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
5243de82
Commit
5243de82
authored
Oct 07, 2019
by
Aleksei Lipniagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests
parent
ac53b960
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletion
+55
-1
app/models/project.rb
app/models/project.rb
+0
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+55
-0
No files found.
app/models/project.rb
View file @
5243de82
...
@@ -2258,7 +2258,6 @@ class Project < ApplicationRecord
...
@@ -2258,7 +2258,6 @@ class Project < ApplicationRecord
setting
setting
end
end
# TODO: unit test this method
def
correct_visibility_level
def
correct_visibility_level
if
group
&&
group
.
visibility_level
<
visibility_level
if
group
&&
group
.
visibility_level
<
visibility_level
self
.
visibility_level
=
group
.
visibility_level
self
.
visibility_level
=
group
.
visibility_level
...
...
spec/models/project_spec.rb
View file @
5243de82
...
@@ -5179,6 +5179,61 @@ describe Project do
...
@@ -5179,6 +5179,61 @@ describe Project do
end
end
end
end
describe
'#correct_visibility_level'
do
context
'when has a group'
do
let
(
:group
)
{
create
(
:group
,
visibility_level:
group_visibility_level
)
}
let
(
:project
)
{
build
(
:project
,
namespace:
group
,
visibility_level:
project_visibility_level
)
}
context
'when the group `visibility_level` is more strict'
do
let
(
:group_visibility_level
)
{
Gitlab
::
VisibilityLevel
::
PRIVATE
}
let
(
:project_visibility_level
)
{
Gitlab
::
VisibilityLevel
::
INTERNAL
}
it
'sets `visibility_level` value from the group'
do
expect
{
project
.
correct_visibility_level
}
.
to
change
{
project
.
visibility_level
}
.
to
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
end
context
'when the group `visibility_level` is less strict'
do
let
(
:group_visibility_level
)
{
Gitlab
::
VisibilityLevel
::
INTERNAL
}
let
(
:project_visibility_level
)
{
Gitlab
::
VisibilityLevel
::
PRIVATE
}
it
'does not change the value of the `visibility_level` field'
do
expect
{
project
.
correct_visibility_level
}
.
not_to
change
{
project
.
visibility_level
}
end
end
end
context
'when `restricted_visibility_levels` of the GitLab instance exist'
do
before
do
stub_application_setting
(
restricted_visibility_levels:
[
Gitlab
::
VisibilityLevel
::
INTERNAL
])
end
let
(
:project
)
{
build
(
:project
,
visibility_level:
project_visibility_level
)
}
context
'when `visibility_level` is included into `restricted_visibility_levels`'
do
let
(
:project_visibility_level
)
{
Gitlab
::
VisibilityLevel
::
INTERNAL
}
it
'sets `visibility_level` value to `PRIVATE`'
do
expect
{
project
.
correct_visibility_level
}
.
to
change
{
project
.
visibility_level
}
.
to
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
end
context
'when `restricted_visibility_levels` does not include `visibility_level`'
do
let
(
:project_visibility_level
)
{
Gitlab
::
VisibilityLevel
::
PUBLIC
}
it
'does not change the value of the `visibility_level` field'
do
expect
{
project
.
correct_visibility_level
}
.
to
not_change
{
project
.
visibility_level
}
end
end
end
end
def
rugged_config
def
rugged_config
rugged_repo
(
project
.
repository
).
config
rugged_repo
(
project
.
repository
).
config
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