Commit f56541de authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Revert "Create dev fixture projects with fixed visibility"

This reverts commit a9fadce3.
parent 5136b6ae
Gitlab::Seeder.quiet do require 'sidekiq/testing'
project_urls = [
'https://github.com/documentcloud/underscore.git', Sidekiq::Testing.inline! do
'https://gitlab.com/gitlab-org/gitlab-ce.git', Gitlab::Seeder.quiet do
'https://gitlab.com/gitlab-org/gitlab-ci.git', project_urls = [
'https://gitlab.com/gitlab-org/gitlab-shell.git', 'https://github.com/documentcloud/underscore.git',
'https://gitlab.com/gitlab-org/gitlab-test.git', 'https://gitlab.com/gitlab-org/gitlab-ce.git',
'https://github.com/twitter/flight.git', 'https://gitlab.com/gitlab-org/gitlab-ci.git',
'https://github.com/twitter/typeahead.js.git', 'https://gitlab.com/gitlab-org/gitlab-shell.git',
'https://github.com/h5bp/html5-boilerplate.git', 'https://gitlab.com/gitlab-org/gitlab-test.git',
] 'https://github.com/twitter/flight.git',
'https://github.com/twitter/typeahead.js.git',
project_urls.each do |url| 'https://github.com/h5bp/html5-boilerplate.git',
group_path, project_path = url.split('/')[-2..-1] ]
group = Group.find_by(path: group_path) project_urls.each_with_index do |url, i|
group_path, project_path = url.split('/')[-2..-1]
unless group
group = Group.new( group = Group.find_by(path: group_path)
name: group_path.titleize,
path: group_path unless group
) group = Group.new(
group.description = Faker::Lorem.sentence name: group_path.titleize,
group.save path: group_path
)
group.add_owner(User.first) group.description = Faker::Lorem.sentence
end group.save
project_path.gsub!('.git', '') group.add_owner(User.first)
end
params = {
import_url: url, project_path.gsub!(".git", "")
namespace_id: group.id,
name: project_path.titleize, params = {
description: Faker::Lorem.sentence, import_url: url,
visibility_level: Gitlab::VisibilityLevel.values.sample namespace_id: group.id,
} name: project_path.titleize,
description: Faker::Lorem.sentence,
project = Projects::CreateService.new(User.first, params).execute visibility_level: Gitlab::VisibilityLevel.values.sample
}
if project.valid?
print '.' project = Projects::CreateService.new(User.first, params).execute
else
puts project.errors.full_messages if project.valid?
print 'F' print '.'
else
puts project.errors.full_messages
print 'F'
end
end end
end end
end end
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
module FixturesDevelopmentHelper
class << self
def template_project
@template_project ||= Project.
find_with_namespace('gitlab-org/gitlab-test')
end
end
end
require 'sidekiq/testing'
module Gitlab module Gitlab
class Seeder class Seeder
def self.quiet def self.quiet
mute_mailer mute_mailer
SeedFu.quiet = true SeedFu.quiet = true
Sidekiq::Testing.inline! do yield
yield
end
SeedFu.quiet = false SeedFu.quiet = false
puts "\nOK".green puts "\nOK".green
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment