Commit b65903e0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve development fixtures

parent ef7e605e
Gitlab::Seeder.quiet do
(1..300).each do |i|
# Random Project
project = Project.scoped.sample
# Random user
user = User.not_in_project(project).sample
ActiveRecord::Base.observers.disable :all
next unless user
UsersProject.seed(:id, [{
id: i,
project_id: project.id,
user_id: user.id,
project_access: UsersProject.access_roles.values.sample
}])
print('.')
Gitlab::Seeder.quiet do
Project.all.each do |project|
project.team << [User.first, :master]
print '.'
User.all.sample(rand(10)).each do |user|
role = [:master, :developer, :reporter].sample
project.team << [user, role]
print '.'
end
end
end
puts "OK".green
ActiveRecord::Base.observers.disable :all
Gitlab::Seeder.quiet do
(1..300).each do |i|
# Random Project
......
ActiveRecord::Base.observers.disable :all
Gitlab::Seeder.quiet do
(1..300).each do |i|
(1..100).each do |i|
# Random Project
project = Project.all.sample
......@@ -8,19 +10,28 @@ Gitlab::Seeder.quiet do
next unless user
next if project.empty_repo?
branches = project.repository.branch_names.sample(2)
user_id = user.id
MergeRequestObserver.current_user = user
MergeRequest.seed(:id, [{
id: i,
source_branch: 'master',
target_branch: 'feature',
source_branch: branches.first,
target_branch: branches.last,
project_id: project.id,
author_id: user_id,
assignee_id: user_id,
state: ['opened', 'closed'].sample,
milestone: project.milestones.sample,
title: Faker::Lorem.sentence(6)
}])
print('.')
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
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