diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-05-05 16:07:19 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-05-05 16:07:19 +0400 |
commit | f5c4bda8fe53549f2ba63484359543f272954a61 (patch) | |
tree | ef4752fb002017f728b61d2e7bc7645437c7e76b /db/fixtures/development | |
parent | 4f670fbe9c83bdf20e1a58d3166848ab6d453b6c (diff) |
Improve MR seeds
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db/fixtures/development')
-rw-r--r-- | db/fixtures/development/10_merge_requests.rb | 70 |
1 files changed, 29 insertions, 41 deletions
diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb index cb08a7c2537..62fd0d84ea3 100644 --- a/db/fixtures/development/10_merge_requests.rb +++ b/db/fixtures/development/10_merge_requests.rb @@ -1,45 +1,33 @@ Gitlab::Seeder.quiet do - (1..100).each do |i| - # Random Project - project = Project.all.sample - - # Random user - user = project.team.users.sample - - next unless user - - next if project.empty_repo? - - branches = project.repository.branch_names.sample(2) - - next if branches.uniq.size < 2 - - user_id = user.id - - Gitlab::Seeder.by_user(user) do - MergeRequest.seed(:id, [{ - id: i, - source_branch: branches.first, - target_branch: branches.last, - source_project_id: project.id, - target_project_id: project.id, - author_id: user_id, - assignee_id: user_id, - milestone: project.milestones.sample, - title: Faker::Lorem.sentence(6) - }]) + Project.all.reject(&:empty_repo?).each do |project| + branches = project.repository.branch_names + + branches.each do |branch_name| + break if branches.size < 2 + source_branch = branches.pop + target_branch = branches.pop + + # Random user + user = project.team.users.sample + next unless user + + params = { + source_branch: source_branch, + target_branch: target_branch, + title: Faker::Lorem.sentence(6), + description: Faker::Lorem.sentences(3).join(" ") + } + + merge_request = MergeRequests::CreateService.new(project, user, params).execute + + if merge_request.valid? + merge_request.assignee = user + merge_request.milestone = project.milestones.sample + merge_request.save + print '.' + else + print 'F' + end end - print('.') end end - -MergeRequest.all.map do |mr| - mr.set_iid - mr.save -end - -puts 'Load diffs for Merge Requests (it will take some time)...' -MergeRequest.all.each do |mr| - mr.reload_code - print '.' -end |