summaryrefslogtreecommitdiff
path: root/db/fixtures
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-08-16 16:18:44 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-08-17 10:14:11 +0100
commitf52f62d7aec168b3b8c291cdb81f64501bd80e5a (patch)
tree532702ec8b9f4d58f6fdc0685f78b8ef785401b9 /db/fixtures
parentfee7992c08c434940f0722886dc96f249a8e7fbf (diff)
downloadgitlab-ce-f52f62d7aec168b3b8c291cdb81f64501bd80e5a.tar.gz
Update fixtures to make development testing easier
Diffstat (limited to 'db/fixtures')
-rw-r--r--db/fixtures/development/14_builds.rb32
1 files changed, 26 insertions, 6 deletions
diff --git a/db/fixtures/development/14_builds.rb b/db/fixtures/development/14_builds.rb
index e65abe4ef77..3734c861078 100644
--- a/db/fixtures/development/14_builds.rb
+++ b/db/fixtures/development/14_builds.rb
@@ -28,24 +28,44 @@ class Gitlab::Seeder::Builds
build_create!(pipeline, name: 'production', stage: 'deploy', environment: 'production', when: 'manual', status: :success)
commit_status_create!(pipeline, name: 'jenkins', status: :success)
-
print '.'
rescue ActiveRecord::RecordInvalid
print 'F'
+ ensure
+ pipeline.build_updated
end
end
end
def pipelines
- commits = @project.repository.commits('master', limit: 5)
- commits_sha = commits.map { |commit| commit.raw.id }
- commits_sha.map do |sha|
- @project.ensure_pipeline(sha, 'master')
- end
+ master_pipelines + merge_request_pipelines
+ end
+
+ def master_pipelines
+ create_pipelines_for(@project, 'master')
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
+ 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
+ end
+
def build_create!(pipeline, opts = {})
attributes = build_attributes_for(pipeline, opts)
build = Ci::Build.create!(attributes)