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

@ -79,7 +79,7 @@ RSpec.describe ActivityPub::OutboxesController do
it 'returns orderedItems with public or unlisted statuses' do
expect(body[:orderedItems]).to be_an Array
expect(body[:orderedItems].size).to eq 2
expect(body[:orderedItems].all? { |item| item[:to].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:cc].include?(ActivityPub::TagManager::COLLECTIONS[:public]) }).to be true
expect(body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
end
it_behaves_like 'cacheable response'
@ -132,7 +132,7 @@ RSpec.describe ActivityPub::OutboxesController do
json = body_as_json
expect(json[:orderedItems]).to be_an Array
expect(json[:orderedItems].size).to eq 2
expect(json[:orderedItems].all? { |item| item[:to].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:cc].include?(ActivityPub::TagManager::COLLECTIONS[:public]) }).to be true
expect(json[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
end
it 'returns private Cache-Control header' do
@ -158,7 +158,7 @@ RSpec.describe ActivityPub::OutboxesController do
json = body_as_json
expect(json[:orderedItems]).to be_an Array
expect(json[:orderedItems].size).to eq 3
expect(json[:orderedItems].all? { |item| item[:to].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:cc].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:to].include?(account_followers_url(account, ActionMailer::Base.default_url_options)) }).to be true
expect(json[:orderedItems].all? { |item| targets_public_collection?(item) || targets_followers_collection?(item, account) }).to be true
end
it 'returns private Cache-Control header' do
@ -217,4 +217,20 @@ RSpec.describe ActivityPub::OutboxesController do
end
end
end
private
def ap_public_collection
ActivityPub::TagManager::COLLECTIONS[:public]
end
def targets_public_collection?(item)
item[:to].include?(ap_public_collection) || item[:cc].include?(ap_public_collection)
end
def targets_followers_collection?(item, account)
item[:to].include?(
account_followers_url(account, ActionMailer::Base.default_url_options)
)
end
end

View file

@ -84,7 +84,7 @@ RSpec.describe ActivityPub::RepliesController do
expect(page_json).to be_a Hash
expect(page_json[:items]).to be_an Array
expect(page_json[:items].size).to eq 1
expect(page_json[:items].all? { |item| item[:to].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:cc].include?(ActivityPub::TagManager::COLLECTIONS[:public]) }).to be true
expect(page_json[:items].all? { |item| targets_public_collection?(item) }).to be true
end
context 'when there are few self-replies' do
@ -117,8 +117,7 @@ RSpec.describe ActivityPub::RepliesController do
it 'only inlines items that are local and public or unlisted replies' do
inlined_replies = page_json[:items].select { |x| x.is_a?(Hash) }
public_collection = ActivityPub::TagManager::COLLECTIONS[:public]
expect(inlined_replies.all? { |item| item[:to].include?(public_collection) || item[:cc].include?(public_collection) }).to be true
expect(inlined_replies.all? { |item| targets_public_collection?(item) }).to be true
expect(inlined_replies.all? { |item| ActivityPub::TagManager.instance.local_uri?(item[:id]) }).to be true
end
@ -194,4 +193,14 @@ RSpec.describe ActivityPub::RepliesController do
end
end
end
private
def ap_public_collection
ActivityPub::TagManager::COLLECTIONS[:public]
end
def targets_public_collection?(item)
item[:to].include?(ap_public_collection) || item[:cc].include?(ap_public_collection)
end
end

View file

@ -44,7 +44,7 @@ RSpec.describe Admin::Disputes::AppealsController do
expect(response).to redirect_to(disputes_strike_path(appeal.strike))
end
it 'notifies target account about approved appeal' do
it 'notifies target account about approved appeal', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at)))
@ -62,7 +62,7 @@ RSpec.describe Admin::Disputes::AppealsController do
expect(response).to redirect_to(disputes_strike_path(appeal.strike))
end
it 'notifies target account about rejected appeal' do
it 'notifies target account about rejected appeal', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at)))

View file

@ -176,7 +176,7 @@ RSpec.describe Admin::DomainBlocksController do
end
end
describe 'PUT #update' do
describe 'PUT #update', :sidekiq_inline do
subject do
post :update, params: { :id => domain_block.id, :domain_block => { domain: 'example.com', severity: new_severity }, 'confirm' => '' }
end

View file

