Merge tag 'v2.9.2' into instance_only_statuses

This commit is contained in:
Renato "Lond" Cerqueira
2019-06-25 19:44:59 +02:00
534 changed files with 12629 additions and 7877 deletions

View File

@ -601,8 +601,8 @@ RSpec.describe Account, type: :model do
expect(account).to model_have_error_on_field(:display_name)
end
it 'is invalid if the note is longer than 160 characters' do
account = Fabricate.build(:account, note: Faker::Lorem.characters(161))
it 'is invalid if the note is longer than 500 characters' do
account = Fabricate.build(:account, note: Faker::Lorem.characters(501))
account.valid?
expect(account).to model_have_error_on_field(:note)
end
@ -647,8 +647,8 @@ RSpec.describe Account, type: :model do
expect(account).not_to model_have_error_on_field(:display_name)
end
it 'is valid even if the note is longer than 160 characters' do
account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(161))
it 'is valid even if the note is longer than 500 characters' do
account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(501))
account.valid?
expect(account).not_to model_have_error_on_field(:note)
end
@ -687,6 +687,23 @@ RSpec.describe Account, type: :model do
end
end
describe 'by_domain_and_subdomains' do
it 'returns exact domain matches' do
account = Fabricate(:account, domain: 'example.com')
expect(Account.by_domain_and_subdomains('example.com')).to eq [account]
end
it 'returns subdomains' do
account = Fabricate(:account, domain: 'foo.example.com')
expect(Account.by_domain_and_subdomains('example.com')).to eq [account]
end
it 'does not return partially matching domains' do
account = Fabricate(:account, domain: 'grexample.com')
expect(Account.by_domain_and_subdomains('example.com')).to_not eq [account]
end
end
describe 'expiring' do
it 'returns remote accounts with followers whose subscription expiration date is past or not given' do
local = Fabricate(:account, domain: nil)

View File

@ -35,7 +35,7 @@ describe StatusThreadingConcern do
end
it 'does not return conversation history from silenced and not followed users' do
jeff.update(silenced: true)
jeff.silence!
expect(reply3.ancestors(4, viewer)).to_not include(reply1)
end
@ -110,7 +110,7 @@ describe StatusThreadingConcern do
end
it 'does not return replies from silenced and not followed users' do
jeff.update(silenced: true)
jeff.silence!
expect(status.descendants(4, viewer)).to_not include(reply3)
end

View File

@ -21,23 +21,40 @@ RSpec.describe DomainBlock, type: :model do
end
end
describe 'blocked?' do
describe '.blocked?' do
it 'returns true if the domain is suspended' do
Fabricate(:domain_block, domain: 'domain', severity: :suspend)
expect(DomainBlock.blocked?('domain')).to eq true
Fabricate(:domain_block, domain: 'example.com', severity: :suspend)
expect(DomainBlock.blocked?('example.com')).to eq true
end
it 'returns false even if the domain is silenced' do
Fabricate(:domain_block, domain: 'domain', severity: :silence)
expect(DomainBlock.blocked?('domain')).to eq false
Fabricate(:domain_block, domain: 'example.com', severity: :silence)
expect(DomainBlock.blocked?('example.com')).to eq false
end
it 'returns false if the domain is not suspended nor silenced' do
expect(DomainBlock.blocked?('domain')).to eq false
expect(DomainBlock.blocked?('example.com')).to eq false
end
end
describe 'stricter_than?' do
describe '.rule_for' do
it 'returns rule matching a blocked domain' do
block = Fabricate(:domain_block, domain: 'example.com')
expect(DomainBlock.rule_for('example.com')).to eq block
end
it 'returns a rule matching a subdomain of a blocked domain' do
block = Fabricate(:domain_block, domain: 'example.com')
expect(DomainBlock.rule_for('sub.example.com')).to eq block
end
it 'returns a rule matching a blocked subdomain' do
block = Fabricate(:domain_block, domain: 'sub.example.com')
expect(DomainBlock.rule_for('sub.example.com')).to eq block
end
end
describe '#stricter_than?' do
it 'returns true if the new block has suspend severity while the old has lower severity' do
suspend = DomainBlock.new(domain: 'domain', severity: :suspend)
silence = DomainBlock.new(domain: 'domain', severity: :silence)