Commit c0ced540 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'instance-level-services-multiple-issue-trackers' into 'master'

Improve instance-level services code

See merge request gitlab-org/gitlab!29604
parents 982cb911 a517983c
......@@ -15,9 +15,7 @@ module IntegrationsActions
end
def update
integration.attributes = service_params[:service]
saved = integration.save(context: :manual_change)
saved = integration.update(service_params[:service])
respond_to do |format|
format.html do
......
......@@ -172,7 +172,7 @@ class IssueTrackerService < Service
end
def one_issue_tracker
return if template?
return if template? || instance?
return if project.blank?
if project.services.external_issue_trackers.where.not(id: id).any?
......
......@@ -130,13 +130,11 @@ module API
TRIGGER_SERVICES.each do |service_slug, settings|
helpers do
# rubocop: disable CodeReuse/ActiveRecord
def slash_command_service(project, service_slug, params)
project.services.active.where(template: false).find do |service|
project.services.active.find do |service|
service.try(:token) == params[:token] && service.to_param == service_slug.underscore
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
params do
......
......@@ -49,11 +49,12 @@ describe Admin::IntegrationsController do
end
context 'invalid params' do
let(:url) { 'https://jira.localhost' }
let(:url) { 'invalid' }
it 'updates the integration' do
expect(response).to have_gitlab_http_status(:found)
expect(integration.reload.url).to eq(url)
it 'does not update the integration' do
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:edit)
expect(integration.reload.url).not_to eq(url)
end
end
end
......
......@@ -100,11 +100,12 @@ describe Groups::Settings::IntegrationsController do
end
context 'invalid params' do
let(:url) { 'https://jira.localhost' }
let(:url) { 'invalid' }
it 'does not update the integration' do
expect(response).to have_gitlab_http_status(:found)
expect(integration.reload.url).to eq(url)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:edit)
expect(integration.reload.url).not_to eq(url)
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