Commit 61caaa8d authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Define pagination params

parent 04094afc
......@@ -16,7 +16,7 @@ module API
class BranchCommit < Grape::Entity
expose :id, as: :sha
expose :type do |model|
expose :type do |_|
'commit'
end
end
......@@ -36,7 +36,6 @@ module API
}
end
expose :commit do |commit|
# TODO: export to entity
{
author: {
name: commit.author_name,
......@@ -54,7 +53,6 @@ module API
}
end
expose :parents do |commit|
# TODO: export to entity
commit.parent_ids.map { |id| { sha: id } }
end
expose :files do |commit|
......
module API
module V3
class Github < Grape::API
include PaginationParams
before do
authenticate!
authorize_jira_user_agent!(request)
authenticate!
end
helpers do
......@@ -36,6 +38,9 @@ module API
end
resource :users do
params do
use :pagination
end
get ':namespace/repos' do
projects = current_user.authorized_projects.select { |project| project.feature_available?(:jira_dev_panel_integration) }
projects = ::Kaminari.paginate_array(projects)
......@@ -50,6 +55,7 @@ module API
params do
use :project_full_path
use :pagination
end
get ':namespace/:project/branches' do
namespace = params[:namespace]
......
......@@ -50,6 +50,7 @@ describe API::V3::Github do
get v3_api('/users/foo/repos', user)
expect(response).to have_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an(Array)
expect(json_response.size).to eq(2)
......@@ -81,6 +82,7 @@ describe API::V3::Github do
get v3_api('/users/foo/repos', user)
expect(response).to have_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.size).to eq(1)
expect(json_response.first['id']).to eq(licensed_project.id)
end
......@@ -94,6 +96,7 @@ describe API::V3::Github do
get v3_api("/repos/#{project.namespace.path}/#{project.path}/branches", user)
expect(response).to have_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an(Array)
expect(json_response.first.keys).to contain_exactly('name', 'commit')
expect(json_response.first['commit'].keys).to contain_exactly('sha', 'type')
......
Markdown is supported
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