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
Tatuya Kamada
gitlab-ce
Commits
acd8930c
Commit
acd8930c
authored
May 11, 2016
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidy up user project specs
parent
97424ea5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
14 deletions
+9
-14
app/models/user.rb
app/models/user.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+8
-13
No files found.
app/models/user.rb
View file @
acd8930c
...
...
@@ -383,7 +383,7 @@ class User < ActiveRecord::Base
def
viewable_starred_projects
starred_projects
.
where
(
"projects.visibility_level IN (?) OR projects.id IN (
#{
projects_union
.
to_sql
}
)"
,
[
Gitlab
::
VisibilityLevel
::
PUBLIC
,
Gitlab
::
VisibilityLevel
::
INTERNAL
])
[
Project
::
PUBLIC
,
Project
::
INTERNAL
])
end
def
owned_projects
...
...
spec/models/user_spec.rb
View file @
acd8930c
...
...
@@ -233,8 +233,6 @@ describe User, models: true do
@project
=
create
:project
,
namespace:
@user
.
namespace
@project_2
=
create
:project
,
group:
create
(
:group
)
# Grant MASTER access to the user
@project_3
=
create
:project
,
group:
create
(
:group
)
# Grant DEVELOPER access to the user
@project_4
=
create
:project
,
group:
create
(
:group
)
@project_5
=
create
:project
,
group:
create
(
:group
)
@project_2
.
team
<<
[
@user
,
:master
]
@project_3
.
team
<<
[
@user
,
:developer
]
...
...
@@ -787,23 +785,20 @@ describe User, models: true do
describe
'#viewable_starred_projects'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:public_project
)
{
create
(
:project
,
:public
)
}
let
(
:private_project
)
{
create
(
:project
,
:private
)
}
let
(
:private_viewable_project
)
{
create
(
:project
,
:private
)
}
let
(
:viewable?
)
{
->
(
project
)
{
user
.
can?
(
:read_project
,
project
)
}
}
let
(
:projects
)
{
[
public_project
,
private_project
,
private_viewable_project
]
}
let
(
:public_project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:private_project
)
{
create
(
:empty_project
,
:private
)
}
let
(
:private_viewable_project
)
{
create
(
:empty_project
,
:private
)
}
before
do
private_viewable_project
.
team
<<
[
user
,
Gitlab
::
Access
::
MASTER
]
projects
.
each
{
|
project
|
user
.
toggle_star
(
project
)
}
end
it
'returns only starred projects the user can view'
do
expect
(
user
.
viewable_starred_projects
).
to
all
(
satisfy
(
&
viewable?
))
[
public_project
,
private_project
,
private_viewable_project
].
each
do
|
project
|
user
.
toggle_star
(
project
)
end
end
it
're
jects only starred projects the user can not
view'
do
expect
(
projects
-
user
.
viewable_starred_projects
).
not_to
include
(
satisfy
(
&
viewable?
)
)
it
're
turns only starred projects the user can
view'
do
expect
(
user
.
viewable_starred_projects
).
not_to
include
(
private_project
)
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