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
Boxiang Sun
gitlab-ce
Commits
c301ab04
Commit
c301ab04
authored
Dec 24, 2015
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some specs for forked project visibility_level cases
parent
3cfd892f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+24
-0
spec/services/projects/update_service_spec.rb
spec/services/projects/update_service_spec.rb
+39
-0
No files found.
spec/models/project_spec.rb
View file @
c301ab04
...
...
@@ -552,4 +552,28 @@ describe Project, models: true do
end
end
end
describe
'#visibility_level_allowed?'
do
let
(
:project
)
{
create
:project
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
}
context
'when checking on non-forked project'
do
it
{
expect
(
project
.
visibility_level_allowed?
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)).
to
be_truthy
}
it
{
expect
(
project
.
visibility_level_allowed?
(
Gitlab
::
VisibilityLevel
::
INTERNAL
)).
to
be_truthy
}
it
{
expect
(
project
.
visibility_level_allowed?
(
Gitlab
::
VisibilityLevel
::
PUBLIC
)).
to
be_truthy
}
end
context
'when checking on forked project'
do
let
(
:forked_project
)
{
create
:forked_project_with_submodules
}
before
do
forked_project
.
build_forked_project_link
(
forked_to_project_id:
forked_project
.
id
,
forked_from_project_id:
project
.
id
)
forked_project
.
save
end
it
{
expect
(
forked_project
.
visibility_level_allowed?
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)).
to
be_truthy
}
it
{
expect
(
forked_project
.
visibility_level_allowed?
(
Gitlab
::
VisibilityLevel
::
INTERNAL
)).
to
be_truthy
}
it
{
expect
(
forked_project
.
visibility_level_allowed?
(
Gitlab
::
VisibilityLevel
::
PUBLIC
)).
to
be_falsey
}
end
end
end
spec/services/projects/update_service_spec.rb
View file @
c301ab04
...
...
@@ -100,6 +100,45 @@ describe Projects::UpdateService, services: true do
end
end
describe
:visibility_level
do
let
(
:user
)
{
create
:user
,
admin:
true
}
let
(
:project
)
{
create
:project
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
}
let
(
:forked_project
)
{
create
:forked_project_with_submodules
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
}
let
(
:opts
)
{
{}
}
before
do
forked_project
.
build_forked_project_link
(
forked_to_project_id:
forked_project
.
id
,
forked_from_project_id:
project
.
id
)
forked_project
.
save
@created_internal
=
project
.
internal?
@fork_created_internal
=
forked_project
.
internal?
end
context
'should update forks visibility level when parent set to more restrictive'
do
before
do
opts
.
merge!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
update_project
(
project
,
user
,
opts
).
inspect
end
it
{
expect
(
@created_internal
).
to
be_truthy
}
it
{
expect
(
@fork_created_internal
).
to
be_truthy
}
it
{
expect
(
project
.
private?
).
to
be_truthy
}
it
{
expect
(
project
.
forks
.
first
.
private?
).
to
be_truthy
}
end
context
'should not update forks visibility level when parent set to less restrictive'
do
before
do
opts
.
merge!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
update_project
(
project
,
user
,
opts
).
inspect
end
it
{
expect
(
@created_internal
).
to
be_truthy
}
it
{
expect
(
@fork_created_internal
).
to
be_truthy
}
it
{
expect
(
project
.
public?
).
to
be_truthy
}
it
{
expect
(
project
.
forks
.
first
.
internal?
).
to
be_truthy
}
end
end
def
update_project
(
project
,
user
,
opts
)
Projects
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
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