diff --git a/spec/controllers/api/v1/circles/statuses_controller_spec.rb b/spec/controllers/api/v1/circles/statuses_controller_spec.rb index 5921f468bf..03f7b7faf3 100644 --- a/spec/controllers/api/v1/circles/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/circles/statuses_controller_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Api::V1::Circles::StatusesController do get :show, params: { circle_id: circle.id, limit: 5 } expect(response).to have_http_status(200) - json = body_as_json + json = response.parsed_body expect(json.map { |item| item[:id].to_i }).to eq [status.id] end diff --git a/spec/controllers/api/v1/lists_controller_spec.rb b/spec/controllers/api/v1/lists_controller_spec.rb index 62cf53a09f..66e546e8fd 100644 --- a/spec/controllers/api/v1/lists_controller_spec.rb +++ b/spec/controllers/api/v1/lists_controller_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Api::V1::ListsController do get :index expect(response).to have_http_status(200) - list_ids = body_as_json.pluck(:id) + list_ids = response.parsed_body.pluck(:id) expect(list_ids.size).to eq 1 expect(list_ids).to include list_id end diff --git a/spec/requests/api/v1/accounts_spec.rb b/spec/requests/api/v1/accounts_spec.rb index 1870a885ca..53467d1466 100644 --- a/spec/requests/api/v1/accounts_spec.rb +++ b/spec/requests/api/v1/accounts_spec.rb @@ -168,7 +168,7 @@ RSpec.describe '/api/v1/accounts' do it 'returns JSON with following=false and requested=true' do subject - json = body_as_json + json = response.parsed_body expect(json[:following]).to be false expect(json[:requested]).to be true diff --git a/spec/requests/api/v1/circles/accounts_spec.rb b/spec/requests/api/v1/circles/accounts_spec.rb index 162c4f111c..f8ab24e95d 100644 --- a/spec/requests/api/v1/circles/accounts_spec.rb +++ b/spec/requests/api/v1/circles/accounts_spec.rb @@ -34,7 +34,7 @@ RSpec.describe 'Accounts' do subject expect(response).to have_http_status(200) - expect(body_as_json).to match_array(expected_response) + expect(response.parsed_body).to match_array(expected_response) end context 'with limit param' do @@ -43,7 +43,7 @@ RSpec.describe 'Accounts' do it 'returns only the requested number of accounts' do subject - expect(body_as_json.size).to eq(params[:limit]) + expect(response.parsed_body.size).to eq(params[:limit]) end end end diff --git a/spec/requests/api/v1/instances/domain_blocks_spec.rb b/spec/requests/api/v1/instances/domain_blocks_spec.rb index 48435cece7..883fc17e90 100644 --- a/spec/requests/api/v1/instances/domain_blocks_spec.rb +++ b/spec/requests/api/v1/instances/domain_blocks_spec.rb @@ -34,7 +34,7 @@ RSpec.describe 'Domain Blocks' do it 'returns http success and dont include hidden record' do get api_v1_instance_domain_blocks_path - expect(body_as_json.pluck(:domain)).to_not include('hello.com') + expect(response.parsed_body.pluck(:domain)).to_not include('hello.com') end end end @@ -59,7 +59,7 @@ RSpec.describe 'Domain Blocks' do expect(response) .to have_http_status(200) - expect(body_as_json) + expect(response.parsed_body) .to be_present .and(be_an(Array)) .and(have_attributes(size: 1)) @@ -71,7 +71,7 @@ RSpec.describe 'Domain Blocks' do it 'returns http success and dont include hidden record' do get api_v1_instance_domain_blocks_path, headers: headers - expect(body_as_json.pluck(:domain)).to_not include('hello.com') + expect(response.parsed_body.pluck(:domain)).to_not include('hello.com') end end end diff --git a/spec/requests/api/v1/statuses/emoji_reactions_spec.rb b/spec/requests/api/v1/statuses/emoji_reactions_spec.rb index e85404379d..f25a0146e2 100644 --- a/spec/requests/api/v1/statuses/emoji_reactions_spec.rb +++ b/spec/requests/api/v1/statuses/emoji_reactions_spec.rb @@ -29,7 +29,7 @@ RSpec.describe 'EmojiReactions' do it 'returns json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, emoji_reactions_count: 1) ) end @@ -133,7 +133,7 @@ RSpec.describe 'EmojiReactions' do it 'returns json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, emoji_reactions_count: 0) ) end @@ -155,7 +155,7 @@ RSpec.describe 'EmojiReactions' do it 'returns json with updated attributes' do subject - expect(body_as_json).to match( + expect(response.parsed_body).to match( a_hash_including(id: status.id.to_s, emoji_reactions_count: 0) ) end diff --git a/spec/requests/api/v1/statuses_spec.rb b/spec/requests/api/v1/statuses_spec.rb index fde8239247..3a3635c4a5 100644 --- a/spec/requests/api/v1/statuses_spec.rb +++ b/spec/requests/api/v1/statuses_spec.rb @@ -126,15 +126,15 @@ RSpec.describe '/api/v1/statuses' do it 'returns unique ancestors' do get "/api/v1/statuses/#{thread.id}/context" - status_ids = body_as_json[:ancestors].map { |ref| ref[:id].to_i } + status_ids = response.parsed_body[:ancestors].map { |ref| ref[:id].to_i } expect(status_ids).to eq [status.id] end it 'returns unique references' do get "/api/v1/statuses/#{thread.id}/context", params: { with_reference: true } - ancestor_status_ids = body_as_json[:ancestors].map { |ref| ref[:id].to_i } - reference_status_ids = body_as_json[:references].map { |ref| ref[:id].to_i } + ancestor_status_ids = response.parsed_body[:ancestors].map { |ref| ref[:id].to_i } + reference_status_ids = response.parsed_body[:references].map { |ref| ref[:id].to_i } expect(ancestor_status_ids).to eq [status.id] expect(reference_status_ids).to eq [] @@ -164,14 +164,14 @@ RSpec.describe '/api/v1/statuses' do it 'returns empty references' do get "/api/v1/statuses/#{status.id}/context", headers: headers - status_ids = body_as_json[:references].map { |ref| ref[:id].to_i } + status_ids = response.parsed_body[:references].map { |ref| ref[:id].to_i } expect(status_ids).to eq [] end it 'contains referred status' do get "/api/v1/statuses/#{status.id}/context", headers: headers - status_ids = body_as_json[:ancestors].map { |ref| ref[:id].to_i } + status_ids = response.parsed_body[:ancestors].map { |ref| ref[:id].to_i } expect(status_ids).to include referred.id expect(status_ids).to include referred_private_following.id @@ -179,14 +179,14 @@ RSpec.describe '/api/v1/statuses' do it 'does not contain private status' do get "/api/v1/statuses/#{status.id}/context", headers: headers - status_ids = body_as_json[:ancestors].map { |ref| ref[:id].to_i } + status_ids = response.parsed_body[:ancestors].map { |ref| ref[:id].to_i } expect(status_ids).to_not include referred_private.id end it 'does not contain private status when not autienticated' do get "/api/v1/statuses/#{status.id}/context" - status_ids = body_as_json[:ancestors].map { |ref| ref[:id].to_i } + status_ids = response.parsed_body[:ancestors].map { |ref| ref[:id].to_i } expect(status_ids).to_not include referred_private.id end @@ -199,14 +199,14 @@ RSpec.describe '/api/v1/statuses' do it 'returns empty ancestors' do get "/api/v1/statuses/#{status.id}/context", params: { with_reference: true }, headers: headers - status_ids = body_as_json[:ancestors].map { |ref| ref[:id].to_i } + status_ids = response.parsed_body[:ancestors].map { |ref| ref[:id].to_i } expect(status_ids).to eq [] end it 'contains referred status' do get "/api/v1/statuses/#{status.id}/context", params: { with_reference: true }, headers: headers - status_ids = body_as_json[:references].map { |ref| ref[:id].to_i } + status_ids = response.parsed_body[:references].map { |ref| ref[:id].to_i } expect(status_ids).to include referred.id end diff --git a/spec/requests/api/v1/timelines/public_spec.rb b/spec/requests/api/v1/timelines/public_spec.rb index 4bc83ec571..8e3c15f40f 100644 --- a/spec/requests/api/v1/timelines/public_spec.rb +++ b/spec/requests/api/v1/timelines/public_spec.rb @@ -156,7 +156,7 @@ RSpec.describe 'Public' do context 'when user is setting filters' do subject do get '/api/v1/timelines/public', headers: headers, params: params - body_as_json.filter { |status| status[:filtered].empty? || status[:filtered][0][:filter][:id] != filter.id.to_s }.map { |status| status[:id].to_i } + response.parsed_body.filter { |status| status[:filtered].empty? || status[:filtered][0][:filter][:id] != filter.id.to_s }.map { |status| status[:id].to_i } end before do