From 6675bf574adf6fc898dde84fccdbd7abe17c3072 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 29 Feb 2024 08:47:38 -0500 Subject: [PATCH] Extract `parsed_uri_query_values` helper in ap/replies controller spec (#29410) --- .../activitypub/replies_controller_spec.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spec/controllers/activitypub/replies_controller_spec.rb b/spec/controllers/activitypub/replies_controller_spec.rb index 6b5a69d42..db7f60d3f 100644 --- a/spec/controllers/activitypub/replies_controller_spec.rb +++ b/spec/controllers/activitypub/replies_controller_spec.rb @@ -90,7 +90,7 @@ RSpec.describe ActivityPub::RepliesController do context 'when there are few self-replies' do it 'points next to replies from other people' do expect(page_json).to be_a Hash - expect(Addressable::URI.parse(page_json[:next]).query.split('&')).to include('only_other_accounts=true', 'page=true') + expect(parsed_uri_query_values(page_json[:next])).to include('only_other_accounts=true', 'page=true') end end @@ -101,7 +101,7 @@ RSpec.describe ActivityPub::RepliesController do it 'points next to other self-replies' do expect(page_json).to be_a Hash - expect(Addressable::URI.parse(page_json[:next]).query.split('&')).to include('only_other_accounts=false', 'page=true') + expect(parsed_uri_query_values(page_json[:next])).to include('only_other_accounts=false', 'page=true') end end end @@ -140,7 +140,7 @@ RSpec.describe ActivityPub::RepliesController do it 'points next to other replies' do expect(page_json).to be_a Hash - expect(Addressable::URI.parse(page_json[:next]).query.split('&')).to include('only_other_accounts=true', 'page=true') + expect(parsed_uri_query_values(page_json[:next])).to include('only_other_accounts=true', 'page=true') end end end @@ -196,6 +196,13 @@ RSpec.describe ActivityPub::RepliesController do private + def parsed_uri_query_values(uri) + Addressable::URI + .parse(uri) + .query + .split('&') + end + def ap_public_collection ActivityPub::TagManager::COLLECTIONS[:public] end