Commit 564e2731 authored by Pavel Shutsin's avatar Pavel Shutsin

Merge branch '346479_fix_mutation_response' into 'master'

Fix response of `securityTrainingUpdate` mutation

See merge request gitlab-org/gitlab!80731
parents d6caf0eb a9fcbb72
......@@ -27,6 +27,12 @@ module Types
field :is_primary, GraphQL::Types::Boolean, null: false,
description: 'Represents whether the provider is set as primary or not.'
def is_primary # rubocop:disable Naming/PredicateName
return false if object.destroyed?
object.is_primary
end
end
end
end
......@@ -6,4 +6,33 @@ RSpec.describe GitlabSchema.types['ProjectSecurityTraining'] do
let(:fields) { %i[id name description url logo_url is_enabled is_primary] }
it { expect(described_class).to have_graphql_fields(fields) }
describe '#is_primary' do
let(:training) { create(:security_training, :primary) }
let(:query) { double('query', schema: GitlabSchema, with_error_handling: true) }
let(:query_context) { GraphQL::Query::Context.new(query: query, values: {}, object: nil) }
let(:type_instance) { described_class.authorized_new(training, query_context) }
subject { type_instance.is_primary }
context 'when the object is destroyed' do
before do
training.destroy!
end
it { is_expected.to be(false) }
end
context 'when the object is not destroyed' do
context 'when the object is not primary' do
let(:training) { create(:security_training) }
it { is_expected.to be(false) }
end
context 'when the object is primary' do
it { is_expected.to be(true) }
end
end
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