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
ae6080c7
Commit
ae6080c7
authored
Jan 19, 2016
by
Josh Frye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs. Adjust filter.
parent
11797df1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
app/models/project.rb
app/models/project.rb
+1
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+23
-0
No files found.
app/models/project.rb
View file @
ae6080c7
...
...
@@ -273,7 +273,7 @@ class Project < ActiveRecord::Base
end
def
search_by_visibility
(
level
)
where
(
visibility_level:
visibility_levels
[
level
.
capitalize
]
)
where
(
visibility_level:
Gitlab
::
VisibilityLevel
.
const_get
(
level
.
upcase
)
)
end
def
search_by_title
(
query
)
...
...
spec/requests/api/projects_spec.rb
View file @
ae6080c7
...
...
@@ -90,6 +90,29 @@ describe API::API, api: true do
end
end
context
'and using the visibility filter'
do
it
'should filter based on private visibility param'
do
get
api
(
'/projects'
,
user
),
{
visibility:
'private'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
user
.
namespace
.
projects
.
where
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
).
count
)
end
it
'should filter based on internal visibility param'
do
get
api
(
'/projects'
,
user
),
{
visibility:
'internal'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
user
.
namespace
.
projects
.
where
(
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
).
count
)
end
it
'should filter based on public visibility param'
do
get
api
(
'/projects'
,
user
),
{
visibility:
'public'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
user
.
namespace
.
projects
.
where
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
).
count
)
end
end
context
'and using sorting'
do
before
do
project2
...
...
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