0
0
Fork 0

Combine API request spec assertions (#31970)

This commit is contained in:
Matt Jankowski 2024-09-19 06:15:21 -04:00 committed by GitHub
parent 1fce55cf5d
commit b071e618e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 36 additions and 232 deletions

View file

@ -18,15 +18,11 @@ RSpec.describe 'Bookmarks' do
it_behaves_like 'forbidden for wrong scope', 'read'
context 'with public status' do
it 'bookmarks the status successfully', :aggregate_failures do
it 'bookmarks the status successfully and includes updated json', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(user.account.bookmarked?(status)).to be true
end
it 'returns json with updated attributes' do
subject
expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, bookmarked: true)
@ -93,15 +89,11 @@ RSpec.describe 'Bookmarks' do
Bookmark.find_or_create_by!(account: user.account, status: status)
end
it 'unbookmarks the status successfully', :aggregate_failures do
it 'unbookmarks the status successfully and includes updated json', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(user.account.bookmarked?(status)).to be false
end
it 'returns json with updated attributes' do
subject
expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, bookmarked: false)
@ -117,15 +109,11 @@ RSpec.describe 'Bookmarks' do
status.account.block!(user.account)
end
it 'unbookmarks the status successfully', :aggregate_failures do
it 'unbookmarks the status successfully and includes updated json', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(user.account.bookmarked?(status)).to be false
end
it 'returns json with updated attributes' do
subject
expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, bookmarked: false)

View file

@ -18,15 +18,11 @@ RSpec.describe 'Favourites', :inline_jobs do
it_behaves_like 'forbidden for wrong scope', 'read read:favourites'
context 'with public status' do
it 'favourites the status successfully', :aggregate_failures do
it 'favourites the status successfully and includes updated json', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(user.account.favourited?(status)).to be true
end
it 'returns json with updated attributes' do
subject
expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, favourites_count: 1, favourited: true)
@ -84,16 +80,12 @@ RSpec.describe 'Favourites', :inline_jobs do
FavouriteService.new.call(user.account, status)
end
it 'unfavourites the status successfully', :aggregate_failures do
it 'unfavourites the status successfully and includes updated json', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(user.account.favourited?(status)).to be false
end
it 'returns json with updated attributes' do
subject
expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, favourites_count: 0, favourited: false)
@ -107,16 +99,12 @@ RSpec.describe 'Favourites', :inline_jobs do
status.account.block!(user.account)
end
it 'unfavourites the status successfully', :aggregate_failures do
it 'unfavourites the status successfully and includes updated json', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(user.account.favourited?(status)).to be false
end
it 'returns json with updated attributes' do
subject
expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, favourites_count: 0, favourited: false)

View file

@ -18,15 +18,11 @@ RSpec.describe 'Pins' do
it_behaves_like 'forbidden for wrong scope', 'read read:accounts'
context 'when the status is public' do
it 'pins the status successfully', :aggregate_failures do
it 'pins the status successfully and returns updated json', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(user.account.pinned?(status)).to be true
end
it 'return json with updated attributes' do
subject
expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, pinned: true)
@ -86,15 +82,11 @@ RSpec.describe 'Pins' do
Fabricate(:status_pin, status: status, account: user.account)
end
it 'unpins the status successfully', :aggregate_failures do
it 'unpins the status successfully and includes updated json', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(user.account.pinned?(status)).to be false
end
it 'return json with updated attributes' do
subject
expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, pinned: false)