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
7c3ca863
Commit
7c3ca863
authored
May 14, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add order option for projects API
parent
5619c7b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
lib/api/projects.rb
lib/api/projects.rb
+6
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+9
-0
No files found.
lib/api/projects.rb
View file @
7c3ca863
...
...
@@ -22,7 +22,12 @@ module API
projects
=
projects
.
search
(
params
[
:search
])
end
projects
.
reorder
(
project_order_by
=>
project_sort
)
if
params
[
:ci_enabled_first
].
present?
projects
.
includes
(
:gitlab_ci_service
).
reorder
(
"services.active DESC, projects.
#{
project_order_by
}
#{
project_sort
}
"
)
else
projects
.
reorder
(
project_order_by
=>
project_sort
)
end
end
def
project_order_by
...
...
spec/requests/api/projects_spec.rb
View file @
7c3ca863
...
...
@@ -86,6 +86,15 @@ describe API::API, api: true do
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
project3
.
id
)
end
it
'returns projects in the correct order when ci_enabled_first parameter is passed'
do
[
project
,
project2
,
project3
].
each
{
|
project
|
project
.
build_missing_services
}
project2
.
gitlab_ci_service
.
update
(
active:
true
,
token:
"token"
,
project_url:
"url"
)
get
api
(
'/projects'
,
user
),
{
ci_enabled_first:
'true'
}
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
project2
.
id
)
end
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