From 4cb5e5011abfe8d50ac3a7ebd0018c563c6d7af4 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 13 Mar 2020 09:09:23 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/controllers/projects/services_controller.rb | 30 ++++++++++++------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'app/controllers/projects/services_controller.rb') diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index c916140211e..92c6ce324f7 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -52,28 +52,26 @@ class Projects::ServicesController < Projects::ApplicationController private def service_test_response - if @service.update(service_params[:service]) - data = @service.test_data(project, current_user) - outcome = @service.test(data) - - if outcome[:success] - {} - else - { error: true, message: _('Test failed.'), service_response: outcome[:result].to_s, test_failed: true } - end - else - { error: true, message: _('Validations failed.'), service_response: @service.errors.full_messages.join(','), test_failed: false } + unless @service.update(service_params[:service]) + return { error: true, message: _('Validations failed.'), service_response: @service.errors.full_messages.join(','), test_failed: false } + end + + data = @service.test_data(project, current_user) + outcome = @service.test(data) + + unless outcome[:success] + return { error: true, message: _('Test failed.'), service_response: outcome[:result].to_s, test_failed: true } end + + {} rescue Gitlab::HTTP::BlockedUrlError => e { error: true, message: _('Test failed.'), service_response: e.message, test_failed: true } end def success_message - if @service.active? - _("%{service_title} activated.") % { service_title: @service.title } - else - _("%{service_title} settings saved, but not activated.") % { service_title: @service.title } - end + message = @service.active? ? _('activated') : _('settings saved, but not activated') + + _('%{service_title} %{message}.') % { service_title: @service.title, message: message } end def service -- cgit v1.2.1