Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
1d337def
Commit
1d337def
authored
Nov 07, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8168 from cirosantilli/dev-fixtures-visibility
Create dev fixture projects with fixed visibility
parents
2bb8e93d
a9fadce3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
50 deletions
+96
-50
db/fixtures/development/04_project.rb
db/fixtures/development/04_project.rb
+45
-49
db/fixtures/development/07_projects_visibility.rb
db/fixtures/development/07_projects_visibility.rb
+38
-0
db/fixtures/development/08_milestones.rb
db/fixtures/development/08_milestones.rb
+0
-0
db/fixtures/development/fixtures_development_helper.rb
db/fixtures/development/fixtures_development_helper.rb
+8
-0
lib/gitlab/seeder.rb
lib/gitlab/seeder.rb
+5
-1
No files found.
db/fixtures/development/04_project.rb
View file @
1d337def
require
'sidekiq/testing'
Gitlab
::
Seeder
.
quiet
do
project_urls
=
[
Sidekiq
::
Testing
.
inline!
do
'https://github.com/documentcloud/underscore.git'
,
Gitlab
::
Seeder
.
quiet
do
'https://gitlab.com/gitlab-org/gitlab-ce.git'
,
project_urls
=
[
'https://gitlab.com/gitlab-org/gitlab-ci.git'
,
'https://github.com/documentcloud/underscore.git'
,
'https://gitlab.com/gitlab-org/gitlab-shell.git'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
,
'https://gitlab.com/gitlab-org/gitlab-test.git'
,
'https://gitlab.com/gitlab-org/gitlab-ci.git'
,
'https://github.com/twitter/flight.git'
,
'https://gitlab.com/gitlab-org/gitlab-shell.git'
,
'https://github.com/twitter/typeahead.js.git'
,
'https://gitlab.com/gitlab-org/gitlab-test.git'
,
'https://github.com/h5bp/html5-boilerplate.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
]
project_urls
.
each_with_index
do
|
url
,
i
|
group
=
Group
.
find_by
(
path:
group_path
)
group_path
,
project_path
=
url
.
split
(
'/'
)[
-
2
..-
1
]
unless
group
group
=
Group
.
find_by
(
path:
group_path
)
group
=
Group
.
new
(
name:
group_path
.
titleize
,
unless
group
path:
group_path
group
=
Group
.
new
(
)
name:
group_path
.
titleize
,
group
.
description
=
Faker
::
Lorem
.
sentence
path:
group_path
group
.
save
)
group
.
description
=
Faker
::
Lorem
.
sentence
group
.
add_owner
(
User
.
first
)
group
.
save
end
group
.
add_owner
(
User
.
first
)
project_path
.
gsub!
(
'.git'
,
''
)
end
params
=
{
project_path
.
gsub!
(
".git"
,
""
)
import_url:
url
,
namespace_id:
group
.
id
,
params
=
{
name:
project_path
.
titleize
,
import_url:
url
,
description:
Faker
::
Lorem
.
sentence
,
namespace_id:
group
.
id
,
visibility_level:
Gitlab
::
VisibilityLevel
.
values
.
sample
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?
project
=
Projects
::
CreateService
.
new
(
User
.
first
,
params
).
execute
print
'.'
else
if
project
.
valid?
puts
project
.
errors
.
full_messages
print
'.'
print
'F'
else
puts
project
.
errors
.
full_messages
print
'F'
end
end
end
end
end
end
end
db/fixtures/development/07_projects_visibility.rb
0 → 100644
View file @
1d337def
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
db/fixtures/development/0
7
_milestones.rb
→
db/fixtures/development/0
8
_milestones.rb
View file @
1d337def
File moved
db/fixtures/development/fixtures_development_helper.rb
0 → 100644
View file @
1d337def
module
FixturesDevelopmentHelper
class
<<
self
def
template_project
@template_project
||=
Project
.
find_with_namespace
(
'gitlab-org/gitlab-test'
)
end
end
end
lib/gitlab/seeder.rb
View file @
1d337def
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
yield
Sidekiq
::
Testing
.
inline!
do
yield
end
SeedFu
.
quiet
=
false
SeedFu
.
quiet
=
false
puts
"
\n
OK"
.
green
puts
"
\n
OK"
.
green
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment