diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-08-11 17:55:31 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-08-11 17:55:31 +0300 |
commit | 2804902cfce28859fbed96e1d9de1d12964800ee (patch) | |
tree | 38e52fbd855305fac8f873b9ca7efdad2602bd9e /db/fixtures | |
parent | 3cc2c6ef79c8b6f511af32c40a336bc8bfc4c2fe (diff) | |
download | gitlab-ce-2804902cfce28859fbed96e1d9de1d12964800ee.tar.gz |
Improve developer seeds
* Improt projects inline so after seeds you have repos
* Fix merge request seeds
* Add comment seeds to both issues and merge requests
* Remove some projects from seeds to increase speed
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db/fixtures')
-rw-r--r-- | db/fixtures/development/01_admin.rb | 25 | ||||
-rw-r--r-- | db/fixtures/development/04_project.rb | 102 | ||||
-rw-r--r-- | db/fixtures/development/05_users.rb | 2 | ||||
-rw-r--r-- | db/fixtures/development/07_milestones.rb | 28 | ||||
-rw-r--r-- | db/fixtures/development/09_issues.rb | 36 | ||||
-rw-r--r-- | db/fixtures/development/10_merge_requests.rb | 20 | ||||
-rw-r--r-- | db/fixtures/development/11_keys.rb | 19 | ||||
-rw-r--r-- | db/fixtures/development/13_comments.rb | 38 |
8 files changed, 123 insertions, 147 deletions
diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb index 176845fd8a8..1927a39f388 100644 --- a/db/fixtures/development/01_admin.rb +++ b/db/fixtures/development/01_admin.rb @@ -1,14 +1,11 @@ -User.seed(:id, [ - { - id: 1, - name: "Administrator", - email: "admin@example.com", - username: 'root', - password: "5iveL!fe", - password_confirmation: "5iveL!fe", - admin: true, - projects_limit: 100, - theme_id: Gitlab::Theme::MARS, - confirmed_at: DateTime.now - } -]) +User.seed do |s| + s.id = 1 + s.name = "Administrator" + s.email = "admin@example.com" + s.username = 'root' + s.password = "5iveL!fe" + s.password_confirmation = "5iveL!fe" + s.admin = true + s.projects_limit = 100 + s.confirmed_at = DateTime.now +end diff --git a/db/fixtures/development/04_project.rb b/db/fixtures/development/04_project.rb index 164bb637809..b93229a0609 100644 --- a/db/fixtures/development/04_project.rb +++ b/db/fixtures/development/04_project.rb @@ -1,56 +1,52 @@ -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, - visibility_level: Gitlab::VisibilityLevel.values.sample - } - - project = Projects::CreateService.new(User.first, params).execute - - if project.valid? - print '.' - else - puts project.errors.full_messages - print 'F' +require 'sidekiq/testing' + +Sidekiq::Testing.inline! do + Gitlab::Seeder.quiet do + project_urls = [ + 'https://github.com/documentcloud/underscore.git', + 'https://github.com/gitlabhq/gitlabhq.git', + 'https://github.com/gitlabhq/gitlab-ci.git', + 'https://github.com/gitlabhq/gitlab-shell.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', + ] + + 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, + visibility_level: Gitlab::VisibilityLevel.values.sample + } + + project = Projects::CreateService.new(User.first, params).execute + + if project.valid? + print '.' + else + puts project.errors.full_messages + print 'F' + end end end end diff --git a/db/fixtures/development/05_users.rb b/db/fixtures/development/05_users.rb index d736408dbf5..f4a5b8631a4 100644 --- a/db/fixtures/development/05_users.rb +++ b/db/fixtures/development/05_users.rb @@ -1,5 +1,5 @@ Gitlab::Seeder.quiet do - (2..10).each do |i| + (2..20).each do |i| begin User.seed(:id, [{ id: i, diff --git a/db/fixtures/development/07_milestones.rb b/db/fixtures/development/07_milestones.rb index 6fe7e246770..2296821e528 100644 --- a/db/fixtures/development/07_milestones.rb +++ b/db/fixtures/development/07_milestones.rb @@ -1,18 +1,16 @@ -Milestone.seed(:id, [ - { id: 1, project_id: 1, title: 'v' + Faker::Address.zip_code }, - { id: 2, project_id: 1, title: 'v' + Faker::Address.zip_code }, - { id: 3, project_id: 1, title: 'v' + Faker::Address.zip_code }, - { id: 4, project_id: 2, title: 'v' + Faker::Address.zip_code }, - { id: 5, project_id: 2, title: 'v' + Faker::Address.zip_code }, +Gitlab::Seeder.quiet do + Project.all.each do |project| + (1..5).each do |i| + milestone_params = { + title: "v#{i}.0", + description: Faker::Lorem.sentence, + state: ['opened', 'closed'].sample, + } - { id: 6, project_id: 2, title: 'v' + Faker::Address.zip_code }, - { id: 7, project_id: 2, title: 'v' + Faker::Address.zip_code }, - { id: 8, project_id: 3, title: 'v' + Faker::Address.zip_code }, - { id: 9, project_id: 3, title: 'v' + Faker::Address.zip_code }, - { id: 11, project_id: 3, title: 'v' + Faker::Address.zip_code }, -]) + milestone = Milestones::CreateService.new( + project, project.team.users.sample, milestone_params).execute -Milestone.all.map do |ml| - ml.set_iid - ml.save + print '.' + end + end end diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb index 635878622d0..e8b01b46d22 100644 --- a/db/fixtures/development/09_issues.rb +++ b/db/fixtures/development/09_issues.rb @@ -1,32 +1,16 @@ Gitlab::Seeder.quiet do - (1..300).each do |i| - # Random Project - project = Project.all.sample - - # Random user - user = project.team.users.sample - - next unless user - - user_id = user.id - - Gitlab::Seeder.by_user(user) do - Issue.seed(:id, [{ - id: i, - project_id: project.id, - author_id: user_id, - assignee_id: user_id, + Project.all.each do |project| + (1..10).each do |i| + issue_params = { + title: Faker::Lorem.sentence(6), + description: Faker::Lorem.sentence, state: ['opened', 'closed'].sample, milestone: project.milestones.sample, - title: Faker::Lorem.sentence(6), - description: Faker::Lorem.sentence - }]) - end - print('.') - end + assignee: project.team.users.sample + } - Issue.all.map do |issue| - issue.set_iid - issue.save + Issues::CreateService.new(project, project.team.users.sample, issue_params).execute + print '.' + end end end diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb index 62fd0d84ea3..03f8de12985 100644 --- a/db/fixtures/development/10_merge_requests.rb +++ b/db/fixtures/development/10_merge_requests.rb @@ -7,27 +7,17 @@ Gitlab::Seeder.quiet do 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(" ") + description: Faker::Lorem.sentences(3).join(" "), + milestone: project.milestones.sample, + assignee: project.team.users.sample } - 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 + MergeRequests::CreateService.new(project, project.team.users.sample, params).execute + print '.' end end end diff --git a/db/fixtures/development/11_keys.rb b/db/fixtures/development/11_keys.rb index 61329f197c3..8b4bee384e1 100644 --- a/db/fixtures/development/11_keys.rb +++ b/db/fixtures/development/11_keys.rb @@ -1,13 +1,12 @@ Gitlab::Seeder.quiet do - User.first(30).each_with_index do |user, i| - Key.seed(:id, [ - { - id: i + 1, - title: "Sample key #{i}", - key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt#{i + 100}6k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", - user_id: user.id, - } - ]) - puts "SSH KEY ##{i} added.".green + User.first(10).each do |user| + key = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt#{user.id + 100}6k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" + + user.keys.create( + title: "Sample key #{user.id}", + key: key + ) + + print '.' end end diff --git a/db/fixtures/development/13_comments.rb b/db/fixtures/development/13_comments.rb index 626aba200d1..d37be53c7b9 100644 --- a/db/fixtures/development/13_comments.rb +++ b/db/fixtures/development/13_comments.rb @@ -1,19 +1,31 @@ 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.each do |issue| + project = issue.project - 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' - }]) + project.team.users.each do |user| + note_params = { + noteable_type: 'Issue', + noteable_id: issue.id, + note: Faker::Lorem.sentence, + } - print '.' - end + Notes::CreateService.new(project, user, note_params).execute + print '.' + end + end + + MergeRequest.all.each do |mr| + project = mr.project + + project.team.users.each do |user| + note_params = { + noteable_type: 'MergeRequest', + noteable_id: mr.id, + note: Faker::Lorem.sentence, + } + + Notes::CreateService.new(project, user, note_params).execute + print '.' end end end |