Wrote specs for GraphQL root resolvers

This commit is contained in:
Alberto Miedes Garcés
2017-01-08 11:37:15 +01:00
parent 0b302c2afc
commit ed6ba384dd
3 changed files with 64 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
require 'rails_helper'
describe GraphQL::RootCollectionResolver do
let(:comments_resolver) { GraphQL::RootCollectionResolver.new(Comment) }
describe '#call' do
it 'resolves collections' do
comment_1 = create(:comment)
comment_2 = create(:comment)
result = comments_resolver.call(nil, nil, nil)
expect(result).to match_array([comment_1, comment_2])
end
it 'blocks collection forbidden elements' do
proposal = create(:proposal, :hidden)
comment_1 = create(:comment)
comment_2 = create(:comment, commentable: proposal)
result = comments_resolver.call(nil, nil, nil)
expect(result).to match_array([comment_1])
end
end
end