diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-08-17 14:30:36 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-08-18 17:31:06 +0300 |
commit | d3af645e6aee2430e0882a25dc7ad11c80f23aea (patch) | |
tree | a2ac8cd4aecb96f4f06e569dda688dd151b98498 /db | |
parent | ac73de508e21af95b473bfafc2ca2543b234430d (diff) |
Refactor pipeline fixtures for dev env a little
Diffstat (limited to 'db')
-rw-r--r-- | db/fixtures/development/14_builds.rb | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/db/fixtures/development/14_builds.rb b/db/fixtures/development/14_builds.rb index 069d9dd6226..3b02dddc1fd 100644 --- a/db/fixtures/development/14_builds.rb +++ b/db/fixtures/development/14_builds.rb @@ -34,33 +34,38 @@ class Gitlab::Seeder::Builds end end + private + def pipelines - master_pipelines + merge_request_pipelines + create_master_pipelines + create_merge_request_pipelines end - def master_pipelines - create_pipelines_for(@project, 'master') + def create_master_pipelines + @project.repository.commits('master', limit: 5).map do |commit| + create_pipeline!(@project, 'master', commit) + end rescue [] end - def merge_request_pipelines - @project.merge_requests.last(5).map do |merge_request| - create_pipelines(merge_request.source_project, merge_request.source_branch, merge_request.commits.last(5)) - end.flatten + def create_merge_request_pipelines + pipelines = @project.merge_requests.first(5).map do |merge_request| + project = merge_request.source_project + branch = merge_request.source_branch + + merge_request.commits.last(5).map do |commit| + create_pipeline!(project, branch, commit) + end + end + + pipelines.flatten rescue [] end - def create_pipelines_for(project, ref) - commits = project.repository.commits(ref, limit: 5) - create_pipelines(project, ref, commits) - end - def create_pipelines(project, ref, commits) - commits.map do |commit| - project.pipelines.create(sha: commit.id, ref: ref) - end + def create_pipeline!(project, ref, commit) + project.pipelines.create(sha: commit.id, ref: ref) end def build_create!(pipeline, opts = {}) |