Commit b3a1af26 authored by Michael Leopard's avatar Michael Leopard Committed by Michael Kozono

Update CiCdSettingsUpdate mutation to accept MR pipelines and merge trains

parent 4aa39fc5
......@@ -17,13 +17,23 @@ module Mutations
required: false,
description: 'Indicates if the latest artifact should be kept for this project.'
field :ci_cd_settings,
Types::Ci::CiCdSettingType,
null: false,
description: 'The CI/CD settings after mutation.'
def resolve(full_path:, **args)
project = authorized_find!(full_path)
settings = project.ci_cd_settings
settings.update(args)
{ errors: errors_on_object(settings) }
{
ci_cd_settings: settings,
errors: errors_on_object(settings)
}
end
end
end
end
Mutations::Ci::CiCdSettingsUpdate.prepend_if_ee('::EE::Mutations::Ci::CiCdSettingsUpdate')
......@@ -1055,6 +1055,7 @@ Autogenerated return type of CiCdSettingsUpdate.
| Field | Type | Description |
| ----- | ---- | ----------- |
| `ciCdSettings` | [`ProjectCiCdSetting!`](#projectcicdsetting) | The CI/CD settings after mutation. |
| `clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
| `errors` | [`[String!]!`](#string) | Errors encountered during execution of the mutation. |
......
# frozen_string_literal: true
module EE
module Mutations
module Ci
module CiCdSettingsUpdate
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
prepended do
argument :merge_pipelines_enabled, GraphQL::BOOLEAN_TYPE,
required: false,
description: 'Indicates if merge pipelines are enabled for the project.'
argument :merge_trains_enabled, GraphQL::BOOLEAN_TYPE,
required: false,
description: 'Indicates if merge trains are enabled for the project.'
end
end
end
end
end
---
title: Update CiCdSettingsUpdate mutation to accept MR pipelines and merge trains
merge_request: 58592
author:
type: added
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Mutations::Ci::CiCdSettingsUpdate do
include GraphqlHelpers
let_it_be(:project) { create(:project) }
let(:user) { project.owner }
let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }
subject { mutation.resolve(full_path: project.full_path, **mutation_params) }
before do
stub_licensed_features(merge_pipelines: true, merge_trains: true)
stub_feature_flags(disable_merge_trains: false)
project.merge_pipelines_enabled = nil
project.merge_trains_enabled = false
subject
project.reload
end
describe '#resolve' do
context 'when merge trains are set to true and merge pipelines are set to false' do
let(:mutation_params) do
{
full_path: project.full_path,
merge_pipelines_enabled: false,
merge_trains_enabled: true
}
end
it 'does not enable merge trains' do
expect(project.ci_cd_settings.merge_trains_enabled?).to eq(false)
end
end
context 'when merge trains and merge pipelines are set to true' do
let(:mutation_params) do
{
full_path: project.full_path,
merge_pipelines_enabled: true,
merge_trains_enabled: true
}
end
it 'enables merge pipelines and merge trains' do
expect(project.merge_pipelines_enabled?).to eq(true)
expect(project.merge_trains_enabled?).to eq(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