Merge remote-tracking branch 'parent/main' into upstream-20240112

This commit is contained in:
KMY 2024-01-12 14:48:17 +09:00
commit e65fb9fb51
333 changed files with 2661 additions and 1461 deletions

View file

@ -177,7 +177,9 @@ RSpec.describe 'IP Blocks' do
let(:params) { { severity: 'sign_up_requires_approval', comment: 'Decreasing severity' } }
it 'returns the correct ip block', :aggregate_failures do
subject
expect { subject }
.to change_severity_level
.and change_comment_value
expect(response).to have_http_status(200)
expect(body_as_json).to match(hash_including({
@ -187,12 +189,12 @@ RSpec.describe 'IP Blocks' do
}))
end
it 'updates the severity correctly' do
expect { subject }.to change { ip_block.reload.severity }.from('no_access').to('sign_up_requires_approval')
def change_severity_level
change { ip_block.reload.severity }.from('no_access').to('sign_up_requires_approval')
end
it 'updates the comment correctly' do
expect { subject }.to change { ip_block.reload.comment }.from('Spam').to('Decreasing severity')
def change_comment_value
change { ip_block.reload.comment }.from('Spam').to('Decreasing severity')
end
context 'when ip block does not exist' do

View file

@ -32,18 +32,18 @@ describe 'Links' do
it_behaves_like 'forbidden for wrong role', ''
it 'returns http success' do
subject
expect { subject }
.to change_link_trendable_to_true
expect(response).to have_http_status(200)
expects_correct_link_data
end
it 'sets the link as trendable' do
expect { subject }.to change { preview_card.reload.trendable }.from(false).to(true)
def change_link_trendable_to_true
change { preview_card.reload.trendable }.from(false).to(true)
end
it 'returns the link data' do
subject
def expects_correct_link_data
expect(body_as_json).to match(
a_hash_including(
url: preview_card.url,
@ -85,13 +85,14 @@ describe 'Links' do
it_behaves_like 'forbidden for wrong role', ''
it 'returns http success' do
subject
expect { subject }
.to_not change_link_trendable
expect(response).to have_http_status(200)
end
it 'does not set the link as trendable' do
expect { subject }.to_not(change { preview_card.reload.trendable })
def change_link_trendable
change { preview_card.reload.trendable }
end
it 'returns the link data' do

View file

@ -147,7 +147,7 @@ RSpec.describe 'FeaturedTags' do
expect(body).to be_empty
end
it 'deletes the featured tag' do
it 'deletes the featured tag', :sidekiq_inline do
delete "/api/v1/featured_tags/#{id}", headers: headers
featured_tag = FeaturedTag.find_by(id: id)

View file

@ -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' do
describe 'GET /api/v1/notifications', :sidekiq_inline do
subject do
get '/api/v1/notifications', headers: headers, params: params
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe 'Favourites' do
RSpec.describe 'Favourites', :sidekiq_inline do
let(:user) { Fabricate(:user) }
let(:scopes) { 'write:favourites' }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
@ -70,7 +70,7 @@ RSpec.describe 'Favourites' do
end
end
describe 'POST /api/v1/statuses/:status_id/unfavourite', :sidekiq_fake do
describe 'POST /api/v1/statuses/:status_id/unfavourite' do
subject do
post "/api/v1/statuses/#{status.id}/unfavourite", headers: headers
end
@ -88,9 +88,7 @@ RSpec.describe 'Favourites' do
subject
expect(response).to have_http_status(200)
expect(user.account.favourited?(status)).to be true
UnfavouriteWorker.drain
expect(user.account.favourited?(status)).to be false
end
@ -113,9 +111,7 @@ RSpec.describe 'Favourites' do
subject
expect(response).to have_http_status(200)
expect(user.account.favourited?(status)).to be true
UnfavouriteWorker.drain
expect(user.account.favourited?(status)).to be false
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe 'Home' do
describe 'Home', :sidekiq_inline do
let(:user) { Fabricate(:user) }
let(:scopes) { 'read:statuses' }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }