Merge remote-tracking branch 'parent/main' into upstream-20240326
This commit is contained in:
commit
6c9b221cb2
263 changed files with 4628 additions and 1518 deletions
|
@ -7,13 +7,35 @@ describe 'Featured Tags Suggestions API' do
|
|||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:accounts' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:account) { Fabricate(:account, user: user) }
|
||||
|
||||
describe 'GET /api/v1/featured_tags/suggestions' do
|
||||
it 'returns http success' do
|
||||
get '/api/v1/featured_tags/suggestions', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||
let!(:unused_featured_tag) { Fabricate(:tag, name: 'unused_featured_tag') }
|
||||
let!(:used_tag) { Fabricate(:tag, name: 'used_tag') }
|
||||
let!(:used_featured_tag) { Fabricate(:tag, name: 'used_featured_tag') }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
before do
|
||||
_unused_tag = Fabricate(:tag, name: 'unused_tag')
|
||||
|
||||
# Make relevant tags used by account
|
||||
status = Fabricate(:status, account: account)
|
||||
status.tags << used_tag
|
||||
status.tags << used_featured_tag
|
||||
|
||||
# Feature the relevant tags
|
||||
Fabricate :featured_tag, account: account, name: unused_featured_tag.name
|
||||
Fabricate :featured_tag, account: account, name: used_featured_tag.name
|
||||
end
|
||||
|
||||
it 'returns http success and recently used but not featured tags' do
|
||||
get '/api/v1/featured_tags/suggestions', params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(body_as_json)
|
||||
.to contain_exactly(
|
||||
include(name: used_tag.name)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue