Add include_pagination_headers
matcher to check Link
header in api specs (#29596)
This commit is contained in:
parent
6865fda593
commit
2e91a9bd34
10 changed files with 67 additions and 46 deletions
|
@ -55,10 +55,11 @@ describe 'Home', :sidekiq_inline do
|
|||
it 'sets the correct pagination headers', :aggregate_failures do
|
||||
subject
|
||||
|
||||
headers = response.headers['Link']
|
||||
|
||||
expect(headers.find_link(%w(rel prev)).href).to eq(api_v1_timelines_home_url(limit: 1, min_id: ana.statuses.first.id.to_s))
|
||||
expect(headers.find_link(%w(rel next)).href).to eq(api_v1_timelines_home_url(limit: 1, max_id: ana.statuses.first.id.to_s))
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v1_timelines_home_url(limit: params[:limit], min_id: ana.statuses.first.id),
|
||||
next: api_v1_timelines_home_url(limit: params[:limit], max_id: ana.statuses.first.id)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -83,10 +83,11 @@ describe 'Public' do
|
|||
it 'sets the correct pagination headers', :aggregate_failures do
|
||||
subject
|
||||
|
||||
headers = response.headers['Link']
|
||||
|
||||
expect(headers.find_link(%w(rel prev)).href).to eq(api_v1_timelines_public_url(limit: 1, min_id: media_status.id.to_s))
|
||||
expect(headers.find_link(%w(rel next)).href).to eq(api_v1_timelines_public_url(limit: 1, max_id: media_status.id.to_s))
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v1_timelines_public_url(limit: params[:limit], min_id: media_status.id),
|
||||
next: api_v1_timelines_public_url(limit: params[:limit], max_id: media_status.id)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -71,10 +71,11 @@ RSpec.describe 'Tag' do
|
|||
it 'sets the correct pagination headers', :aggregate_failures do
|
||||
subject
|
||||
|
||||
headers = response.headers['Link']
|
||||
|
||||
expect(headers.find_link(%w(rel prev)).href).to eq(api_v1_timelines_tag_url(limit: 1, min_id: love_status.id.to_s))
|
||||
expect(headers.find_link(%w(rel next)).href).to eq(api_v1_timelines_tag_url(limit: 1, max_id: love_status.id.to_s))
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v1_timelines_tag_url(limit: params[:limit], min_id: love_status.id),
|
||||
next: api_v1_timelines_tag_url(limit: params[:limit], max_id: love_status.id)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue