]>
cat aescling's git repositories - mastodon.git/blob - spec/models/block_spec.rb
3 RSpec
.describe Block
, type
: :model do
4 describe
'validations' do
5 it
'has a valid fabricator' do
6 block
= Fabricate
.build(:block)
7 expect(block
).to be_valid
10 it
'is invalid without an account' do
11 block
= Fabricate
.build(:block, account
: nil)
13 expect(block
).to
model_have_error_on_field(:account)
16 it
'is invalid without a target_account' do
17 block
= Fabricate
.build(:block, target_account
: nil)
19 expect(block
).to
model_have_error_on_field(:target_account)
23 it
'removes blocking cache after creation' do
24 account
= Fabricate(:account)
25 target_account
= Fabricate(:account)
26 Rails
.cache
.write("exclude_account_ids_for:#{account.id}", [])
27 Rails
.cache
.write("exclude_account_ids_for:#{target_account.id}", [])
29 Block
.create!
(account
: account
, target_account
: target_account
)
31 expect(Rails
.cache
.exist
?("exclude_account_ids_for:#{account.id}")).to eq
false
32 expect(Rails
.cache
.exist
?("exclude_account_ids_for:#{target_account.id}")).to eq
false
35 it
'removes blocking cache after destruction' do
36 account
= Fabricate(:account)
37 target_account
= Fabricate(:account)
38 block
= Block
.create!
(account
: account
, target_account
: target_account
)
39 Rails
.cache
.write("exclude_account_ids_for:#{account.id}", [target_account
.id
])
40 Rails
.cache
.write("exclude_account_ids_for:#{target_account.id}", [account
.id
])
44 expect(Rails
.cache
.exist
?("exclude_account_ids_for:#{account.id}")).to eq
false
45 expect(Rails
.cache
.exist
?("exclude_account_ids_for:#{target_account.id}")).to eq
false
This page took 0.096364 seconds and 4 git commands to generate.