Merge commit '389a6cc4c0' into upstream-20231108

This commit is contained in:
KMY 2023-11-08 10:41:10 +09:00
commit 08f86bcb8f
107 changed files with 970 additions and 703 deletions

View file

@ -78,13 +78,15 @@ RSpec.describe Admin::AccountAction do
end
it 'calls process_email!' do
expect(account_action).to receive(:process_email!)
allow(account_action).to receive(:process_email!)
subject
expect(account_action).to have_received(:process_email!)
end
it 'calls process_reports!' do
expect(account_action).to receive(:process_reports!)
allow(account_action).to receive(:process_reports!)
subject
expect(account_action).to have_received(:process_reports!)
end
end

View file

@ -120,8 +120,11 @@ RSpec.describe Remotable do
end
it 'does not try to write attribute' do
expect(foo).to_not receive('[]=').with(attribute_name, url)
allow(foo).to receive('[]=').with(attribute_name, url)
foo.hoge_remote_url = url
expect(foo).to_not have_received('[]=').with(attribute_name, url)
end
end
@ -131,8 +134,11 @@ RSpec.describe Remotable do
end
it 'does not try to write attribute' do
expect(foo).to receive('[]=').with(attribute_name, url)
allow(foo).to receive('[]=').with(attribute_name, url)
foo.hoge_remote_url = url
expect(foo).to have_received('[]=').with(attribute_name, url)
end
end
@ -146,10 +152,13 @@ RSpec.describe Remotable do
let(:code) { 500 }
it 'does not assign file' do
expect(foo).to_not receive(:public_send).with("#{hoge}=", any_args)
expect(foo).to_not receive(:public_send).with("#{hoge}_file_name=", any_args)
allow(foo).to receive(:public_send)
allow(foo).to receive(:public_send)
foo.hoge_remote_url = url
expect(foo).to_not have_received(:public_send).with("#{hoge}=", any_args)
expect(foo).to_not have_received(:public_send).with("#{hoge}_file_name=", any_args)
end
end
@ -165,13 +174,13 @@ RSpec.describe Remotable do
allow(ResponseWithLimit).to receive(:new).with(anything, anything).and_return(response_with_limit)
expect(foo).to receive(:public_send).with("download_#{hoge}!", url)
allow(foo).to receive(:public_send)
foo.hoge_remote_url = url
expect(foo).to have_received(:public_send).with("download_#{hoge}!", url)
expect(foo).to receive(:public_send).with("#{hoge}=", response_with_limit)
allow(foo).to receive(:public_send)
foo.download_hoge!(url)
expect(foo).to have_received(:public_send).with("#{hoge}=", response_with_limit)
end
end
end
@ -193,10 +202,13 @@ RSpec.describe Remotable do
let(:error_class) { error_class }
it 'calls Rails.logger.debug' do
expect(Rails.logger).to receive(:debug) do |&block|
allow(Rails.logger).to receive(:debug)
foo.hoge_remote_url = url
expect(Rails.logger).to have_received(:debug) do |&block|
expect(block.call).to match(/^Error fetching remote #{hoge}: /)
end
foo.hoge_remote_url = url
end
end
end

View file

@ -21,12 +21,17 @@ RSpec.describe FollowRequest do
end
it 'calls Account#follow!, MergeWorker.perform_async, and #destroy!' do
expect(account).to receive(:follow!).with(target_account, reblogs: true, notify: false, uri: follow_request.uri, languages: nil, bypass_limit: true) do
allow(account).to receive(:follow!) do
account.active_relationships.create!(target_account: target_account)
end
expect(MergeWorker).to receive(:perform_async).with(target_account.id, account.id)
expect(follow_request).to receive(:destroy!)
allow(MergeWorker).to receive(:perform_async)
allow(follow_request).to receive(:destroy!)
follow_request.authorize!
expect(account).to have_received(:follow!).with(target_account, reblogs: true, notify: false, uri: follow_request.uri, languages: nil, bypass_limit: true)
expect(MergeWorker).to have_received(:perform_async).with(target_account.id, account.id)
expect(follow_request).to have_received(:destroy!)
end
it 'correctly passes show_reblogs when true' do

View file

@ -7,8 +7,11 @@ RSpec.describe Identity do
let(:auth) { Fabricate(:identity, user: Fabricate(:user)) }
it 'calls .find_or_create_by' do
expect(described_class).to receive(:find_or_create_by).with(uid: auth.uid, provider: auth.provider)
allow(described_class).to receive(:find_or_create_by)
described_class.find_for_oauth(auth)
expect(described_class).to have_received(:find_or_create_by).with(uid: auth.uid, provider: auth.provider)
end
it 'returns an instance of Identity' do

View file

@ -74,9 +74,13 @@ RSpec.describe SessionActivation do
let(:options) { { user: Fabricate(:user), session_id: '1' } }
it 'calls create! and purge_old' do
expect(described_class).to receive(:create!).with(**options)
expect(described_class).to receive(:purge_old)
allow(described_class).to receive(:create!).with(**options)
allow(described_class).to receive(:purge_old)
described_class.activate(**options)
expect(described_class).to have_received(:create!).with(**options)
expect(described_class).to have_received(:purge_old)
end
it 'returns an instance of SessionActivation' do

View file

@ -23,8 +23,11 @@ RSpec.describe Setting do
let(:rails_initialized) { false }
it 'calls RailsSettings::Base#[]' do
expect(RailsSettings::Base).to receive(:[]).with(key)
allow(RailsSettings::Base).to receive(:[]).with(key)
described_class[key]
expect(RailsSettings::Base).to have_received(:[]).with(key)
end
end
@ -38,8 +41,11 @@ RSpec.describe Setting do
let(:cache_value) { 'cache-value' }
it 'calls not RailsSettings::Base#[]' do
expect(RailsSettings::Base).to_not receive(:[]).with(key)
allow(RailsSettings::Base).to receive(:[]).with(key)
described_class[key]
expect(RailsSettings::Base).to_not have_received(:[]).with(key)
end
context 'when Rails.cache does not exists' do
@ -56,8 +62,11 @@ RSpec.describe Setting do
let(:records) { [Fabricate(:setting, var: key, value: nil)] }
it 'calls RailsSettings::Settings.object' do
expect(RailsSettings::Settings).to receive(:object).with(key)
allow(RailsSettings::Settings).to receive(:object).with(key)
described_class[key]
expect(RailsSettings::Settings).to have_received(:object).with(key)
end
context 'when RailsSettings::Settings.object returns truthy' do

View file

@ -60,7 +60,7 @@ RSpec.describe UserRole do
end
describe '#permissions_as_keys=' do
let(:input) {}
let(:input) { nil }
before do
subject.permissions_as_keys = input

View file

@ -102,7 +102,7 @@ RSpec.describe User do
end
describe 'blacklist' do
around(:each) do |example|
around do |example|
old_blacklist = Rails.configuration.x.email_blacklist
Rails.configuration.x.email_domains_blacklist = 'mvrht.com'
@ -169,7 +169,7 @@ RSpec.describe User do
let(:user) { Fabricate(:user, confirmed_at: nil, unconfirmed_email: new_email) }
context 'when the user is already approved' do
around(:example) do |example|
around do |example|
registrations_mode = Setting.registrations_mode
Setting.registrations_mode = 'approved'
@ -193,7 +193,7 @@ RSpec.describe User do
end
context 'when the user does not require explicit approval' do
around(:example) do |example|
around do |example|
registrations_mode = Setting.registrations_mode
Setting.registrations_mode = 'open'
@ -213,7 +213,7 @@ RSpec.describe User do
end
context 'when the user requires explicit approval but is not approved' do
around(:example) do |example|
around do |example|
registrations_mode = Setting.registrations_mode
Setting.registrations_mode = 'approved'
@ -237,7 +237,7 @@ RSpec.describe User do
describe '#approve!' do
subject { user.approve! }
around(:example) do |example|
around do |example|
registrations_mode = Setting.registrations_mode
Setting.registrations_mode = 'approved'
@ -338,7 +338,7 @@ RSpec.describe User do
end
describe 'whitelist' do
around(:each) do |example|
around do |example|
old_whitelist = Rails.configuration.x.email_domains_whitelist
Rails.configuration.x.email_domains_whitelist = 'mastodon.space'