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