Commit 598b8f14 authored by charlie ablett's avatar charlie ablett

Merge branch '216391-allow-require_graphql_authorizations-to-work-for-mutations' into 'master'

Allow require_graphql_authorizations to work for mutation specs

Closes #216391

See merge request gitlab-org/gitlab!30958
parents ed59e4dc 7e08d73d
......@@ -16,6 +16,8 @@ describe Mutations::Issues::Update do
let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }
let(:mutated_issue) { subject[:issue] }
specify { expect(described_class).to require_graphql_authorizations(:update_issue) }
describe '#resolve' do
let(:mutation_params) do
{
......
# frozen_string_literal: true
RSpec::Matchers.define :require_graphql_authorizations do |*expected|
match do |field|
expect(field.to_graphql.metadata[:authorize]).to eq(*expected)
match do |klass|
permissions = if klass.respond_to?(:required_permissions)
klass.required_permissions
else
[klass.to_graphql.metadata[:authorize]]
end
expect(permissions).to eq(expected)
end
end
......
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