Commit 23efe5ff authored by Jan Provaznik's avatar Jan Provaznik

Enable setting of project_key

Allow setting of service_desk's project_key attribute (though still
behind a feature flag).
parent fbf4d185
...@@ -22,7 +22,7 @@ class Projects::ServiceDeskController < Projects::ApplicationController ...@@ -22,7 +22,7 @@ class Projects::ServiceDeskController < Projects::ApplicationController
private private
def setting_params def setting_params
params.permit(:issue_template_key, :outgoing_name) params.permit(:issue_template_key, :outgoing_name, :project_key)
end end
def json_response def json_response
...@@ -35,7 +35,8 @@ class Projects::ServiceDeskController < Projects::ApplicationController ...@@ -35,7 +35,8 @@ class Projects::ServiceDeskController < Projects::ApplicationController
service_desk_enabled: project.service_desk_enabled, service_desk_enabled: project.service_desk_enabled,
issue_template_key: service_desk_settings&.issue_template_key, issue_template_key: service_desk_settings&.issue_template_key,
template_file_missing: service_desk_settings&.issue_template_missing?, template_file_missing: service_desk_settings&.issue_template_missing?,
outgoing_name: service_desk_settings&.outgoing_name outgoing_name: service_desk_settings&.outgoing_name,
project_key: service_desk_settings&.project_key
} }
format.json { render json: service_desk_attributes } format.json { render json: service_desk_attributes }
......
...@@ -5,6 +5,10 @@ module ServiceDeskSettings ...@@ -5,6 +5,10 @@ module ServiceDeskSettings
def execute def execute
settings = ServiceDeskSetting.safe_find_or_create_by!(project_id: project.id) settings = ServiceDeskSetting.safe_find_or_create_by!(project_id: project.id)
unless ::Feature.enabled?(:service_desk_custom_address)
params.delete(:project_key)
end
if settings.update(params) if settings.update(params)
success success
else else
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
incoming_email: (@project.service_desk_address if @project.service_desk_enabled), incoming_email: (@project.service_desk_address if @project.service_desk_enabled),
selected_template: "#{@project.service_desk_setting&.issue_template_key}", selected_template: "#{@project.service_desk_setting&.issue_template_key}",
outgoing_name: "#{@project.service_desk_setting&.outgoing_name}", outgoing_name: "#{@project.service_desk_setting&.outgoing_name}",
project_key: "#{@project.service_desk_setting&.project_key}",
templates: issuable_templates_names(Issue.new) } } templates: issuable_templates_names(Issue.new) } }
- elsif show_promotions? && show_callout?('promote_service_desk_dismissed') - elsif show_promotions? && show_callout?('promote_service_desk_dismissed')
= render 'shared/promotions/promote_servicedesk' = render 'shared/promotions/promote_servicedesk'
...@@ -7,13 +7,27 @@ describe ServiceDeskSettings::UpdateService do ...@@ -7,13 +7,27 @@ describe ServiceDeskSettings::UpdateService do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
context 'with valid params' do context 'with valid params' do
let(:params) { { outgoing_name: 'some name' } } let(:params) { { outgoing_name: 'some name', project_key: 'foo' } }
it 'updates service desk settings' do it 'updates service desk settings' do
result = described_class.new(settings.project, user, params).execute result = described_class.new(settings.project, user, params).execute
expect(result[:status]).to eq :success expect(result[:status]).to eq :success
expect(settings.reload.outgoing_name).to eq 'some name' expect(settings.reload.outgoing_name).to eq 'some name'
expect(settings.reload.project_key).to eq 'foo'
end
context 'when service_desk_custom_address is disabled' do
before do
stub_feature_flags(service_desk_custom_address: false)
end
it 'ignores project_key parameter' do
result = described_class.new(settings.project, user, params).execute
expect(result[:status]).to eq :success
expect(settings.reload.project_key).to be_nil
end
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