mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-21 14:18:36 +00:00
Merge commit '973597c6f1e25b16c592e5573304319aeaa375e1' into glitch-soc/merge-upstream
Conflicts: - `app/validators/status_pin_validator.rb`: Upstream refactored that file, while glitch-soc had configurable limits for pinned statuses. Updated the code with upstream's refactor, while keeping glitch-soc's configurability.
This commit is contained in:
@@ -450,10 +450,11 @@ RSpec.describe Account do
|
||||
expect(results).to eq [match]
|
||||
end
|
||||
|
||||
it 'limits by 10 by default' do
|
||||
11.times.each { Fabricate(:account, display_name: 'Display Name') }
|
||||
it 'limits via constant by default' do
|
||||
stub_const('AccountSearch::DEFAULT_LIMIT', 1)
|
||||
2.times.each { Fabricate(:account, display_name: 'Display Name') }
|
||||
results = described_class.search_for('display')
|
||||
expect(results.size).to eq 10
|
||||
expect(results.size).to eq 1
|
||||
end
|
||||
|
||||
it 'accepts arbitrary limits' do
|
||||
@@ -594,9 +595,10 @@ RSpec.describe Account do
|
||||
end
|
||||
|
||||
it 'limits by 10 by default' do
|
||||
11.times { Fabricate(:account, display_name: 'Display Name') }
|
||||
stub_const('AccountSearch::DEFAULT_LIMIT', 1)
|
||||
2.times { Fabricate(:account, display_name: 'Display Name') }
|
||||
results = described_class.advanced_search_for('display', account)
|
||||
expect(results.size).to eq 10
|
||||
expect(results.size).to eq 1
|
||||
end
|
||||
|
||||
it 'accepts arbitrary limits' do
|
||||
|
||||
@@ -280,10 +280,10 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
||||
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
||||
|
||||
before do
|
||||
4.times { faved_primary.increment_count!(:favourites_count) }
|
||||
5.times { faved_secondary.increment_count!(:favourites_count) }
|
||||
4.times { reblogged_primary.increment_count!(:reblogs_count) }
|
||||
5.times { reblogged_secondary.increment_count!(:reblogs_count) }
|
||||
faved_primary.status_stat.update(favourites_count: 4)
|
||||
faved_secondary.status_stat.update(favourites_count: 5)
|
||||
reblogged_primary.status_stat.update(reblogs_count: 4)
|
||||
reblogged_secondary.status_stat.update(reblogs_count: 5)
|
||||
end
|
||||
|
||||
context 'when passed a max_id' do
|
||||
|
||||
@@ -46,12 +46,10 @@ RSpec.describe Admin::AccountAction do
|
||||
expect(target_account).to be_suspended
|
||||
end
|
||||
|
||||
it 'queues Admin::SuspensionWorker by 1' do
|
||||
Sidekiq::Testing.fake! do
|
||||
expect do
|
||||
subject
|
||||
end.to change { Admin::SuspensionWorker.jobs.size }.by 1
|
||||
end
|
||||
it 'queues Admin::SuspensionWorker by 1', :sidekiq_fake do
|
||||
expect do
|
||||
subject
|
||||
end.to change { Admin::SuspensionWorker.jobs.size }.by 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -40,35 +40,34 @@ RSpec.describe StatusPin do
|
||||
expect(described_class.new(account: account, status: status).save).to be false
|
||||
end
|
||||
|
||||
max_pins = 5
|
||||
it 'does not allow pins above the max' do
|
||||
account = Fabricate(:account)
|
||||
status = []
|
||||
context 'with a pin limit' do
|
||||
before { stub_const('StatusPinValidator::PIN_LIMIT', 2) }
|
||||
|
||||
(max_pins + 1).times do |i|
|
||||
status[i] = Fabricate(:status, account: account)
|
||||
it 'does not allow pins above the max' do
|
||||
account = Fabricate(:account)
|
||||
|
||||
Fabricate.times(StatusPinValidator::PIN_LIMIT, :status_pin, account: account)
|
||||
|
||||
pin = described_class.new(account: account, status: Fabricate(:status, account: account))
|
||||
expect(pin.save)
|
||||
.to be(false)
|
||||
|
||||
expect(pin.errors[:base])
|
||||
.to contain_exactly(I18n.t('statuses.pin_errors.limit'))
|
||||
end
|
||||
|
||||
max_pins.times do |i|
|
||||
expect(described_class.new(account: account, status: status[i]).save).to be true
|
||||
it 'allows pins above the max for remote accounts' do
|
||||
account = Fabricate(:account, domain: 'remote.test', username: 'bob', url: 'https://remote.test/')
|
||||
|
||||
Fabricate.times(StatusPinValidator::PIN_LIMIT, :status_pin, account: account)
|
||||
|
||||
pin = described_class.new(account: account, status: Fabricate(:status, account: account))
|
||||
expect(pin.save)
|
||||
.to be(true)
|
||||
|
||||
expect(pin.errors[:base])
|
||||
.to be_empty
|
||||
end
|
||||
|
||||
expect(described_class.new(account: account, status: status[max_pins]).save).to be false
|
||||
end
|
||||
|
||||
it 'allows pins above the max for remote accounts' do
|
||||
account = Fabricate(:account, domain: 'remote.test', username: 'bob', url: 'https://remote.test/')
|
||||
status = []
|
||||
|
||||
(max_pins + 1).times do |i|
|
||||
status[i] = Fabricate(:status, account: account)
|
||||
end
|
||||
|
||||
max_pins.times do |i|
|
||||
expect(described_class.new(account: account, status: status[i]).save).to be true
|
||||
end
|
||||
|
||||
expect(described_class.new(account: account, status: status[max_pins]).save).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,12 +27,6 @@ RSpec.describe User do
|
||||
expect(user).to model_have_error_on_field(:account)
|
||||
end
|
||||
|
||||
it 'is invalid without a valid locale' do
|
||||
user = Fabricate.build(:user, locale: 'toto')
|
||||
user.valid?
|
||||
expect(user).to model_have_error_on_field(:locale)
|
||||
end
|
||||
|
||||
it 'is invalid without a valid email' do
|
||||
user = Fabricate.build(:user, email: 'john@')
|
||||
user.valid?
|
||||
@@ -45,6 +39,18 @@ RSpec.describe User do
|
||||
expect(user.valid?).to be true
|
||||
end
|
||||
|
||||
it 'cleans out invalid locale' do
|
||||
user = Fabricate.build(:user, locale: 'toto')
|
||||
expect(user.valid?).to be true
|
||||
expect(user.locale).to be_nil
|
||||
end
|
||||
|
||||
it 'cleans out invalid timezone' do
|
||||
user = Fabricate.build(:user, time_zone: 'toto')
|
||||
expect(user.valid?).to be true
|
||||
expect(user.time_zone).to be_nil
|
||||
end
|
||||
|
||||
it 'cleans out empty string from languages' do
|
||||
user = Fabricate.build(:user, chosen_languages: [''])
|
||||
user.valid?
|
||||
|
||||
Reference in New Issue
Block a user