@ -35,6 +35,16 @@ RSpec.describe Admin::EmailDomainBlocksController do
describe 'POST #create' do
context 'when resolve button is pressed' do
before do
resolver = instance_double(Resolv::DNS)
allow(resolver).to receive(:getresources)
.with('example.com', Resolv::DNS::Resource::IN::MX)
.and_return([])
allow(resolver).to receive(:getresources).with('example.com', Resolv::DNS::Resource::IN::A).and_return([])
allow(resolver).to receive(:getresources).with('example.com', Resolv::DNS::Resource::IN::AAAA).and_return([])
allow(resolver).to receive(:timeouts=).and_return(nil)
allow(Resolv::DNS).to receive(:open).and_yield(resolver)
post :create, params: { email_domain_block: { domain: 'example.com' } }
end

View file

@ -11,7 +11,7 @@ describe Admin::ResetsController do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
end
describe 'POST #create' do
describe 'POST #create', :sidekiq_inline do
it 'redirects to admin accounts page' do
expect do
post :create, params: { account_id: account.id }

View file

@ -13,7 +13,7 @@ RSpec.describe Api::V1::ConversationsController do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
describe 'GET #index', :sidekiq_inline do
let(:scopes) { 'read:statuses' }
before do

View file

@ -9,7 +9,7 @@ describe Api::V1::Statuses::ReblogsController do
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write:statuses', application: app) }
context 'with an oauth token', :sidekiq_fake do
context 'with an oauth token' do
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
@ -46,7 +46,7 @@ describe Api::V1::Statuses::ReblogsController do
end
end
describe 'POST #destroy' do
describe 'POST #destroy', :sidekiq_inline do
context 'with public status' do
let(:status) { Fabricate(:status, account: user.account) }

View file

@ -5,7 +5,7 @@ require 'rails_helper'
describe Api::V1::StreamingController do
around do |example|
before = Rails.configuration.x.streaming_api_base_url
Rails.configuration.x.streaming_api_base_url = Rails.configuration.x.web_domain
Rails.configuration.x.streaming_api_base_url = "wss://#{Rails.configuration.x.web_domain}"
example.run
Rails.configuration.x.streaming_api_base_url = before
end

View file

@ -138,7 +138,7 @@ RSpec.describe Auth::SessionsController do
expect(controller.current_user).to eq user
end
it 'sends a suspicious sign-in mail' do
it 'sends a suspicious sign-in mail', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.suspicious_sign_in.subject'))

View file

@ -75,7 +75,7 @@ describe UserTrackingConcern do
expect(redis.ttl("account:#{user.account_id}:regeneration")).to be >= 0
end
it 'regenerates feed when sign in is older than two weeks' do
it 'regenerates feed when sign in is older than two weeks', :sidekiq_inline do
get :show
expect_updated_sign_in_at(user)

View file

@ -17,7 +17,7 @@ RSpec.describe Disputes::AppealsController do
post :create, params: { strike_id: strike.id, appeal: { text: 'Foo' } }
end
it 'notifies staff about new appeal' do
it 'notifies staff about new appeal', :sidekiq_inline do
expect(ActionMailer::Base.deliveries.first.to).to eq([admin.email])
end

View file

@ -50,7 +50,7 @@ describe Settings::DeletesController do
delete :destroy, params: { form_delete_confirmation: { password: 'petsmoldoggos' } }
end
it 'removes user record and redirects', :aggregate_failures do
it 'removes user record and redirects', :aggregate_failures, :sidekiq_inline do
expect(response).to redirect_to '/auth/sign_in'
expect(User.find_by(id: user.id)).to be_nil
expect(user.account.reload).to be_suspended

View file

@ -38,7 +38,7 @@ describe Settings::ExportsController do
expect(response).to redirect_to(settings_export_path)
end
it 'queues BackupWorker job by 1', :sidekiq_fake do
it 'queues BackupWorker job by 1' do
expect do
post :create
end.to change(BackupWorker.jobs, :size).by(1)

View file

@ -43,10 +43,20 @@ describe Settings::FeaturedTagsController do
end
describe 'GET to #index' do
let(:tag) { Fabricate(:tag) }
before do
status = Fabricate :status, account: user.account
status.tags << tag
end
it 'responds with success' do
get :index
expect(response).to have_http_status(200)
expect(response.body).to include(
settings_featured_tags_path(featured_tag: { name: tag.name })
)
end
end

View file

@ -6,6 +6,7 @@ describe Settings::LoginActivitiesController do
render_views
let!(:user) { Fabricate(:user) }
let!(:login_activity) { Fabricate :login_activity, user: user }
before do
sign_in user, scope: :user
@ -19,6 +20,10 @@ describe Settings::LoginActivitiesController do
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Cache-Control']).to include('private, no-store')
expect(response.body)
.to include(login_activity.user_agent)
.and include(login_activity.authentication_method)
.and include(login_activity.ip.to_s)
end
end
end