diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-09-28 14:35:26 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-09-29 11:47:03 +0300 |
commit | 0e3381470870732dff69c9298131062f786d55e7 (patch) | |
tree | 02a4a5e588c73c066fa80222b03065d3b8295e24 /app/models | |
parent | 30c78e70cba395c1336611c58891a75473f8a037 (diff) |
Fix tests
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 2 | ||||
-rw-r--r-- | app/models/ci/commit.rb | 27 | ||||
-rw-r--r-- | app/models/project.rb | 6 |
3 files changed, 24 insertions, 11 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 9ac47ccfe4a..cda4fdd4982 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -186,7 +186,7 @@ module Ci end def project_id - commit.gl_project.gitlab_id + commit.project.id end def project_name diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb index 9a719787649..a6556690b9a 100644 --- a/app/models/ci/commit.rb +++ b/app/models/ci/commit.rb @@ -37,8 +37,15 @@ module Ci end def project - @project ||= gl_project.gitlab_ci_project - @project ||= gl_project.create_gitlab_ci_project + unless @project + gl_project.ensure_ci_project + @project = gl_project.gitlab_ci_project + end + @project + end + + def project_id + project.id end def last_build @@ -116,14 +123,14 @@ module Ci builds_attrs = config_processor.builds_for_stage_and_ref(stage, ref, tag) builds_attrs.map do |build_attrs| builds.create!({ - name: build_attrs[:name], - commands: build_attrs[:script], - tag_list: build_attrs[:tags], - options: build_attrs[:options], - allow_failure: build_attrs[:allow_failure], - stage: build_attrs[:stage], - trigger_request: trigger_request, - }) + name: build_attrs[:name], + commands: build_attrs[:script], + tag_list: build_attrs[:tags], + options: build_attrs[:options], + allow_failure: build_attrs[:allow_failure], + stage: build_attrs[:stage], + trigger_request: trigger_request, + }) end end diff --git a/app/models/project.rb b/app/models/project.rb index 9ecf16d9812..ddf8526d6c2 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -748,6 +748,12 @@ class Project < ActiveRecord::Base gitlab_ci_project.commits.find_by(sha: sha) if gitlab_ci? end + def ensure_ci_project + unless gitlab_ci_project + create_gitlab_ci_project + end + end + def enable_ci(user) # Enable service service = gitlab_ci_service || create_gitlab_ci_service |