Commit b65903e0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve development fixtures

parent ef7e605e
Gitlab::Seeder.quiet do ActiveRecord::Base.observers.disable :all
(1..300).each do |i|
# Random Project
project = Project.scoped.sample
# Random user
user = User.not_in_project(project).sample
next unless user
UsersProject.seed(:id, [{ Gitlab::Seeder.quiet do
id: i, Project.all.each do |project|
project_id: project.id, project.team << [User.first, :master]
user_id: user.id, print '.'
project_access: UsersProject.access_roles.values.sample
}]) User.all.sample(rand(10)).each do |user|
role = [:master, :developer, :reporter].sample
print('.') project.team << [user, role]
print '.'
end
end end
end end
puts "OK".green
ActiveRecord::Base.observers.disable :all
Gitlab::Seeder.quiet do Gitlab::Seeder.quiet do
(1..300).each do |i| (1..300).each do |i|
# Random Project # Random Project
......
ActiveRecord::Base.observers.disable :all
Gitlab::Seeder.quiet do Gitlab::Seeder.quiet do
(1..300).each do |i| (1..100).each do |i|
# Random Project # Random Project
project = Project.all.sample project = Project.all.sample
...@@ -8,19 +10,28 @@ Gitlab::Seeder.quiet do ...@@ -8,19 +10,28 @@ Gitlab::Seeder.quiet do
next unless user next unless user
next if project.empty_repo?
branches = project.repository.branch_names.sample(2)
user_id = user.id user_id = user.id
MergeRequestObserver.current_user = user MergeRequestObserver.current_user = user
MergeRequest.seed(:id, [{ MergeRequest.seed(:id, [{
id: i, id: i,
source_branch: 'master', source_branch: branches.first,
target_branch: 'feature', target_branch: branches.last,
project_id: project.id, project_id: project.id,
author_id: user_id, author_id: user_id,
assignee_id: user_id, assignee_id: user_id,
state: ['opened', 'closed'].sample,
milestone: project.milestones.sample, milestone: project.milestones.sample,
title: Faker::Lorem.sentence(6) title: Faker::Lorem.sentence(6)
}]) }])
print('.') print('.')
end end
end end
puts 'Load diffs for Merge Requests (it will take some time)...'
MergeRequest.all.each do |mr|
mr.reload_code
print '.'
end
ActiveRecord::Base.observers.enable :all
Gitlab::Seeder.quiet do Gitlab::Seeder.quiet do
User.first(30).each_with_index do |user, i| User.first(30).each_with_index do |user, i|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment