Commit dfb172bd authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'sdesk-name-param' into 'master'

Expose service desk project_key param in private API

See merge request gitlab-org/gitlab!24357
parents f153f3a7 23efe5ff
......@@ -22,7 +22,7 @@ class Projects::ServiceDeskController < Projects::ApplicationController
private
def setting_params
params.permit(:issue_template_key, :outgoing_name)
params.permit(:issue_template_key, :outgoing_name, :project_key)
end
def json_response
......@@ -35,7 +35,8 @@ class Projects::ServiceDeskController < Projects::ApplicationController
service_desk_enabled: project.service_desk_enabled,
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
outgoing_name: service_desk_settings&.outgoing_name,
project_key: service_desk_settings&.project_key
}
format.json { render json: service_desk_attributes }
......
......@@ -5,6 +5,10 @@ module ServiceDeskSettings
def execute
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)
success
else
......
......@@ -14,6 +14,7 @@
incoming_email: (@project.service_desk_address if @project.service_desk_enabled),
selected_template: "#{@project.service_desk_setting&.issue_template_key}",
outgoing_name: "#{@project.service_desk_setting&.outgoing_name}",
project_key: "#{@project.service_desk_setting&.project_key}",
templates: issuable_templates_names(Issue.new) } }
- elsif show_promotions? && show_callout?('promote_service_desk_dismissed')
= render 'shared/promotions/promote_servicedesk'
......@@ -7,13 +7,27 @@ describe ServiceDeskSettings::UpdateService do
let_it_be(:user) { create(:user) }
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
result = described_class.new(settings.project, user, params).execute
expect(result[:status]).to eq :success
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
......
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