summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/services_controller.rb2
-rw-r--r--app/models/gitlab_ci_service.rb10
-rw-r--r--app/views/services/_gitlab_ci.html.haml5
3 files changed, 11 insertions, 6 deletions
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb
index b0fd77424a1..50f7e97af9f 100644
--- a/app/controllers/services_controller.rb
+++ b/app/controllers/services_controller.rb
@@ -19,7 +19,7 @@ class ServicesController < ProjectResourceController
@service = @project.gitlab_ci_service
if @service.update_attributes(params[:service])
- redirect_to :back
+ redirect_to edit_project_service_path(@project, :gitlab_ci)
else
render 'edit'
end
diff --git a/app/models/gitlab_ci_service.rb b/app/models/gitlab_ci_service.rb
index f5734dc2820..020dc868841 100644
--- a/app/models/gitlab_ci_service.rb
+++ b/app/models/gitlab_ci_service.rb
@@ -14,12 +14,16 @@
class GitlabCiService < Service
attr_accessible :project_url
- validates :project_url, presence: true
- validates :token, presence: true
+ validates :project_url, presence: true, if: :activated?
+ validates :token, presence: true, if: :activated?
delegate :execute, to: :service_hook, prefix: nil
- after_save :compose_service_hook
+ after_save :compose_service_hook, if: :activated?
+
+ def activated?
+ active
+ end
def compose_service_hook
hook = service_hook || build_service_hook
diff --git a/app/views/services/_gitlab_ci.html.haml b/app/views/services/_gitlab_ci.html.haml
index b2e2add3ceb..3c9820b32b4 100644
--- a/app/views/services/_gitlab_ci.html.haml
+++ b/app/views/services/_gitlab_ci.html.haml
@@ -11,7 +11,7 @@
%hr
-= form_for(@service, :as => :service, :url => project_service_path(@project, @service), :method => :put) do |f|
+= form_for(@service, :as => :service, :url => project_service_path(@project, :gitlab_ci), :method => :put) do |f|
- if @service.errors.any?
.alert-message.block-message.error
%ul
@@ -39,4 +39,5 @@
.form-actions
= f.submit 'Save', class: 'btn save-btn'
&nbsp;
- = link_to 'Test settings', test_project_service_path(@project), class: 'btn btn-small'
+ - if @service.valid? && @service.active
+ = link_to 'Test settings', test_project_service_path(@project), class: 'btn btn-small'