summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-05 15:42:07 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-05 15:42:07 +0300
commitb65903e005f1a594b9a66fb9dcff96ca5ea4c04f (patch)
tree62f0a63e29be8d3f376f1363cdfed2faef7316cd /db
parentef7e605ed5b6cf3cc00e0af8b16a7641a498457c (diff)
downloadgitlab-ce-b65903e005f1a594b9a66fb9dcff96ca5ea4c04f.tar.gz
Improve development fixtures
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/06_teams.rb30
-rw-r--r--db/fixtures/development/09_issues.rb2
-rw-r--r--db/fixtures/development/10_merge_requests.rb19
-rw-r--r--db/fixtures/development/11_keys.rb1
4 files changed, 29 insertions, 23 deletions
diff --git a/db/fixtures/development/06_teams.rb b/db/fixtures/development/06_teams.rb
index 9fbf21a02d7..f82977d7fdc 100644
--- a/db/fixtures/development/06_teams.rb
+++ b/db/fixtures/development/06_teams.rb
@@ -1,22 +1,14 @@
-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
diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb
index cd9b2b3e456..d13d520e3dd 100644
--- a/db/fixtures/development/09_issues.rb
+++ b/db/fixtures/development/09_issues.rb
@@ -1,3 +1,5 @@
+ActiveRecord::Base.observers.disable :all
+
Gitlab::Seeder.quiet do
(1..300).each do |i|
# Random Project
diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb
index 6d111b26c53..4d0ec1e6da1 100644
--- a/db/fixtures/development/10_merge_requests.rb
+++ b/db/fixtures/development/10_merge_requests.rb
@@ -1,5 +1,7 @@
+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
diff --git a/db/fixtures/development/11_keys.rb b/db/fixtures/development/11_keys.rb
index 8e4724c277c..4b53ff411f2 100644
--- a/db/fixtures/development/11_keys.rb
+++ b/db/fixtures/development/11_keys.rb
@@ -1,3 +1,4 @@
+ActiveRecord::Base.observers.enable :all
Gitlab::Seeder.quiet do
User.first(30).each_with_index do |user, i|