diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-12-27 06:14:05 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-12-27 06:14:05 +0300 |
commit | 4cbb29cfadb243733185cdfaefe34e15dee35260 (patch) | |
tree | 904eea0215e69a02569271c6df465244b2402d51 /db/fixtures | |
parent | e56a47ab19a6d161732a75e19f385b1df4e4821f (diff) | |
download | gitlab-ce-4cbb29cfadb243733185cdfaefe34e15dee35260.tar.gz |
Fix not_in_project scope. Added counters in admin -> users. Improved seeds
Diffstat (limited to 'db/fixtures')
-rw-r--r-- | db/fixtures/development/001_admin.rb | 10 | ||||
-rw-r--r-- | db/fixtures/development/002_project.rb | 12 | ||||
-rw-r--r-- | db/fixtures/development/003_users.rb | 26 | ||||
-rw-r--r-- | db/fixtures/development/004_teams.rb | 40 | ||||
-rw-r--r-- | db/fixtures/development/006_wall.rb | 8 | ||||
-rw-r--r-- | db/fixtures/development/007_issues.rb | 8 | ||||
-rw-r--r-- | db/fixtures/development/008_merge_requests.rb | 9 | ||||
-rw-r--r-- | db/fixtures/development/009_source_code.rb | 12 | ||||
-rw-r--r-- | db/fixtures/development/010_keys.rb | 8 |
9 files changed, 78 insertions, 55 deletions
diff --git a/db/fixtures/development/001_admin.rb b/db/fixtures/development/001_admin.rb index fa8addbe199..fbe41e4d22d 100644 --- a/db/fixtures/development/001_admin.rb +++ b/db/fixtures/development/001_admin.rb @@ -9,13 +9,3 @@ User.seed(:id, [ admin: true, } ]) - - -Key.seed(:id, [ - { - id: 1, - title: "Sample key", - key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", - user_id: 1, - } -]) diff --git a/db/fixtures/development/002_project.rb b/db/fixtures/development/002_project.rb index 4db11a878ec..d145cc6254f 100644 --- a/db/fixtures/development/002_project.rb +++ b/db/fixtures/development/002_project.rb @@ -1,14 +1,26 @@ Group.seed(:id, [ + { id: 99, name: "GitLab", path: 'gitlab', owner_id: 1 }, { id: 100, name: "Brightbox", path: 'brightbox', owner_id: 1 }, { id: 101, name: "KDE", path: 'kde', owner_id: 1 }, ]) Project.seed(:id, [ + + # Global { id: 1, name: "Underscore.js", path: "underscore", owner_id: 1 }, { id: 2, name: "Diaspora", path: "diaspora", owner_id: 1 }, + + # Brightbox { id: 3, namespace_id: 100, name: "Brightbox CLI", path: "brightbox-cli", owner_id: 1 }, { id: 4, namespace_id: 100, name: "Puppet", path: "puppet", owner_id: 1 }, + + # KDE { id: 5, namespace_id: 101, name: "kdebase", path: "kdebase", owner_id: 1}, { id: 6, namespace_id: 101, name: "kdelibs", path: "kdelibs", owner_id: 1}, { id: 7, namespace_id: 101, name: "amarok", path: "amarok", owner_id: 1}, + + # GitLab + { id: 8, namespace_id: 99, name: "gitlabhq", path: "gitlabhq", owner_id: 1}, + { id: 9, namespace_id: 99, name: "gitlab-ci", path: "gitlab-ci", owner_id: 1}, + { id: 10, namespace_id: 99, name: "gitlab-recipes", path: "gitlab-recipes", owner_id: 1}, ]) diff --git a/db/fixtures/development/003_users.rb b/db/fixtures/development/003_users.rb index 25705f1b726..abcb0259618 100644 --- a/db/fixtures/development/003_users.rb +++ b/db/fixtures/development/003_users.rb @@ -1,11 +1,15 @@ -User.seed(:id, [ - { id: 2, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, - { id: 3, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, - { id: 4, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, - { id: 5, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, - { id: 6, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, - { id: 7, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, - { id: 8, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email}, - { id: 9, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email} -]) - +Gitlab::Seeder.quiet do + (2..300).each do |i| + begin + User.seed(:id, [{ + id: i, + username: Faker::Internet.user_name, + name: Faker::Name.name, + email: Faker::Internet.email, + }]) + print '.' + rescue ActiveRecord::RecordNotSaved + print 'F' + end + end +end diff --git a/db/fixtures/development/004_teams.rb b/db/fixtures/development/004_teams.rb index 2752cb44e1d..7a8f9139d3f 100644 --- a/db/fixtures/development/004_teams.rb +++ b/db/fixtures/development/004_teams.rb @@ -1,24 +1,26 @@ UsersProject.skip_callback(:save, :after, :update_repository) -UsersProject.seed(:id, [ - { :id => 1, :project_id => 1, :user_id => 1, :project_access => UsersProject::MASTER }, - { :id => 2, :project_id => 1, :user_id => 2, :project_access => UsersProject::REPORTER}, - { :id => 3, :project_id => 1, :user_id => 3, :project_access => UsersProject::REPORTER}, - { :id => 4, :project_id => 1, :user_id => 4, :project_access => UsersProject::REPORTER}, - { :id => 5, :project_id => 1, :user_id => 5, :project_access => UsersProject::REPORTER}, - - { :id => 6, :project_id => 2, :user_id => 1, :project_access => UsersProject::MASTER }, - { :id => 7, :project_id => 2, :user_id => 2, :project_access => UsersProject::REPORTER}, - { :id => 8, :project_id => 2, :user_id => 3, :project_access => UsersProject::REPORTER}, - { :id => 9, :project_id => 2, :user_id => 4, :project_access => UsersProject::MASTER}, - { :id => 11, :project_id => 2, :user_id => 5, :project_access => UsersProject::MASTER}, - - { :id => 12, :project_id => 3, :user_id => 1, :project_access => UsersProject::MASTER }, - { :id => 13, :project_id => 3, :user_id => 2, :project_access => UsersProject::REPORTER}, - { :id => 14, :project_id => 3, :user_id => 3, :project_access => UsersProject::MASTER}, - { :id => 15, :project_id => 3, :user_id => 4, :project_access => UsersProject::REPORTER}, - { :id => 16, :project_id => 3, :user_id => 5, :project_access => UsersProject::MASTER} -]) +Gitlab::Seeder.quiet do + + (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, [{ + id: i, + project_id: project.id, + user_id: user.id, + project_access: UsersProject.access_roles.values.sample + }]) + + print('.') + end +end UsersProject.set_callback(:save, :after, :update_repository) diff --git a/db/fixtures/development/006_wall.rb b/db/fixtures/development/006_wall.rb index a9fb66dda6b..c4e304cc217 100644 --- a/db/fixtures/development/006_wall.rb +++ b/db/fixtures/development/006_wall.rb @@ -1,16 +1,18 @@ Gitlab::Seeder.quiet do (1..300).each do |i| # Random Project - project_id = rand(2) + 1 - project = Project.find(project_id) + project = Project.all.sample # Random user user = project.users.sample + + next unless user + user_id = user.id Note.seed(:id, [{ id: i, - project_id: project_id, + project_id: project.id, author_id: user_id, note: Faker::Lorem.sentence(6) }]) diff --git a/db/fixtures/development/007_issues.rb b/db/fixtures/development/007_issues.rb index 98e32fccc3d..8978db4742b 100644 --- a/db/fixtures/development/007_issues.rb +++ b/db/fixtures/development/007_issues.rb @@ -1,17 +1,19 @@ Gitlab::Seeder.quiet do (1..300).each do |i| # Random Project - project_id = rand(2) + 1 - project = Project.find(project_id) + project = Project.all.sample # Random user user = project.users.sample + + next unless user + user_id = user.id IssueObserver.current_user = user Issue.seed(:id, [{ id: i, - project_id: project_id, + project_id: project.id, author_id: user_id, assignee_id: user_id, closed: [true, false].sample, diff --git a/db/fixtures/development/008_merge_requests.rb b/db/fixtures/development/008_merge_requests.rb index 698c55ad95f..9904b4a1505 100644 --- a/db/fixtures/development/008_merge_requests.rb +++ b/db/fixtures/development/008_merge_requests.rb @@ -1,19 +1,20 @@ Gitlab::Seeder.quiet do (1..300).each do |i| # Random Project - project_id = rand(2) + 1 - project = Project.find(project_id) + project = Project.all.sample # Random user user = project.users.sample + + next unless user + user_id = user.id MergeRequestObserver.current_user = user - MergeRequest.seed(:id, [{ id: i, source_branch: 'master', target_branch: 'feature', - project_id: project_id, + project_id: project.id, author_id: user_id, assignee_id: user_id, closed: [true, false].sample, diff --git a/db/fixtures/development/009_source_code.rb b/db/fixtures/development/009_source_code.rb index 6b9b6584a58..d3fe69c6f55 100644 --- a/db/fixtures/development/009_source_code.rb +++ b/db/fixtures/development/009_source_code.rb @@ -1,16 +1,18 @@ -root = Gitlab.config.git_base_path +root = Gitlab.config.gitolite.repos_path projects = [ - { path: 'underscore.git', git: 'https://github.com/documentcloud/underscore.git' }, - { path: 'diaspora.git', git: 'https://github.com/diaspora/diaspora.git' }, + { path: 'underscore.git', git: 'https://github.com/documentcloud/underscore.git' }, + { path: 'diaspora.git', git: 'https://github.com/diaspora/diaspora.git' }, { path: 'brightbox/brightbox-cli.git', git: 'https://github.com/brightbox/brightbox-cli.git' }, - { path: 'brightbox/puppet.git', git: 'https://github.com/brightbox/puppet.git' }, + { path: 'brightbox/puppet.git', git: 'https://github.com/brightbox/puppet.git' }, + { path: 'gitlab/gitlabhq.git', git: 'https://github.com/gitlabhq/gitlabhq.git' }, + { path: 'gitlab/gitlab-ci.git', git: 'https://github.com/gitlabhq/gitlab-ci.git' }, + { path: 'gitlab/gitlab-recipres.git', git: 'https://github.com/gitlabhq/gitlab-recipes.git' }, ] projects.each do |project| project_path = File.join(root, project[:path]) - next if File.exists?(project_path) cmds = [ diff --git a/db/fixtures/development/010_keys.rb b/db/fixtures/development/010_keys.rb new file mode 100644 index 00000000000..d17e73db56b --- /dev/null +++ b/db/fixtures/development/010_keys.rb @@ -0,0 +1,8 @@ +Key.seed(:id, [ + { + id: 1, + title: "Sample key", + key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", + user_id: 1, + } +]) |