diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-28 09:11:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-28 09:11:12 +0300 |
commit | a1ea041b49c20794ea94564bf07837692645ce11 (patch) | |
tree | 46126c28dcda7b0ddc8b3aacc0a198ff0a9fa5ea | |
parent | a488d0c499d9544ccf0c886e21c44ff6c6440730 (diff) |
Add latest changes from gitlab-org/gitlab@master
4 files changed, 48 insertions, 6 deletions
diff --git a/app/controllers/projects/service_desk_controller.rb b/app/controllers/projects/service_desk_controller.rb index ca3cecf5949..70cb439c4f3 100644 --- a/app/controllers/projects/service_desk_controller.rb +++ b/app/controllers/projects/service_desk_controller.rb @@ -29,7 +29,7 @@ class Projects::ServiceDeskController < Projects::ApplicationController end def allowed_update_attributes - %i[issue_template_key outgoing_name project_key] + %i[issue_template_key outgoing_name project_key add_external_participants_from_cc] end def service_desk_attributes @@ -41,7 +41,8 @@ class Projects::ServiceDeskController < Projects::ApplicationController issue_template_key: service_desk_settings&.issue_template_key, template_file_missing: service_desk_settings&.issue_template_missing?, outgoing_name: service_desk_settings&.outgoing_name, - project_key: service_desk_settings&.project_key + project_key: service_desk_settings&.project_key, + add_external_participants_from_cc: service_desk_settings&.add_external_participants_from_cc } end diff --git a/app/services/service_desk_settings/update_service.rb b/app/services/service_desk_settings/update_service.rb index 182022beb1d..f8b825923f3 100644 --- a/app/services/service_desk_settings/update_service.rb +++ b/app/services/service_desk_settings/update_service.rb @@ -9,6 +9,8 @@ module ServiceDeskSettings params[:project_key] = nil if params[:project_key].blank? + apply_feature_flag_restrictions! + # We want to know when custom email got enabled write_log_message = params[:custom_email_enabled].present? && !settings.custom_email_enabled? @@ -20,5 +22,14 @@ module ServiceDeskSettings ServiceResponse.error(message: settings.errors.full_messages.to_sentence) end end + + private + + def apply_feature_flag_restrictions! + return if Feature.enabled?(:issue_email_participants, project) + return unless params.include?(:add_external_participants_from_cc) + + params.delete(:add_external_participants_from_cc) + end end end diff --git a/spec/requests/projects/service_desk_controller_spec.rb b/spec/requests/projects/service_desk_controller_spec.rb index 05e48c2c5c7..7d881d8ea62 100644 --- a/spec/requests/projects/service_desk_controller_spec.rb +++ b/spec/requests/projects/service_desk_controller_spec.rb @@ -88,6 +88,16 @@ RSpec.describe Projects::ServiceDeskController, feature_category: :service_desk expect(json_response['issue_template_key']).to eq('service_desk') end + it 'sets add_external_participants_from_cc' do + put project_service_desk_path(project, format: :json), params: { add_external_participants_from_cc: true } + project.reset + + settings = project.service_desk_setting + expect(settings).to be_present + expect(settings.add_external_participants_from_cc).to eq(true) + expect(json_response['add_external_participants_from_cc']).to eq(true) + end + it 'returns an error when update of service desk settings fails' do put project_service_desk_path(project, format: :json), params: { issue_template_key: 'invalid key' } diff --git a/spec/services/service_desk_settings/update_service_spec.rb b/spec/services/service_desk_settings/update_service_spec.rb index 27978225bcf..a9e54012075 100644 --- a/spec/services/service_desk_settings/update_service_spec.rb +++ b/spec/services/service_desk_settings/update_service_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -RSpec.describe ServiceDeskSettings::UpdateService, feature_category: :service_desk do +RSpec.describe ServiceDeskSettings::UpdateService, :aggregate_failures, feature_category: :service_desk do describe '#execute' do let_it_be(:settings) do create(:service_desk_setting, outgoing_name: 'original name', custom_email: 'user@example.com') @@ -12,14 +12,17 @@ RSpec.describe ServiceDeskSettings::UpdateService, feature_category: :service_de let_it_be(:user) { create(:user) } context 'with valid params' do - let(:params) { { outgoing_name: 'some name', project_key: 'foo' } } + let(:params) { { outgoing_name: 'some name', project_key: 'foo', add_external_participants_from_cc: true } } it 'updates service desk settings' do response = described_class.new(settings.project, user, params).execute expect(response).to be_success - expect(settings.reload.outgoing_name).to eq 'some name' - expect(settings.reload.project_key).to eq 'foo' + expect(settings.reset).to have_attributes( + outgoing_name: 'some name', + project_key: 'foo', + add_external_participants_from_cc: true + ) end context 'with custom email verification in finished state' do @@ -39,6 +42,23 @@ RSpec.describe ServiceDeskSettings::UpdateService, feature_category: :service_de expect(Gitlab::AppLogger).to have_received(:info).with({ category: 'custom_email' }) end end + + context 'when issue_email_participants feature flag is disabled' do + before do + stub_feature_flags(issue_email_participants: false) + end + + it 'updates service desk setting but not add_external_participants_from_cc value' do + response = described_class.new(settings.project, user, params).execute + + expect(response).to be_success + expect(settings.reset).to have_attributes( + outgoing_name: 'some name', + project_key: 'foo', + add_external_participants_from_cc: false + ) + end + end end context 'when project_key is an empty string' do |