about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorAkihiko Odaki (@fn_aki@pawoo.net) <akihiko.odaki.4i@stu.hosei.ac.jp>2017-06-04 22:00:08 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-04 15:00:08 +0200
commit02a0fd5b649ff09433e36a17f7d84e13907eca74 (patch)
tree6f7fef2113dceaf403b2bbdd79688145dd3e39ec /spec
parent6505a42be0f0633d1dfaedaa5d4bae399c9481e4 (diff)
Spec InlineRablScope (#3542)
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/inline_rabl_scope_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/lib/inline_rabl_scope_spec.rb b/spec/lib/inline_rabl_scope_spec.rb
new file mode 100644
index 000000000..3fff176e4
--- /dev/null
+++ b/spec/lib/inline_rabl_scope_spec.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe InlineRablScope do
+  describe '#current_account' do
+    it 'returns the given account' do
+      account = Fabricate(:account)
+      expect(InlineRablScope.new(account).current_account).to eq account
+    end
+  end
+
+  describe '#current_user' do
+    it 'returns nil if the given account is nil' do
+      expect(InlineRablScope.new(nil).current_user).to eq nil
+    end
+
+    it 'returns user of account if the given account is not nil' do
+      user = Fabricate(:user)
+      expect(InlineRablScope.new(user.account).current_user).to eq user
+    end
+  end
+end