summaryrefslogtreecommitdiff
path: root/db/fixtures
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-15 11:39:35 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-15 11:39:35 +0200
commit39f80884db394decdb4b4a21a30bc1ecb3203944 (patch)
treee261a14a3eec5cea67d1479901c3bf1faed14a35 /db/fixtures
parent6e73b208a9f69c68bf8575d902d6662eb3db0662 (diff)
downloadgitlab-ce-39f80884db394decdb4b4a21a30bc1ecb3203944.tar.gz
Improve developer seeds
Return execution of observers in seeds. Mute email sending to letter opening in you browser. Added `rake dev` task to reset db and add seeds. Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db/fixtures')
-rw-r--r--db/fixtures/development/01_admin.rb5
-rw-r--r--db/fixtures/development/04_project.rb104
-rw-r--r--db/fixtures/development/05_users.rb1
-rw-r--r--db/fixtures/development/06_teams.rb2
-rw-r--r--db/fixtures/development/09_issues.rb8
-rw-r--r--db/fixtures/development/10_merge_requests.rb7
-rw-r--r--db/fixtures/development/11_keys.rb2
-rw-r--r--db/fixtures/development/12_snippets.rb2
-rw-r--r--db/fixtures/development/13_comments.rb26
9 files changed, 74 insertions, 83 deletions
diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb
index 3e76d76e838..42d18435340 100644
--- a/db/fixtures/development/01_admin.rb
+++ b/db/fixtures/development/01_admin.rb
@@ -8,8 +8,7 @@ User.seed(:id, [
password_confirmation: "5iveL!fe",
admin: true,
projects_limit: 100,
- theme_id: Gitlab::Theme::MARS
+ theme_id: Gitlab::Theme::MARS,
+ confirmed_at: DateTime.now
}
])
-
-User.find(1).confirm!
diff --git a/db/fixtures/development/04_project.rb b/db/fixtures/development/04_project.rb
index d0d0774e0c8..9303ab93300 100644
--- a/db/fixtures/development/04_project.rb
+++ b/db/fixtures/development/04_project.rb
@@ -1,53 +1,55 @@
-project_urls = [
- 'https://github.com/documentcloud/underscore.git',
- 'https://github.com/diaspora/diaspora.git',
- 'https://github.com/diaspora/diaspora-project-site.git',
- 'https://github.com/diaspora/diaspora-client.git',
- 'https://github.com/brightbox/brightbox-cli.git',
- 'https://github.com/brightbox/puppet.git',
- 'https://github.com/gitlabhq/gitlabhq.git',
- 'https://github.com/gitlabhq/gitlab-ci.git',
- 'https://github.com/gitlabhq/gitlab-recipes.git',
- 'https://github.com/gitlabhq/gitlab-shell.git',
- 'https://github.com/gitlabhq/grack.git',
- 'https://github.com/gitlabhq/testme.git',
- 'https://github.com/twitter/flight.git',
- 'https://github.com/twitter/typeahead.js.git',
- 'https://github.com/h5bp/html5-boilerplate.git',
- 'https://github.com/h5bp/mobile-boilerplate.git',
-]
-
-project_urls.each_with_index do |url, i|
- group_path, project_path = url.split('/')[-2..-1]
-
- group = Group.find_by(path: group_path)
-
- unless group
- group = Group.new(
- name: group_path.titleize,
- path: group_path
- )
- group.description = Faker::Lorem.sentence
- group.save
-
- group.add_owner(User.first)
- end
-
- project_path.gsub!(".git", "")
-
- params = {
- import_url: url,
- namespace_id: group.id,
- name: project_path.titleize,
- description: Faker::Lorem.sentence
- }
-
- project = Projects::CreateService.new(User.first, params).execute
-
- if project.valid?
- print '.'
- else
- puts project.errors.full_messages
- print 'F'
+Gitlab::Seeder.quiet do
+ project_urls = [
+ 'https://github.com/documentcloud/underscore.git',
+ 'https://github.com/diaspora/diaspora.git',
+ 'https://github.com/diaspora/diaspora-project-site.git',
+ 'https://github.com/diaspora/diaspora-client.git',
+ 'https://github.com/brightbox/brightbox-cli.git',
+ 'https://github.com/brightbox/puppet.git',
+ 'https://github.com/gitlabhq/gitlabhq.git',
+ 'https://github.com/gitlabhq/gitlab-ci.git',
+ 'https://github.com/gitlabhq/gitlab-recipes.git',
+ 'https://github.com/gitlabhq/gitlab-shell.git',
+ 'https://github.com/gitlabhq/grack.git',
+ 'https://github.com/gitlabhq/testme.git',
+ 'https://github.com/twitter/flight.git',
+ 'https://github.com/twitter/typeahead.js.git',
+ 'https://github.com/h5bp/html5-boilerplate.git',
+ 'https://github.com/h5bp/mobile-boilerplate.git',
+ ]
+
+ project_urls.each_with_index do |url, i|
+ group_path, project_path = url.split('/')[-2..-1]
+
+ group = Group.find_by(path: group_path)
+
+ unless group
+ group = Group.new(
+ name: group_path.titleize,
+ path: group_path
+ )
+ group.description = Faker::Lorem.sentence
+ group.save
+
+ group.add_owner(User.first)
+ end
+
+ project_path.gsub!(".git", "")
+
+ params = {
+ import_url: url,
+ namespace_id: group.id,
+ name: project_path.titleize,
+ description: Faker::Lorem.sentence
+ }
+
+ project = Projects::CreateService.new(User.first, params).execute
+
+ if project.valid?
+ print '.'
+ else
+ puts project.errors.full_messages
+ print 'F'
+ end
end
end
diff --git a/db/fixtures/development/05_users.rb b/db/fixtures/development/05_users.rb
index 3440a645408..d736408dbf5 100644
--- a/db/fixtures/development/05_users.rb
+++ b/db/fixtures/development/05_users.rb
@@ -6,6 +6,7 @@ Gitlab::Seeder.quiet do
username: Faker::Internet.user_name,
name: Faker::Name.name,
email: Faker::Internet.email,
+ confirmed_at: DateTime.now
}])
print '.'
rescue ActiveRecord::RecordNotSaved
diff --git a/db/fixtures/development/06_teams.rb b/db/fixtures/development/06_teams.rb
index a1e01879db5..dfbe75fd20e 100644
--- a/db/fixtures/development/06_teams.rb
+++ b/db/fixtures/development/06_teams.rb
@@ -1,5 +1,3 @@
-ActiveRecord::Base.observers.disable :all
-
Gitlab::Seeder.quiet do
Group.all.each do |group|
User.all.sample(4).each do |user|
diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb
index 2b81d7a2597..635878622d0 100644
--- a/db/fixtures/development/09_issues.rb
+++ b/db/fixtures/development/09_issues.rb
@@ -1,5 +1,3 @@
-ActiveRecord::Base.observers.disable :all
-
Gitlab::Seeder.quiet do
(1..300).each do |i|
# Random Project
@@ -12,9 +10,7 @@ Gitlab::Seeder.quiet do
user_id = user.id
- begin
- Thread.current[:current_user] = user
-
+ Gitlab::Seeder.by_user(user) do
Issue.seed(:id, [{
id: i,
project_id: project.id,
@@ -25,8 +21,6 @@ Gitlab::Seeder.quiet do
title: Faker::Lorem.sentence(6),
description: Faker::Lorem.sentence
}])
- ensure
- Thread.current[:current_user] = nil
end
print('.')
end
diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb
index 2b1f4160211..cb08a7c2537 100644
--- a/db/fixtures/development/10_merge_requests.rb
+++ b/db/fixtures/development/10_merge_requests.rb
@@ -1,5 +1,3 @@
-ActiveRecord::Base.observers.disable :all
-
Gitlab::Seeder.quiet do
(1..100).each do |i|
# Random Project
@@ -17,9 +15,8 @@ Gitlab::Seeder.quiet do
next if branches.uniq.size < 2
user_id = user.id
- begin
- Thread.current[:current_user] = user
+ Gitlab::Seeder.by_user(user) do
MergeRequest.seed(:id, [{
id: i,
source_branch: branches.first,
@@ -31,8 +28,6 @@ Gitlab::Seeder.quiet do
milestone: project.milestones.sample,
title: Faker::Lorem.sentence(6)
}])
- ensure
- Thread.current[:current_user] = nil
end
print('.')
end
diff --git a/db/fixtures/development/11_keys.rb b/db/fixtures/development/11_keys.rb
index 4b53ff411f2..42171393d1b 100644
--- a/db/fixtures/development/11_keys.rb
+++ b/db/fixtures/development/11_keys.rb
@@ -1,5 +1,3 @@
-ActiveRecord::Base.observers.enable :all
-
Gitlab::Seeder.quiet do
User.first(30).each_with_index do |user, i|
Key.seed(:id, [
diff --git a/db/fixtures/development/12_snippets.rb b/db/fixtures/development/12_snippets.rb
index 4ca8afe294e..dced2706264 100644
--- a/db/fixtures/development/12_snippets.rb
+++ b/db/fixtures/development/12_snippets.rb
@@ -1,5 +1,3 @@
-ActiveRecord::Base.observers.disable :all
-
Gitlab::Seeder.quiet do
contents = [
`curl https://gist.github.com/randx/4275756/raw/da2f262920c96d1a970d48bf2e99147954b1f4bd/glus1204.sh`,
diff --git a/db/fixtures/development/13_comments.rb b/db/fixtures/development/13_comments.rb
index b133ec3146d..626aba200d1 100644
--- a/db/fixtures/development/13_comments.rb
+++ b/db/fixtures/development/13_comments.rb
@@ -1,13 +1,19 @@
-ActiveRecord::Base.observers.disable :all
+Gitlab::Seeder.quiet do
+ Issue.all.limit(10).each_with_index do |issue, i|
+ 5.times do
+ user = issue.project.team.users.sample
-Issue.all.limit(10).each_with_index do |issue, i|
- 5.times do
- Note.seed(:id, [{
- project_id: issue.project.id,
- author_id: issue.project.team.users.sample.id,
- note: Faker::Lorem.sentence,
- noteable_id: issue.id,
- noteable_type: 'Issue'
- }])
+ Gitlab::Seeder.by_user(user) do
+ Note.seed(:id, [{
+ project_id: issue.project.id,
+ author_id: user.id,
+ note: Faker::Lorem.sentence,
+ noteable_id: issue.id,
+ noteable_type: 'Issue'
+ }])
+
+ print '.'
+ end
+ end
end
end