From 02a0fd5b649ff09433e36a17f7d84e13907eca74 Mon Sep 17 00:00:00 2001 From: "Akihiko Odaki (@fn_aki@pawoo.net)" Date: Sun, 4 Jun 2017 22:00:08 +0900 Subject: [PATCH] Spec InlineRablScope (#3542) --- spec/lib/inline_rabl_scope_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 spec/lib/inline_rabl_scope_spec.rb diff --git a/spec/lib/inline_rabl_scope_spec.rb b/spec/lib/inline_rabl_scope_spec.rb new file mode 100644 index 0000000000..3fff176e46 --- /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