Commit edee2dae authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'bw-jira-service-per-page' into 'master'

Allow passing per_page to Jira ListService

See merge request gitlab-org/gitlab!36253
parents 238db87a 0fdae852
......@@ -13,15 +13,16 @@ module Jira
@jql = params[:jql].to_s
@page = params[:page].to_i || 1
@per_page = params[:per_page].to_i || PER_PAGE
end
private
attr_reader :jql, :page
attr_reader :jql, :page, :per_page
override :url
def url
"#{base_api_url}/search?jql=#{CGI.escape(jql)}&startAt=#{start_at}&maxResults=#{PER_PAGE}&fields=*all"
"#{base_api_url}/search?jql=#{CGI.escape(jql)}&startAt=#{start_at}&maxResults=#{per_page}&fields=*all"
end
override :build_service_response
......@@ -48,7 +49,7 @@ module Jira
end
def start_at
(page - 1) * PER_PAGE
(page - 1) * per_page
end
end
end
......
......@@ -55,7 +55,7 @@ RSpec.describe Jira::Requests::Issues::ListService do
expect(client).to receive(:get).and_return([])
end
it 'returns a paylod with no issues' do
it 'returns a payload with no issues' do
payload = subject.payload
expect(subject.success?).to be_truthy
......@@ -75,7 +75,7 @@ RSpec.describe Jira::Requests::Issues::ListService do
)
end
it 'returns a paylod with jira issues' do
it 'returns a payload with jira issues' do
payload = subject.payload
expect(subject.success?).to be_truthy
......@@ -83,6 +83,16 @@ RSpec.describe Jira::Requests::Issues::ListService do
expect(payload[:is_last]).to be_falsy
end
end
context 'when using pagination parameters' do
let(:params) { { page: 3, per_page: 20 } }
it 'honors page and per_page' do
expect(client).to receive(:get).with(include('startAt=40&maxResults=20')).and_return([])
subject
end
end
end
end
end
......
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