Merge remote-tracking branch 'parent/main' into upstream-20240122
This commit is contained in:
commit
a4cc73438e
65 changed files with 1150 additions and 707 deletions
|
@ -9,14 +9,10 @@ RSpec.describe Account do
|
|||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
describe '#suspend!' do
|
||||
it 'marks the account as suspended' do
|
||||
subject.suspend!
|
||||
expect(subject.suspended?).to be true
|
||||
end
|
||||
|
||||
it 'creates a deletion request' do
|
||||
subject.suspend!
|
||||
expect(AccountDeletionRequest.where(account: subject).exists?).to be true
|
||||
it 'marks the account as suspended and creates a deletion request' do
|
||||
expect { subject.suspend! }
|
||||
.to change(subject, :suspended?).from(false).to(true)
|
||||
.and(change { AccountDeletionRequest.exists?(account: subject) }.from(false).to(true))
|
||||
end
|
||||
|
||||
context 'when the account is of a local user' do
|
||||
|
@ -1050,6 +1046,25 @@ RSpec.describe Account do
|
|||
end
|
||||
|
||||
describe 'scopes' do
|
||||
describe 'auditable' do
|
||||
let!(:alice) { Fabricate :account }
|
||||
let!(:bob) { Fabricate :account }
|
||||
|
||||
before do
|
||||
2.times { Fabricate :action_log, account: alice }
|
||||
end
|
||||
|
||||
it 'returns distinct accounts with action log records' do
|
||||
results = described_class.auditable
|
||||
|
||||
expect(results.size)
|
||||
.to eq(1)
|
||||
expect(results)
|
||||
.to include(alice)
|
||||
.and not_include(bob)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'alphabetic' do
|
||||
it 'sorts by alphabetic order of domain and username' do
|
||||
matches = [
|
||||
|
|
|
@ -3,16 +3,18 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe DomainAllow do
|
||||
describe 'scopes' do
|
||||
describe 'matches_domain' do
|
||||
let(:domain) { Fabricate(:domain_allow, domain: 'example.com') }
|
||||
let(:other_domain) { Fabricate(:domain_allow, domain: 'example.biz') }
|
||||
describe 'Validations' do
|
||||
it 'is invalid without a domain' do
|
||||
domain_allow = Fabricate.build(:domain_allow, domain: nil)
|
||||
domain_allow.valid?
|
||||
expect(domain_allow).to model_have_error_on_field(:domain)
|
||||
end
|
||||
|
||||
it 'returns the correct records' do
|
||||
results = described_class.matches_domain('example.com')
|
||||
|
||||
expect(results).to eq([domain])
|
||||
end
|
||||
it 'is invalid if the same normalized domain already exists' do
|
||||
_domain_allow = Fabricate(:domain_allow, domain: 'にゃん')
|
||||
domain_allow_with_normalized_value = Fabricate.build(:domain_allow, domain: 'xn--r9j5b5b')
|
||||
domain_allow_with_normalized_value.valid?
|
||||
expect(domain_allow_with_normalized_value).to model_have_error_on_field(:domain)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue