Commit 9d95dfe6 authored by Kamil Trzciński's avatar Kamil Trzciński
Browse files

Merge branch 'fix-projects-api-empty-list' into 'master'

Fix project API listing returning empty list when first projects are not added to CI

The CI prefers to receive the projects added to CI first

/cc @vsizov 

See merge request !225
parents 0ac87af6 1779c1d4
......@@ -7,6 +7,7 @@ v7.14.0 (unreleased)
- Use avatars received from GitLab
- Refactor GitLab API usage to use either access_token or private_token depending on what was specified during login
- Allow to use access_token for API requests
- Fix project API listing returning empty list when first projects are not added to CI
- Added support for CI skipped status
......
......@@ -34,7 +34,7 @@ module API
# GET /projects
get do
gitlab_projects = Project.from_gitlab(
current_user, :authorized, { page: params[:page], per_page: params[:per_page] }
current_user, :authorized, { page: params[:page], per_page: params[:per_page], ci_enabled_first: true }
)
ids = gitlab_projects.map { |project| project.id }
......@@ -48,7 +48,7 @@ module API
# GET /projects/owned
get "owned" do
gitlab_projects = Project.from_gitlab(
current_user, :owned, { page: params[:page], per_page: params[:per_page] }
current_user, :owned, { page: params[:page], per_page: params[:per_page], ci_enabled_first: true }
)
ids = gitlab_projects.map { |project| project.id }
......
......@@ -53,13 +53,13 @@ module StubGitlabCalls
def stub_projects
f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json'))
stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&private_token=Wvjy2Krpb7y8xi93owUz").
stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz").
with(:headers => {'Content-Type'=>'application/json'}).
to_return(:status => 200, :body => f, :headers => {'Content-Type'=>'application/json'})
end
def stub_projects_owned
stub_request(:get, "#{gitlab_url}api/v3/projects/owned.json?archived=false&private_token=Wvjy2Krpb7y8xi93owUz").
stub_request(:get, "#{gitlab_url}api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz").
with(:headers => {'Content-Type'=>'application/json'}).
to_return(:status => 200, :body => "", :headers => {})
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment