Merge remote-tracking branch 'parent/main' into upstream-20240716
This commit is contained in:
commit
adee1645a3
203 changed files with 1707 additions and 1067 deletions
|
@ -10,12 +10,15 @@ describe 'API V1 Accounts Statuses' do
|
|||
|
||||
describe 'GET /api/v1/accounts/:account_id/statuses' do
|
||||
it 'returns expected headers', :aggregate_failures do
|
||||
Fabricate(:status, account: user.account)
|
||||
status = Fabricate(:status, account: user.account)
|
||||
get "/api/v1/accounts/#{user.account.id}/statuses", params: { limit: 1 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(links_from_header.size)
|
||||
.to eq(2)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and include_pagination_headers(
|
||||
prev: api_v1_account_statuses_url(limit: 1, min_id: status.id),
|
||||
next: api_v1_account_statuses_url(limit: 1, max_id: status.id)
|
||||
)
|
||||
end
|
||||
|
||||
context 'with only media' do
|
||||
|
@ -55,16 +58,9 @@ describe 'API V1 Accounts Statuses' do
|
|||
it 'returns http success and includes a header link' do
|
||||
get "/api/v1/accounts/#{user.account.id}/statuses", params: { pinned: true }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(links_from_header.size)
|
||||
.to eq(1)
|
||||
expect(links_from_header)
|
||||
.to contain_exactly(
|
||||
have_attributes(
|
||||
href: /pinned=true/,
|
||||
attr_pairs: contain_exactly(['rel', 'prev'])
|
||||
)
|
||||
)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and include_pagination_headers(prev: api_v1_account_statuses_url(pinned: true, min_id: Status.first.id))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -77,19 +73,11 @@ describe 'API V1 Accounts Statuses' do
|
|||
it 'returns http success and header pagination links to prev and next' do
|
||||
get "/api/v1/accounts/#{user.account.id}/statuses", params: { pinned: true }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(links_from_header.size)
|
||||
.to eq(2)
|
||||
expect(links_from_header)
|
||||
.to contain_exactly(
|
||||
have_attributes(
|
||||
href: /pinned=true/,
|
||||
attr_pairs: contain_exactly(['rel', 'next'])
|
||||
),
|
||||
have_attributes(
|
||||
href: /pinned=true/,
|
||||
attr_pairs: contain_exactly(['rel', 'prev'])
|
||||
)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and include_pagination_headers(
|
||||
prev: api_v1_account_statuses_url(pinned: true, min_id: Status.first.id),
|
||||
next: api_v1_account_statuses_url(pinned: true, max_id: Status.first.id)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -138,12 +126,4 @@ describe 'API V1 Accounts Statuses' do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def links_from_header
|
||||
response
|
||||
.headers['Link']
|
||||
.links
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe 'Account actions' do
|
|||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
shared_examples 'a successful notification delivery' do
|
||||
it 'notifies the user about the action taken', :sidekiq_inline do
|
||||
it 'notifies the user about the action taken', :inline_jobs do
|
||||
emails = capture_emails { subject }
|
||||
|
||||
expect(emails.size)
|
||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe 'API V1 Conversations' do
|
|||
|
||||
let(:other) { Fabricate(:user) }
|
||||
|
||||
describe 'GET /api/v1/conversations', :sidekiq_inline do
|
||||
describe 'GET /api/v1/conversations', :inline_jobs do
|
||||
before do
|
||||
user.account.follow!(other.account)
|
||||
PostStatusService.new.call(other.account, text: 'Hey @alice', visibility: 'direct')
|
||||
|
@ -20,8 +20,12 @@ RSpec.describe 'API V1 Conversations' do
|
|||
it 'returns pagination headers', :aggregate_failures do
|
||||
get '/api/v1/conversations', params: { limit: 1 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.headers['Link'].links.size).to eq(2)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and include_pagination_headers(
|
||||
prev: api_v1_conversations_url(limit: 1, min_id: Status.first.id),
|
||||
next: api_v1_conversations_url(limit: 1, max_id: Status.first.id)
|
||||
)
|
||||
end
|
||||
|
||||
it 'returns conversations', :aggregate_failures do
|
||||
|
|
|
@ -147,7 +147,7 @@ RSpec.describe 'FeaturedTags' do
|
|||
expect(body).to be_empty
|
||||
end
|
||||
|
||||
it 'deletes the featured tag', :sidekiq_inline do
|
||||
it 'deletes the featured tag', :inline_jobs do
|
||||
delete "/api/v1/featured_tags/#{id}", headers: headers
|
||||
|
||||
featured_tag = FeaturedTag.find_by(id: id)
|
||||
|
|
|
@ -121,19 +121,19 @@ RSpec.describe 'Media' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with image/jpeg', :paperclip_processing do
|
||||
context 'with image/jpeg', :attachment_processing do
|
||||
let(:params) { { file: fixture_file_upload('attachment.jpg', 'image/jpeg'), description: 'jpeg image' } }
|
||||
|
||||
it_behaves_like 'a successful media upload', 'image'
|
||||
end
|
||||
|
||||
context 'with image/gif', :paperclip_processing do
|
||||
context 'with image/gif', :attachment_processing do
|
||||
let(:params) { { file: fixture_file_upload('attachment.gif', 'image/gif') } }
|
||||
|
||||
it_behaves_like 'a successful media upload', 'image'
|
||||
end
|
||||
|
||||
context 'with video/webm', :paperclip_processing do
|
||||
context 'with video/webm', :attachment_processing do
|
||||
let(:params) { { file: fixture_file_upload('attachment.webm', 'video/webm') } }
|
||||
|
||||
it_behaves_like 'a successful media upload', 'gifv'
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe 'Policies' do
|
|||
let(:scopes) { 'read:notifications write:notifications' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
describe 'GET /api/v1/notifications/policy', :sidekiq_inline do
|
||||
describe 'GET /api/v1/notifications/policy', :inline_jobs do
|
||||
subject do
|
||||
get '/api/v1/notifications/policy', headers: headers, params: params
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe 'Requests' do
|
|||
let(:scopes) { 'read:notifications write:notifications' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
describe 'GET /api/v1/notifications/requests', :sidekiq_inline do
|
||||
describe 'GET /api/v1/notifications/requests', :inline_jobs do
|
||||
subject do
|
||||
get '/api/v1/notifications/requests', headers: headers, params: params
|
||||
end
|
||||
|
@ -17,7 +17,6 @@ RSpec.describe 'Requests' do
|
|||
|
||||
before do
|
||||
Fabricate(:notification_request, account: user.account)
|
||||
Fabricate(:notification_request, account: user.account, dismissed: true)
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write write:notifications'
|
||||
|
@ -29,16 +28,6 @@ RSpec.describe 'Requests' do
|
|||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with dismissed' do
|
||||
let(:params) { { dismissed: '1' } }
|
||||
|
||||
it 'returns http success', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /api/v1/notifications/requests/:id/accept' do
|
||||
|
@ -78,15 +67,14 @@ RSpec.describe 'Requests' do
|
|||
post "/api/v1/notifications/requests/#{notification_request.id}/dismiss", headers: headers
|
||||
end
|
||||
|
||||
let(:notification_request) { Fabricate(:notification_request, account: user.account) }
|
||||
let!(:notification_request) { Fabricate(:notification_request, account: user.account) }
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'read read:notifications'
|
||||
|
||||
it 'returns http success and dismisses the notification request', :aggregate_failures do
|
||||
subject
|
||||
it 'returns http success and destroys the notification request', :aggregate_failures do
|
||||
expect { subject }.to change(NotificationRequest, :count).by(-1)
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(notification_request.reload.dismissed?).to be true
|
||||
end
|
||||
|
||||
context 'when notification request belongs to someone else' do
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe 'Notifications' do
|
|||
let(:scopes) { 'read:notifications write:notifications' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
describe 'GET /api/v1/notifications', :sidekiq_inline do
|
||||
describe 'GET /api/v1/notifications', :inline_jobs do
|
||||
subject do
|
||||
get '/api/v1/notifications', headers: headers, params: params
|
||||
end
|
||||
|
@ -20,8 +20,8 @@ RSpec.describe 'Notifications' do
|
|||
before do
|
||||
first_status = PostStatusService.new.call(user.account, text: 'Test')
|
||||
ReblogService.new.call(bob.account, first_status)
|
||||
mentioning_status = PostStatusService.new.call(bob.account, text: 'Hello @alice')
|
||||
mentioning_status.mentions.first
|
||||
PostStatusService.new.call(bob.account, text: 'Hello @alice')
|
||||
PostStatusService.new.call(tom.account, text: 'Hello @alice', visibility: :direct) # Filtered by default
|
||||
FavouriteService.new.call(bob.account, first_status)
|
||||
FavouriteService.new.call(tom.account, first_status)
|
||||
FollowService.new.call(bob.account, user.account)
|
||||
|
@ -34,10 +34,22 @@ RSpec.describe 'Notifications' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_json_types).to include 'reblog'
|
||||
expect(body_json_types).to include 'mention'
|
||||
expect(body_json_types).to include 'favourite'
|
||||
expect(body_json_types).to include 'follow'
|
||||
expect(body_as_json.size).to eq 5
|
||||
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
|
||||
expect(body_as_json.any? { |x| x[:filtered] }).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'with include_filtered' do
|
||||
let(:params) { { include_filtered: true } }
|
||||
|
||||
it 'returns expected notification types, including filtered notifications' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json.size).to eq 6
|
||||
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
|
||||
expect(body_as_json.any? { |x| x[:filtered] }).to be true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -96,7 +108,7 @@ RSpec.describe 'Notifications' do
|
|||
it 'returns the requested number of notifications paginated', :aggregate_failures do
|
||||
subject
|
||||
|
||||
notifications = user.account.notifications
|
||||
notifications = user.account.notifications.browserable
|
||||
|
||||
expect(body_as_json.size)
|
||||
.to eq(params[:limit])
|
||||
|
|
|
@ -10,9 +10,10 @@ RSpec.describe 'API V1 Polls Votes' do
|
|||
|
||||
describe 'POST /api/v1/polls/:poll_id/votes' do
|
||||
let(:poll) { Fabricate(:poll) }
|
||||
let(:params) { { choices: %w(1) } }
|
||||
|
||||
before do
|
||||
post "/api/v1/polls/#{poll.id}/votes", params: { choices: %w(1) }, headers: headers
|
||||
post "/api/v1/polls/#{poll.id}/votes", params: params, headers: headers
|
||||
end
|
||||
|
||||
it 'creates a vote', :aggregate_failures do
|
||||
|
@ -24,6 +25,14 @@ RSpec.describe 'API V1 Polls Votes' do
|
|||
expect(poll.reload.cached_tallies).to eq [0, 1]
|
||||
end
|
||||
|
||||
context 'when the required choices param is not provided' do
|
||||
let(:params) { {} }
|
||||
|
||||
it 'returns http bad request' do
|
||||
expect(response).to have_http_status(400)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def vote
|
||||
|
|
|
@ -33,7 +33,7 @@ RSpec.describe 'Reports' do
|
|||
|
||||
it_behaves_like 'forbidden for wrong scope', 'read read:reports'
|
||||
|
||||
it 'creates a report', :aggregate_failures, :sidekiq_inline do
|
||||
it 'creates a report', :aggregate_failures, :inline_jobs do
|
||||
emails = capture_emails { subject }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
|
|
|
@ -29,8 +29,10 @@ RSpec.describe 'API V1 Statuses Favourited by Accounts' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.headers['Link'].links.size)
|
||||
.to eq(2)
|
||||
.and include_pagination_headers(
|
||||
prev: api_v1_status_favourited_by_index_url(limit: 2, since_id: Favourite.last.id),
|
||||
next: api_v1_status_favourited_by_index_url(limit: 2, max_id: Favourite.first.id)
|
||||
)
|
||||
|
||||
expect(body_as_json.size)
|
||||
.to eq(2)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Favourites', :sidekiq_inline do
|
||||
RSpec.describe 'Favourites', :inline_jobs do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:scopes) { 'write:favourites' }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
|
|
@ -28,8 +28,10 @@ RSpec.describe 'API V1 Statuses Reblogged by Accounts' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.headers['Link'].links.size)
|
||||
.to eq(2)
|
||||
.and include_pagination_headers(
|
||||
prev: api_v1_status_reblogged_by_index_url(limit: 2, since_id: bob.statuses.first.id),
|
||||
next: api_v1_status_reblogged_by_index_url(limit: 2, max_id: alice.statuses.first.id)
|
||||
)
|
||||
|
||||
expect(body_as_json.size)
|
||||
.to eq(2)
|
||||
|
|
|
@ -41,7 +41,7 @@ describe 'API V1 Statuses Reblogs' do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'POST /api/v1/statuses/:status_id/unreblog', :sidekiq_inline do
|
||||
describe 'POST /api/v1/statuses/:status_id/unreblog', :inline_jobs do
|
||||
context 'with public status' do
|
||||
let(:status) { Fabricate(:status, account: user.account) }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Home', :sidekiq_inline do
|
||||
describe 'Home', :inline_jobs do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:scopes) { 'read:statuses' }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
|
|
@ -83,7 +83,8 @@ RSpec.describe 'API V2 Admin Accounts' do
|
|||
let(:params) { { limit: 1 } }
|
||||
|
||||
it 'sets the correct pagination headers' do
|
||||
expect(response.headers['Link'].find_link(%w(rel next)).href).to eq api_v2_admin_accounts_url(limit: 1, max_id: admin_account.id)
|
||||
expect(response)
|
||||
.to include_pagination_headers(next: api_v2_admin_accounts_url(limit: 1, max_id: admin_account.id))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Media API', :paperclip_processing do
|
||||
RSpec.describe 'Media API', :attachment_processing do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'write' }
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe 'Notifications' do
|
|||
let(:scopes) { 'read:notifications write:notifications' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
|
||||
describe 'GET /api/v2_alpha/notifications', :sidekiq_inline do
|
||||
describe 'GET /api/v2_alpha/notifications', :inline_jobs do
|
||||
subject do
|
||||
get '/api/v2_alpha/notifications', headers: headers, params: params
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue