mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Replace body_json_types
wrapper with direction inspection in request specs
This commit is contained in:
parent
884bbf7ae2
commit
e06d3a4b52
@ -123,9 +123,15 @@ RSpec.describe 'Notifications' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 5
|
||||
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
|
||||
expect(response.parsed_body.any? { |x| x[:filtered] }).to be false
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(type: 'reblog'),
|
||||
hash_including(type: 'mention'),
|
||||
hash_including(type: 'favourite'),
|
||||
hash_including(type: 'favourite'),
|
||||
hash_including(type: 'follow')
|
||||
)
|
||||
.and not_include(hash_including(filtered: true))
|
||||
end
|
||||
end
|
||||
|
||||
@ -138,9 +144,15 @@ RSpec.describe 'Notifications' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 6
|
||||
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
|
||||
expect(response.parsed_body.any? { |x| x[:filtered] }).to be true
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(type: 'reblog'),
|
||||
hash_including(type: 'mention'),
|
||||
hash_including(type: 'mention', filtered: true),
|
||||
hash_including(type: 'favourite'),
|
||||
hash_including(type: 'favourite'),
|
||||
hash_including(type: 'follow')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@ -183,8 +195,11 @@ RSpec.describe 'Notifications' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to_not eq 0
|
||||
expect(body_json_types.uniq).to_not include 'mention'
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
.and not_include(
|
||||
hash_including(type: 'mention')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@ -197,7 +212,8 @@ RSpec.describe 'Notifications' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(body_json_types.uniq).to eq ['mention']
|
||||
expect(response.parsed_body)
|
||||
.to all(match hash_including(type: 'mention'))
|
||||
end
|
||||
end
|
||||
|
||||
@ -219,10 +235,6 @@ RSpec.describe 'Notifications' do
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def body_json_types
|
||||
response.parsed_body.pluck(:type)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /api/v1/notifications/:id' do
|
||||
|
@ -150,7 +150,15 @@ RSpec.describe 'Notifications' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
notification_groups: contain_exactly(
|
||||
hash_including(type: 'reblog'),
|
||||
hash_including(type: 'mention'),
|
||||
hash_including(type: 'favourite'),
|
||||
hash_including(type: 'follow')
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@ -197,8 +205,9 @@ RSpec.describe 'Notifications' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to_not eq 0
|
||||
expect(body_json_types.uniq).to_not include 'mention'
|
||||
expect(response.parsed_body)
|
||||
.to be_present
|
||||
.and not_include(hash_including(type: 'mention'))
|
||||
end
|
||||
end
|
||||
|
||||
@ -211,8 +220,11 @@ RSpec.describe 'Notifications' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(body_json_types.uniq).to eq ['mention']
|
||||
expect(response.parsed_body.dig(:notification_groups, 0, :page_min_id)).to_not be_nil
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
notification_groups: all(match hash_including(type: 'mention'))
|
||||
.and(have_attributes(first: include(page_min_id: be_present)))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@ -293,10 +305,6 @@ RSpec.describe 'Notifications' do
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
def body_json_types
|
||||
response.parsed_body[:notification_groups].pluck(:type)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /api/v2/notifications/:id' do
|
||||
|
Loading…
Reference in New Issue
Block a user