Commit a517983c authored by Arturo Herrero's avatar Arturo Herrero Committed by Peter Leitzen

Fix specs saving an invalid service

After the changes in ab81251d the specs were misleading.
parent 0a0077c3
......@@ -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