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
96862096
Commit
96862096
authored
Jan 22, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test to can_change_visibility_level? method
parent
003f140c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
spec/helpers/projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+14
-4
No files found.
spec/helpers/projects_helper_spec.rb
View file @
96862096
require
'spec_helper'
describe
ProjectsHelper
do
include
ProjectForksHelper
describe
"#project_status_css_class"
do
it
"returns appropriate class"
do
expect
(
project_status_css_class
(
"started"
)).
to
eq
(
"active"
)
...
...
@@ -10,9 +12,9 @@ describe ProjectsHelper do
end
describe
"can_change_visibility_level?"
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:project_member
,
:reporter
,
user:
create
(
:user
),
project:
project
).
user
}
let
(
:fork
_project
)
{
Projects
::
ForkService
.
new
(
project
,
user
).
execute
}
let
(
:fork
ed_project
)
{
fork_project
(
project
,
user
)
}
it
"returns false if there are no appropriate permissions"
do
allow
(
helper
).
to
receive
(
:can?
)
{
false
}
...
...
@@ -26,13 +28,21 @@ describe ProjectsHelper do
expect
(
helper
.
can_change_visibility_level?
(
project
,
user
)).
to
be_truthy
end
it
'allows visibility level to be changed if the project is forked'
do
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:change_visibility_level
,
project
)
{
true
}
project
.
update!
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
fork_project
(
project
)
expect
(
helper
.
can_change_visibility_level?
(
project
,
user
)).
to
be_truthy
end
context
"forks"
do
it
"returns false if there are permissions and origin project is PRIVATE"
do
allow
(
helper
).
to
receive
(
:can?
)
{
true
}
project
.
update
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
expect
(
helper
.
can_change_visibility_level?
(
fork_project
,
user
)).
to
be_falsey
expect
(
helper
.
can_change_visibility_level?
(
fork
ed
_project
,
user
)).
to
be_falsey
end
it
"returns true if there are permissions and origin project is INTERNAL"
do
...
...
@@ -40,7 +50,7 @@ describe ProjectsHelper do
project
.
update
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
expect
(
helper
.
can_change_visibility_level?
(
fork_project
,
user
)).
to
be_truthy
expect
(
helper
.
can_change_visibility_level?
(
fork
ed
_project
,
user
)).
to
be_truthy
end
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