Commit f47ba909a29f70d59180a373b9a89dd8935fd455
1 parent
86d9ed9a
Exists in
master
and in
4 other branches
Fix seeds. More projects for dev seeds
Showing
8 changed files
with
63 additions
and
60 deletions
Show diff stats
db/fixtures/development/01_admin.rb
db/fixtures/development/02_source_code.rb
@@ -1,29 +0,0 @@ | @@ -1,29 +0,0 @@ | ||
1 | -gitlab_shell_path = File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}") | ||
2 | -root = Gitlab.config.gitlab_shell.repos_path | ||
3 | - | ||
4 | -projects = [ | ||
5 | - { path: 'underscore.git', git: 'https://github.com/documentcloud/underscore.git' }, | ||
6 | - { path: 'diaspora.git', git: 'https://github.com/diaspora/diaspora.git' }, | ||
7 | - { path: 'brightbox/brightbox-cli.git', git: 'https://github.com/brightbox/brightbox-cli.git' }, | ||
8 | - { path: 'brightbox/puppet.git', git: 'https://github.com/brightbox/puppet.git' }, | ||
9 | - { path: 'gitlab/gitlabhq.git', git: 'https://github.com/gitlabhq/gitlabhq.git' }, | ||
10 | - { path: 'gitlab/gitlab-ci.git', git: 'https://github.com/gitlabhq/gitlab-ci.git' }, | ||
11 | - { path: 'gitlab/gitlab-recipes.git', git: 'https://github.com/gitlabhq/gitlab-recipes.git' }, | ||
12 | -] | ||
13 | - | ||
14 | -projects.each do |project| | ||
15 | - project_path = File.join(root, project[:path]) | ||
16 | - | ||
17 | - if File.exists?(project_path) | ||
18 | - print '-' | ||
19 | - next | ||
20 | - end | ||
21 | - if system("#{gitlab_shell_path}/gitlab-shell/bin/gitlab-projects import-project #{project[:path]} #{project[:git]}") | ||
22 | - print '.' | ||
23 | - else | ||
24 | - print 'F' | ||
25 | - end | ||
26 | -end | ||
27 | - | ||
28 | -puts "OK".green | ||
29 | - |
db/fixtures/development/03_group.rb
db/fixtures/development/04_project.rb
1 | -Project.seed(:id, [ | 1 | +project_urls = [ |
2 | + 'https://github.com/documentcloud/underscore.git', | ||
3 | + 'https://github.com/diaspora/diaspora.git', | ||
4 | + 'https://github.com/diaspora/diaspora-project-site.git', | ||
5 | + 'https://github.com/diaspora/diaspora-client.git', | ||
6 | + 'https://github.com/brightbox/brightbox-cli.git', | ||
7 | + 'https://github.com/brightbox/puppet.git', | ||
8 | + 'https://github.com/gitlabhq/gitlabhq.git', | ||
9 | + 'https://github.com/gitlabhq/gitlab-ci.git', | ||
10 | + 'https://github.com/gitlabhq/gitlab-recipes.git', | ||
11 | + 'https://github.com/gitlabhq/gitlab-shell.git', | ||
12 | + 'https://github.com/gitlabhq/grack.git', | ||
13 | + 'https://github.com/twitter/flight.git', | ||
14 | + 'https://github.com/twitter/typeahead.js.git', | ||
15 | + 'https://github.com/h5bp/html5-boilerplate.git', | ||
16 | + 'https://github.com/h5bp/mobile-boilerplate.git', | ||
17 | +] | ||
2 | 18 | ||
3 | - # Global | ||
4 | - { id: 1, name: "Underscore.js", path: "underscore", creator_id: 1 }, | ||
5 | - { id: 2, name: "Diaspora", path: "diaspora", creator_id: 1 }, | 19 | +project_urls.each_with_index do |url, i| |
20 | + group_path, project_path = url.split('/')[-2..-1] | ||
6 | 21 | ||
7 | - # Brightbox | ||
8 | - { id: 3, namespace_id: 100, name: "Brightbox CLI", path: "brightbox-cli", creator_id: 1 }, | ||
9 | - { id: 4, namespace_id: 100, name: "Puppet", path: "puppet", creator_id: 1 }, | 22 | + group = Group.find_by_path(group_path) |
10 | 23 | ||
11 | - # KDE | ||
12 | - { id: 5, namespace_id: 101, name: "kdebase", path: "kdebase", creator_id: 1}, | ||
13 | - { id: 6, namespace_id: 101, name: "kdelibs", path: "kdelibs", creator_id: 1}, | ||
14 | - { id: 7, namespace_id: 101, name: "amarok", path: "amarok", creator_id: 1}, | 24 | + unless group |
25 | + group = Group.new( | ||
26 | + name: group_path.titleize, | ||
27 | + path: group_path | ||
28 | + ) | ||
29 | + group.owner = User.first | ||
30 | + group.save | ||
31 | + end | ||
15 | 32 | ||
16 | - # GitLab | ||
17 | - { id: 8, namespace_id: 99, name: "gitlabhq", path: "gitlabhq", creator_id: 1}, | ||
18 | - { id: 9, namespace_id: 99, name: "gitlab-ci", path: "gitlab-ci", creator_id: 1}, | ||
19 | - { id: 10, namespace_id: 99, name: "gitlab-recipes", path: "gitlab-recipes", creator_id: 1}, | ||
20 | -]) | 33 | + project_path.gsub!(".git", "") |
34 | + | ||
35 | + params = { | ||
36 | + import_url: url, | ||
37 | + namespace_id: group.id, | ||
38 | + name: project_path.titleize | ||
39 | + } | ||
40 | + | ||
41 | + project = Projects::CreateContext.new(User.first, params).execute | ||
42 | + | ||
43 | + if project.valid? | ||
44 | + print '.' | ||
45 | + else | ||
46 | + puts project.errors.full_messages | ||
47 | + print 'F' | ||
48 | + end | ||
49 | +end |
db/fixtures/development/05_users.rb
db/fixtures/development/06_teams.rb
1 | ActiveRecord::Base.observers.disable :all | 1 | ActiveRecord::Base.observers.disable :all |
2 | 2 | ||
3 | Gitlab::Seeder.quiet do | 3 | Gitlab::Seeder.quiet do |
4 | - Project.all.each do |project| | ||
5 | - project.team << [User.first, :master] | ||
6 | - print '.' | 4 | + Group.all.each do |group| |
5 | + User.all.sample(4).each do |user| | ||
6 | + if group.add_users([user.id], UsersGroup.group_access_roles.values.sample) | ||
7 | + print '.' | ||
8 | + else | ||
9 | + print 'F' | ||
10 | + end | ||
11 | + end | ||
12 | + end | ||
7 | 13 | ||
8 | - User.all.sample(rand(10)).each do |user| | ||
9 | - role = [:master, :developer, :reporter].sample | ||
10 | - project.team << [user, role] | ||
11 | - print '.' | 14 | + Project.all.each do |project| |
15 | + User.all.sample(4).each do |user| | ||
16 | + if project.team << [user, UsersProject.access_roles.values.sample] | ||
17 | + print '.' | ||
18 | + else | ||
19 | + print 'F' | ||
20 | + end | ||
12 | end | 21 | end |
13 | end | 22 | end |
14 | end | 23 | end |
db/fixtures/development/09_issues.rb
db/fixtures/development/10_merge_requests.rb
@@ -17,7 +17,6 @@ Gitlab::Seeder.quiet do | @@ -17,7 +17,6 @@ Gitlab::Seeder.quiet do | ||
17 | next if branches.uniq.size < 2 | 17 | next if branches.uniq.size < 2 |
18 | 18 | ||
19 | user_id = user.id | 19 | user_id = user.id |
20 | - MergeRequestObserver.current_user = user | ||
21 | MergeRequest.seed(:id, [{ | 20 | MergeRequest.seed(:id, [{ |
22 | id: i, | 21 | id: i, |
23 | source_branch: branches.first, | 22 | source_branch: branches.first, |