Commit b593a27d authored by Eugenia Grieff's avatar Eugenia Grieff

Check if BatchLoader is nil

- Fix MergeRequestsResolver to check BatchLoader
If project was not found BatchLoader object
can be nil and project.present? would still
return true

- Add specs for cases when Project is not resolved
parent afee38dd
......@@ -15,7 +15,8 @@ module Resolvers
alias_method :project, :object
def resolve(**args)
return unless project.present?
project = object.respond_to?(:sync) ? object.sync : object
return MergeRequest.none if project.nil?
args[:iids] ||= [args[:iid]].compact
......
......@@ -59,6 +59,12 @@ describe Mutations::ResolvesIssuable do
expect(result).to be_nil
end
it 'returns nil if parent path is empty' do
result = mutation.resolve_issuable(type: type, parent_path: "", iid: issuable.iid)
expect(result).to be_nil
end
end
end
......
......@@ -52,6 +52,12 @@ describe Resolvers::MergeRequestsResolver do
expect(result).to be_empty
end
it 'resolves an unknown project to be empty' do
result = batch_sync { resolve_mr(nil, iid: iid_1) }
expect(result.compact).to be_empty
end
end
def resolve_mr(project, args)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment