Merge commit 'd818ddd6870094e89e58ef61f37da4cb73935856' into glitch-soc/merge-upstream
This commit is contained in:
commit
4daed855e5
35 files changed
+153
-78
No files matched your search
@@ -3,22 +3,30 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountDomainBlock do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
it 'removes blocking cache after creation' do
|
||||
account = Fabricate(:account)
|
||||
Rails.cache.write("exclude_domains_for:#{account.id}", 'a.domain.already.blocked')
|
||||
|
||||
described_class.create!(account: account, domain: 'a.domain.blocked.later')
|
||||
|
||||
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false
|
||||
expect { block_domain_for_account('a.domain.blocked.later') }
|
||||
.to change { account_has_exclude_domains_cache? }.to(false)
|
||||
end
|
||||
|
||||
it 'removes blocking cache after destruction' do
|
||||
account = Fabricate(:account)
|
||||
block = described_class.create!(account: account, domain: 'domain')
|
||||
block = block_domain_for_account('domain')
|
||||
Rails.cache.write("exclude_domains_for:#{account.id}", 'domain')
|
||||
|
||||
block.destroy!
|
||||
expect { block.destroy! }
|
||||
.to change { account_has_exclude_domains_cache? }.to(false)
|
||||
end
|
||||
|
||||
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false
|
||||
private
|
||||
|
||||
def block_domain_for_account(domain)
|
||||
Fabricate(:account_domain_block, account: account, domain: domain)
|
||||
end
|
||||
|
||||
def account_has_exclude_domains_cache?
|
||||
Rails.cache.exist?("exclude_domains_for:#{account.id}")
|
||||
end
|
||||
end
|
||||
@@ -36,16 +36,15 @@ RSpec.describe Follow do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'recent' do
|
||||
it 'sorts so that more recent follows comes earlier' do
|
||||
follow0 = described_class.create!(account: alice, target_account: bob)
|
||||
follow1 = described_class.create!(account: bob, target_account: alice)
|
||||
describe '.recent' do
|
||||
let!(:follow_earlier) { Fabricate(:follow) }
|
||||
let!(:follow_later) { Fabricate(:follow) }
|
||||
|
||||
a = described_class.recent.to_a
|
||||
it 'sorts with most recent follows first' do
|
||||
results = described_class.recent
|
||||
|
||||
expect(a.size).to eq 2
|
||||
expect(a[0]).to eq follow1
|
||||
expect(a[1]).to eq follow0
|
||||
expect(results.size).to eq 2
|
||||
expect(results).to eq [follow_later, follow_earlier]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -8,11 +8,6 @@ RSpec.describe Import do
|
||||
let(:data) { attachment_fixture('imports.txt') }
|
||||
|
||||
describe 'validations' do
|
||||
it 'has a valid parameters' do
|
||||
import = described_class.create(account: account, type: type, data: data)
|
||||
expect(import).to be_valid
|
||||
end
|
||||
|
||||
it 'is invalid without an type' do
|
||||
import = described_class.create(account: account, data: data)
|
||||
expect(import).to model_have_error_on_field(:type)
|
||||
|
||||
@@ -31,14 +31,6 @@ describe Poll do
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
context 'when valid' do
|
||||
let(:poll) { Fabricate.build(:poll) }
|
||||
|
||||
it 'is valid with valid attributes' do
|
||||
expect(poll).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not valid' do
|
||||
let(:poll) { Fabricate.build(:poll, expires_at: nil) }
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ RSpec.describe WebauthnCredential do
|
||||
expect(webauthn_credential).to model_have_error_on_field(:sign_count)
|
||||
end
|
||||
|
||||
it 'is invalid if sign_count is greater 2**63 - 1' do
|
||||
webauthn_credential = Fabricate.build(:webauthn_credential, sign_count: 2**63)
|
||||
it 'is invalid if sign_count is greater than the limit' do
|
||||
webauthn_credential = Fabricate.build(:webauthn_credential, sign_count: (described_class::SIGN_COUNT_LIMIT * 2))
|
||||
|
||||
webauthn_credential.valid?
|
||||
|
||||
Reference in new issue
Block a user