Add some more tests for notification policies (#29698)

pull/29692/head
Claire 2024-03-21 17:46:38 +01:00 committed by GitHub
parent a59f5694fe
commit 814a48517f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 10 deletions

View File

@ -22,10 +22,20 @@ RSpec.describe 'Policies' do
it_behaves_like 'forbidden for wrong scope', 'write write:notifications'
context 'with no options' do
it 'returns http success', :aggregate_failures do
it 'returns json with expected attributes', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(body_as_json).to include(
filter_not_following: false,
filter_not_followers: false,
filter_new_accounts: false,
filter_private_mentions: true,
summary: a_hash_including(
pending_requests_count: '1',
pending_notifications_count: '0'
)
)
end
end
end
@ -35,14 +45,25 @@ RSpec.describe 'Policies' do
put '/api/v1/notifications/policy', headers: headers, params: params
end
let(:params) { {} }
let(:params) { { filter_not_following: true } }
it_behaves_like 'forbidden for wrong scope', 'read read:notifications'
it 'returns http success' do
subject
it 'changes notification policy and returns an updated json object', :aggregate_failures do
expect { subject }
.to change { NotificationPolicy.find_or_initialize_by(account: user.account).filter_not_following }.from(false).to(true)
expect(response).to have_http_status(200)
expect(body_as_json).to include(
filter_not_following: true,
filter_not_followers: false,
filter_new_accounts: false,
filter_private_mentions: true,
summary: a_hash_including(
pending_requests_count: '0',
pending_notifications_count: '0'
)
)
end
end
end

View File

@ -82,15 +82,10 @@ RSpec.describe 'Requests' do
it_behaves_like 'forbidden for wrong scope', 'read read:notifications'
it 'returns http success' do
it 'returns http success and dismisses the notification request', :aggregate_failures do
subject
expect(response).to have_http_status(200)
end
it 'dismisses the notification request' do
subject
expect(notification_request.reload.dismissed?).to be true
end