diff options
Diffstat (limited to 'spec/graphql/resolvers/base_resolver_spec.rb')
-rw-r--r-- | spec/graphql/resolvers/base_resolver_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/base_resolver_spec.rb b/spec/graphql/resolvers/base_resolver_spec.rb index a212bd07f35..0a21b2797ee 100644 --- a/spec/graphql/resolvers/base_resolver_spec.rb +++ b/spec/graphql/resolvers/base_resolver_spec.rb @@ -8,8 +8,12 @@ describe Resolvers::BaseResolver do let(:resolver) do Class.new(described_class) do def resolve(**args) + process(object) + [args, args] end + + def process(obj); end end end @@ -69,4 +73,26 @@ describe Resolvers::BaseResolver do expect(field.to_graphql.complexity.call({}, { sort: 'foo', iids: [1, 2, 3] }, 1)).to eq 3 end end + + describe '#object' do + let_it_be(:user) { create(:user) } + + it 'returns object' do + expect_next_instance_of(resolver) do |r| + expect(r).to receive(:process).with(user) + end + + resolve(resolver, obj: user) + end + + context 'when object is a presenter' do + it 'returns presented object' do + expect_next_instance_of(resolver) do |r| + expect(r).to receive(:process).with(user) + end + + resolve(resolver, obj: UserPresenter.new(user)) + end + end + end end |