Use body_as_json
directly instead of via local var assignment (#31696)
This commit is contained in:
parent
e5155c50fd
commit
24a0b20408
15 changed files with 123 additions and 113 deletions
|
@ -42,9 +42,11 @@ RSpec.describe 'API V2 Filters Keywords' do
|
|||
it 'creates a filter', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
json = body_as_json
|
||||
expect(json[:keyword]).to eq 'magic'
|
||||
expect(json[:whole_word]).to be false
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
keyword: 'magic',
|
||||
whole_word: false
|
||||
)
|
||||
|
||||
filter = user.account.custom_filters.first
|
||||
expect(filter).to_not be_nil
|
||||
|
@ -71,9 +73,11 @@ RSpec.describe 'API V2 Filters Keywords' do
|
|||
it 'responds with the keyword', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
json = body_as_json
|
||||
expect(json[:keyword]).to eq 'foo'
|
||||
expect(json[:whole_word]).to be false
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
keyword: 'foo',
|
||||
whole_word: false
|
||||
)
|
||||
end
|
||||
|
||||
context "when trying to access another user's filter keyword" do
|
||||
|
|
|
@ -43,8 +43,10 @@ RSpec.describe 'API V2 Filters Statuses' do
|
|||
it 'creates a filter', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
json = body_as_json
|
||||
expect(json[:status_id]).to eq status.id.to_s
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
status_id: status.id.to_s
|
||||
)
|
||||
|
||||
filter = user.account.custom_filters.first
|
||||
expect(filter).to_not be_nil
|
||||
|
@ -71,8 +73,10 @@ RSpec.describe 'API V2 Filters Statuses' do
|
|||
it 'responds with the filter', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
json = body_as_json
|
||||
expect(json[:status_id]).to eq status_filter.status_id.to_s
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
status_id: status_filter.status.id.to_s
|
||||
)
|
||||
end
|
||||
|
||||
context "when trying to access another user's filter keyword" do
|
||||
|
|
|
@ -58,12 +58,15 @@ RSpec.describe 'Filters' do
|
|||
it 'returns a filter with keywords', :aggregate_failures do
|
||||
subject
|
||||
|
||||
json = body_as_json
|
||||
|
||||
expect(json[:title]).to eq 'magic'
|
||||
expect(json[:filter_action]).to eq 'hide'
|
||||
expect(json[:context]).to eq ['home']
|
||||
expect(json[:keywords].map { |keyword| keyword.slice(:keyword, :whole_word) }).to match [{ keyword: 'magic', whole_word: true }]
|
||||
expect(body_as_json)
|
||||
.to include(
|
||||
title: 'magic',
|
||||
filter_action: 'hide',
|
||||
context: %w(home),
|
||||
keywords: contain_exactly(
|
||||
include(keyword: 'magic', whole_word: true)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates a filter', :aggregate_failures do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue