Ensure GitLab CI project exists when CI service is activated manually

When I check activeated checkbox in project services for GitLab CI it
cause half-working state when gitlab_ci_project is missing. This patch
fixes it until we have proper behaviour implemented later

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2015-10-01 18:10:09 +02:00
parent 3fa8bd0e67
commit e3bc0e2104
No known key found for this signature in database
GPG key ID: 161B5D6A44D3D88A

View file

@ -22,12 +22,17 @@ class GitlabCiService < CiService
include Gitlab::Application.routes.url_helpers
after_save :compose_service_hook, if: :activated?
after_save :ensure_gitlab_ci_project, if: :activated?
def compose_service_hook
hook = service_hook || build_service_hook
hook.save
end
def ensure_gitlab_ci_project
project.ensure_gitlab_ci_project
end
def supported_events
%w(push tag_push)
end