Commit 9f65c274efbebf569b9d5576a33eabebda31e7e9
1 parent
406a0c80
Exists in
master
and in
4 other branches
Fix ci service creation logic
Showing
3 changed files
with
11 additions
and
6 deletions
Show diff stats
app/controllers/services_controller.rb
... | ... | @@ -19,7 +19,7 @@ class ServicesController < ProjectResourceController |
19 | 19 | @service = @project.gitlab_ci_service |
20 | 20 | |
21 | 21 | if @service.update_attributes(params[:service]) |
22 | - redirect_to :back | |
22 | + redirect_to edit_project_service_path(@project, :gitlab_ci) | |
23 | 23 | else |
24 | 24 | render 'edit' |
25 | 25 | end | ... | ... |
app/models/gitlab_ci_service.rb
... | ... | @@ -14,12 +14,16 @@ |
14 | 14 | class GitlabCiService < Service |
15 | 15 | attr_accessible :project_url |
16 | 16 | |
17 | - validates :project_url, presence: true | |
18 | - validates :token, presence: true | |
17 | + validates :project_url, presence: true, if: :activated? | |
18 | + validates :token, presence: true, if: :activated? | |
19 | 19 | |
20 | 20 | delegate :execute, to: :service_hook, prefix: nil |
21 | 21 | |
22 | - after_save :compose_service_hook | |
22 | + after_save :compose_service_hook, if: :activated? | |
23 | + | |
24 | + def activated? | |
25 | + active | |
26 | + end | |
23 | 27 | |
24 | 28 | def compose_service_hook |
25 | 29 | hook = service_hook || build_service_hook | ... | ... |
app/views/services/_gitlab_ci.html.haml
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | %hr |
12 | 12 | |
13 | 13 | |
14 | -= form_for(@service, :as => :service, :url => project_service_path(@project, @service), :method => :put) do |f| | |
14 | += form_for(@service, :as => :service, :url => project_service_path(@project, :gitlab_ci), :method => :put) do |f| | |
15 | 15 | - if @service.errors.any? |
16 | 16 | .alert-message.block-message.error |
17 | 17 | %ul |
... | ... | @@ -39,4 +39,5 @@ |
39 | 39 | .form-actions |
40 | 40 | = f.submit 'Save', class: 'btn save-btn' |
41 | 41 | |
42 | - = link_to 'Test settings', test_project_service_path(@project), class: 'btn btn-small' | |
42 | + - if @service.valid? && @service.active | |
43 | + = link_to 'Test settings', test_project_service_path(@project), class: 'btn btn-small' | ... | ... |