Commit 9f65c274 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix ci service creation logic

parent 406a0c80
......@@ -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
......
......@@ -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
......
......@@ -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;
- if @service.valid? && @service.active
= link_to 'Test settings', test_project_service_path(@project), class: 'btn btn-small'
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