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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
029ef7a6
Commit
029ef7a6
authored
Jul 04, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Projects::CreateService and specs to make EE-only code clearer
parent
b99e3ca2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
43 deletions
+63
-43
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+12
-7
spec/services/ee/projects/create_service_spec.rb
spec/services/ee/projects/create_service_spec.rb
+51
-0
spec/services/projects/create_service_spec.rb
spec/services/projects/create_service_spec.rb
+0
-36
No files found.
app/services/projects/create_service.rb
View file @
029ef7a6
...
...
@@ -22,7 +22,7 @@ module Projects
return
@project
end
# Repository size limit comes as MB from the view
#
EE-only:
Repository size limit comes as MB from the view
set_repository_size_limit_as_bytes
set_project_name_from_path
...
...
@@ -103,12 +103,8 @@ module Projects
@project
.
add_master
(
owners
,
current_user:
current_user
)
end
predefined_push_rule
=
PushRule
.
find_by
(
is_sample:
true
)
if
predefined_push_rule
push_rule
=
predefined_push_rule
.
dup
.
tap
{
|
gh
|
gh
.
is_sample
=
false
}
project
.
push_rule
=
push_rule
end
# EE-only
create_predefined_push_rule
@project
.
group
&
.
refresh_members_authorized_projects
end
...
...
@@ -166,5 +162,14 @@ module Projects
@project
.
path
=
@project
.
name
.
dup
.
parameterize
end
end
def
create_predefined_push_rule
predefined_push_rule
=
PushRule
.
find_by
(
is_sample:
true
)
if
predefined_push_rule
push_rule
=
predefined_push_rule
.
dup
.
tap
{
|
gh
|
gh
.
is_sample
=
false
}
project
.
push_rule
=
push_rule
end
end
end
end
spec/services/ee/projects/create_service_spec.rb
0 → 100644
View file @
029ef7a6
require
'spec_helper'
describe
Projects
::
CreateService
,
'#execute'
,
services:
true
do
let
(
:user
)
{
create
:user
}
let
(
:opts
)
do
{
name:
"GitLab"
,
namespace:
user
.
namespace
}
end
context
'repository_size_limit assignment as Bytes'
do
let
(
:admin_user
)
{
create
(
:user
,
admin:
true
)
}
context
'when param present'
do
let
(
:opts
)
{
{
repository_size_limit:
'100'
}
}
it
'assign repository_size_limit as Bytes'
do
project
=
create_project
(
admin_user
,
opts
)
expect
(
project
.
repository_size_limit
).
to
eql
(
100
*
1024
*
1024
)
end
end
context
'when param not present'
do
let
(
:opts
)
{
{
repository_size_limit:
''
}
}
it
'assign nil value'
do
project
=
create_project
(
admin_user
,
opts
)
expect
(
project
.
repository_size_limit
).
to
be_nil
end
end
end
context
'git hook sample'
do
it
'creates git hook from sample'
do
push_rule_sample
=
create
(
:push_rule_sample
)
push_rule
=
create_project
(
user
,
opts
).
push_rule
[
:force_push_regex
,
:deny_delete_tag
,
:delete_branch_regex
,
:commit_message_regex
].
each
do
|
attr_name
|
expect
(
push_rule
.
send
(
attr_name
)).
to
eq
push_rule_sample
.
send
(
attr_name
)
end
end
end
def
create_project
(
user
,
opts
)
Projects
::
CreateService
.
new
(
user
,
opts
).
execute
end
end
spec/services/projects/create_service_spec.rb
View file @
029ef7a6
...
...
@@ -110,30 +110,6 @@ describe Projects::CreateService, '#execute', services: true do
end
end
context
'repository_size_limit assignment as Bytes'
do
let
(
:admin_user
)
{
create
(
:user
,
admin:
true
)
}
context
'when param present'
do
let
(
:opts
)
{
{
repository_size_limit:
'100'
}
}
it
'assign repository_size_limit as Bytes'
do
project
=
create_project
(
admin_user
,
opts
)
expect
(
project
.
repository_size_limit
).
to
eql
(
100
*
1024
*
1024
)
end
end
context
'when param not present'
do
let
(
:opts
)
{
{
repository_size_limit:
''
}
}
it
'assign nil value'
do
project
=
create_project
(
admin_user
,
opts
)
expect
(
project
.
repository_size_limit
).
to
be_nil
end
end
end
context
'restricted visibility level'
do
before
do
stub_application_setting
(
restricted_visibility_levels:
[
Gitlab
::
VisibilityLevel
::
PUBLIC
])
...
...
@@ -161,18 +137,6 @@ describe Projects::CreateService, '#execute', services: true do
end
end
context
'git hook sample'
do
it
'creates git hook from sample'
do
push_rule_sample
=
create
(
:push_rule_sample
)
push_rule
=
create_project
(
user
,
opts
).
push_rule
[
:force_push_regex
,
:deny_delete_tag
,
:delete_branch_regex
,
:commit_message_regex
].
each
do
|
attr_name
|
expect
(
push_rule
.
send
(
attr_name
)).
to
eq
push_rule_sample
.
send
(
attr_name
)
end
end
end
context
'repository creation'
do
it
'synchronously creates the repository'
do
expect_any_instance_of
(
Project
).
to
receive
(
:create_repository
)
...
...
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