From eb16763bff5cc2d38dec19c82d47615cd2b54e27 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 18 Sep 2024 04:22:07 -0400 Subject: [PATCH] Use `have_http_link_header` matcher in `api/v1/trends/*` specs (#31940) --- spec/requests/api/v1/trends/links_spec.rb | 9 ++++++--- spec/requests/api/v1/trends/statuses_spec.rb | 9 ++++++--- spec/requests/api/v1/trends/tags_spec.rb | 10 ++++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/spec/requests/api/v1/trends/links_spec.rb b/spec/requests/api/v1/trends/links_spec.rb index 012d035907..04d36da0a2 100644 --- a/spec/requests/api/v1/trends/links_spec.rb +++ b/spec/requests/api/v1/trends/links_spec.rb @@ -10,7 +10,9 @@ RSpec.describe 'API V1 Trends Links' do it 'returns http success' do get '/api/v1/trends/links' - expect(response).to have_http_status(200) + expect(response) + .to have_http_status(200) + .and not_have_http_link_header end end @@ -22,8 +24,9 @@ RSpec.describe 'API V1 Trends Links' do stub_const('Api::V1::Trends::LinksController::DEFAULT_LINKS_LIMIT', 2) get '/api/v1/trends/links' - expect(response).to have_http_status(200) - expect(response.headers).to include('Link') + expect(response) + .to have_http_status(200) + .and have_http_link_header(api_v1_trends_links_url(offset: 2)).for(rel: 'next') end def prepare_trends diff --git a/spec/requests/api/v1/trends/statuses_spec.rb b/spec/requests/api/v1/trends/statuses_spec.rb index 3b906e8f82..f04addfe0a 100644 --- a/spec/requests/api/v1/trends/statuses_spec.rb +++ b/spec/requests/api/v1/trends/statuses_spec.rb @@ -10,7 +10,9 @@ RSpec.describe 'API V1 Trends Statuses' do it 'returns http success' do get '/api/v1/trends/statuses' - expect(response).to have_http_status(200) + expect(response) + .to have_http_status(200) + .and not_have_http_link_header end end @@ -22,8 +24,9 @@ RSpec.describe 'API V1 Trends Statuses' do stub_const('Api::BaseController::DEFAULT_STATUSES_LIMIT', 2) get '/api/v1/trends/statuses' - expect(response).to have_http_status(200) - expect(response.headers).to include('Link') + expect(response) + .to have_http_status(200) + .and have_http_link_header(api_v1_trends_statuses_url(offset: 2)).for(rel: 'next') end def prepare_trends diff --git a/spec/requests/api/v1/trends/tags_spec.rb b/spec/requests/api/v1/trends/tags_spec.rb index 598f4e7752..2ff51eed63 100644 --- a/spec/requests/api/v1/trends/tags_spec.rb +++ b/spec/requests/api/v1/trends/tags_spec.rb @@ -10,8 +10,9 @@ RSpec.describe 'API V1 Trends Tags' do it 'returns http success' do get '/api/v1/trends/tags' - expect(response).to have_http_status(200) - expect(response.headers).to_not include('Link') + expect(response) + .to have_http_status(200) + .and not_have_http_link_header end end @@ -23,8 +24,9 @@ RSpec.describe 'API V1 Trends Tags' do stub_const('Api::V1::Trends::TagsController::DEFAULT_TAGS_LIMIT', 2) get '/api/v1/trends/tags' - expect(response).to have_http_status(200) - expect(response.headers).to include('Link') + expect(response) + .to have_http_status(200) + .and have_http_link_header(api_v1_trends_tags_url(offset: 2)).for(rel: 'next') end def prepare_trends