]> cat aescling's git repositories - mastodon.git/blob - spec/models/block_spec.rb
Revert "improve status title (#8596)" (#13591)
[mastodon.git] / spec / models / block_spec.rb
1 require 'rails_helper'
2
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
8 end
9
10 it 'is invalid without an account' do
11 block = Fabricate.build(:block, account: nil)
12 block.valid?
13 expect(block).to model_have_error_on_field(:account)
14 end
15
16 it 'is invalid without a target_account' do
17 block = Fabricate.build(:block, target_account: nil)
18 block.valid?
19 expect(block).to model_have_error_on_field(:target_account)
20 end
21 end
22
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}", [])
28
29 Block.create!(account: account, target_account: target_account)
30
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
33 end
34
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])
41
42 block.destroy!
43
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
46 end
47 end
This page took 0.096364 seconds and 4 git commands to generate.