diff options
author | Marin Jankovski <maxlazio@gmail.com> | 2014-11-07 15:26:48 +0100 |
---|---|---|
committer | Marin Jankovski <maxlazio@gmail.com> | 2014-11-07 15:26:48 +0100 |
commit | 1d337defec2f180744ec9a3e03bd3786b184b113 (patch) | |
tree | 76fceb36405431fee1e0bcf3cda2ed3487003b48 /db/fixtures | |
parent | 2bb8e93d80de6b09caa6a1d9305acc468f0e3d4b (diff) | |
parent | a9fadce361163e97eb1de0ec62e4235ff0fa3daa (diff) | |
download | gitlab-ce-1d337defec2f180744ec9a3e03bd3786b184b113.tar.gz |
Merge pull request #8168 from cirosantilli/dev-fixtures-visibility
Create dev fixture projects with fixed visibility
Diffstat (limited to 'db/fixtures')
-rw-r--r-- | db/fixtures/development/04_project.rb | 94 | ||||
-rw-r--r-- | db/fixtures/development/07_projects_visibility.rb | 38 | ||||
-rw-r--r-- | db/fixtures/development/08_milestones.rb (renamed from db/fixtures/development/07_milestones.rb) | 0 | ||||
-rw-r--r-- | db/fixtures/development/fixtures_development_helper.rb | 8 |
4 files changed, 91 insertions, 49 deletions
diff --git a/db/fixtures/development/04_project.rb b/db/fixtures/development/04_project.rb index ae4c0550a4f..a39e7ac028c 100644 --- a/db/fixtures/development/04_project.rb +++ b/db/fixtures/development/04_project.rb @@ -1,52 +1,48 @@ -require 'sidekiq/testing' - -Sidekiq::Testing.inline! do - Gitlab::Seeder.quiet do - project_urls = [ - 'https://github.com/documentcloud/underscore.git', - 'https://gitlab.com/gitlab-org/gitlab-ce.git', - 'https://gitlab.com/gitlab-org/gitlab-ci.git', - 'https://gitlab.com/gitlab-org/gitlab-shell.git', - 'https://gitlab.com/gitlab-org/gitlab-test.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 +Gitlab::Seeder.quiet do + project_urls = [ + 'https://github.com/documentcloud/underscore.git', + 'https://gitlab.com/gitlab-org/gitlab-ce.git', + 'https://gitlab.com/gitlab-org/gitlab-ci.git', + 'https://gitlab.com/gitlab-org/gitlab-shell.git', + 'https://gitlab.com/gitlab-org/gitlab-test.git', + 'https://github.com/twitter/flight.git', + 'https://github.com/twitter/typeahead.js.git', + 'https://github.com/h5bp/html5-boilerplate.git', + ] + + project_urls.each do |url| + 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 diff --git a/db/fixtures/development/07_projects_visibility.rb b/db/fixtures/development/07_projects_visibility.rb new file mode 100644 index 00000000000..c3287584a07 --- /dev/null +++ b/db/fixtures/development/07_projects_visibility.rb @@ -0,0 +1,38 @@ +require Rails.root.join('db', 'fixtures', Rails.env, 'fixtures_development_helper') + +Gitlab::Seeder.quiet do + Gitlab::VisibilityLevel.options.each do |visibility_label, visibility_value| + visibility_label_downcase = visibility_label.downcase + begin + user = User.seed(:username) do |s| + username = "#{visibility_label_downcase}-owner" + s.username = username + s.name = "#{visibility_label} Owner" + s.email = "#{username}@example.com" + s.password = '12345678' + s.confirmed_at = DateTime.now + end[0] + + # import_url does not work for local paths, + # so we just copy the template repository in. + unless Project.find_with_namespace("#{user.namespace.id}/"\ + "#{visibility_label_downcase}") + params = { + name: "#{visibility_label} Project", + description: "#{visibility_label} Project description", + namespace_id: user.namespace.id, + visibility_level: visibility_value, + } + project = Projects::CreateService.new(user, params).execute + new_path = project.repository.path + FileUtils.rm_rf(new_path) + FileUtils.cp_r(FixturesDevelopmentHelper.template_project.repository.path, + new_path) + end + + print '.' + rescue ActiveRecord::RecordNotSaved + print 'F' + end + end +end diff --git a/db/fixtures/development/07_milestones.rb b/db/fixtures/development/08_milestones.rb index 2296821e528..2296821e528 100644 --- a/db/fixtures/development/07_milestones.rb +++ b/db/fixtures/development/08_milestones.rb diff --git a/db/fixtures/development/fixtures_development_helper.rb b/db/fixtures/development/fixtures_development_helper.rb new file mode 100644 index 00000000000..22a7834bbee --- /dev/null +++ b/db/fixtures/development/fixtures_development_helper.rb @@ -0,0 +1,8 @@ +module FixturesDevelopmentHelper + class << self + def template_project + @template_project ||= Project. + find_with_namespace('gitlab-org/gitlab-test') + end + end +end |