From f91acba70ac455b1240616e61968a36f99176ce7 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 30 Jan 2024 10:32:20 -0500 Subject: [PATCH] Combine repeated requests in account controller concern spec (#28957) --- .../account_controller_concern_spec.rb | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/spec/controllers/concerns/account_controller_concern_spec.rb b/spec/controllers/concerns/account_controller_concern_spec.rb index e3295204a..6eb970ded 100644 --- a/spec/controllers/concerns/account_controller_concern_spec.rb +++ b/spec/controllers/concerns/account_controller_concern_spec.rb @@ -49,22 +49,21 @@ describe AccountControllerConcern do end context 'when account is not suspended' do - it 'assigns @account' do - account = Fabricate(:account) + let(:account) { Fabricate(:account, username: 'username') } + + it 'assigns @account, returns success, and sets link headers' do get 'success', params: { account_username: account.username } + expect(assigns(:account)).to eq account - end - - it 'sets link headers' do - Fabricate(:account, username: 'username') - get 'success', params: { account_username: 'username' } - expect(response.headers['Link'].to_s).to eq '; rel="lrdd"; type="application/jrd+json", ; rel="alternate"; type="application/activity+json"' - end - - it 'returns http success' do - account = Fabricate(:account) - get 'success', params: { account_username: account.username } expect(response).to have_http_status(200) + expect(response.headers['Link'].to_s).to eq(expected_link_headers) + end + + def expected_link_headers + [ + '; rel="lrdd"; type="application/jrd+json"', + '; rel="alternate"; type="application/activity+json"', + ].join(', ') end end end