Merge commit 'c929b4cace3f95fe54fdafe449ea7e972c8d61e8' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2024-07-12 13:41:54 +02:00
39 changed files with 197 additions and 178 deletions

View File

@@ -69,19 +69,16 @@ describe InvitesController do
end
end
describe 'DELETE #create' do
describe 'DELETE #destroy' do
subject { delete :destroy, params: { id: invite.id } }
let(:invite) { Fabricate(:invite, user: user, expires_at: nil) }
before do
delete :destroy, params: { id: invite.id }
end
it 'redirects' do
expect(response).to redirect_to invites_path
end
it 'expires invite' do
expect(invite.reload).to be_expired
it 'expires invite and redirects' do
expect { subject }
.to(change { invite.reload.expired? }.to(true))
expect(response)
.to redirect_to invites_path
end
end
end

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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