summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/graphql/resolves_issuable_shared_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/graphql/resolves_issuable_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/graphql/resolves_issuable_shared_examples.rb41
1 files changed, 16 insertions, 25 deletions
diff --git a/spec/support/shared_examples/graphql/resolves_issuable_shared_examples.rb b/spec/support/shared_examples/graphql/resolves_issuable_shared_examples.rb
index 58cd3d21f66..67d1c2a8254 100644
--- a/spec/support/shared_examples/graphql/resolves_issuable_shared_examples.rb
+++ b/spec/support/shared_examples/graphql/resolves_issuable_shared_examples.rb
@@ -1,7 +1,12 @@
# frozen_string_literal: true
RSpec.shared_examples 'resolving an issuable in GraphQL' do |type|
- subject { mutation.resolve_issuable(type: type, parent_path: parent.full_path, iid: issuable.iid) }
+ include GraphqlHelpers
+
+ let(:parent_path) { parent.full_path }
+ let(:iid) { issuable.iid }
+
+ subject(:result) { mutation.resolve_issuable(type: type, parent_path: parent_path, iid: iid) }
context 'when user has access' do
before do
@@ -9,37 +14,23 @@ RSpec.shared_examples 'resolving an issuable in GraphQL' do |type|
end
it 'resolves issuable by iid' do
- result = type == :merge_request ? subject.sync : subject
expect(result).to eq(issuable)
end
- it 'uses the correct Resolver to resolve issuable' do
- resolver_class = "Resolvers::#{type.to_s.classify.pluralize}Resolver".constantize
- resolve_method = type == :epic ? :resolve_group : :resolve_project
- resolved_parent = mutation.send(resolve_method, full_path: parent.full_path)
-
- allow(mutation).to receive(resolve_method)
- .with(full_path: parent.full_path)
- .and_return(resolved_parent)
-
- expect(resolver_class.single).to receive(:new)
- .with(object: resolved_parent, context: context, field: nil)
- .and_call_original
-
- subject
- end
-
- it 'returns nil if issuable is not found' do
- result = mutation.resolve_issuable(type: type, parent_path: parent.full_path, iid: "100")
- result = result.respond_to?(:sync) ? result.sync : result
+ context 'the IID does not refer to a valid issuable' do
+ let(:iid) { '100' }
- expect(result).to be_nil
+ it 'returns nil' do
+ expect(result).to be_nil
+ end
end
- it 'returns nil if parent path is not present' do
- result = mutation.resolve_issuable(type: type, parent_path: "", iid: issuable.iid)
+ context 'the parent path is not present' do
+ let(:parent_path) { '' }
- expect(result).to be_nil
+ it 'returns nil' do
+ expect(result).to be_nil
+ end
end
end
end