From 63df649fe52e3e19a4f5514375380dd81e3e0e1f Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 15 Oct 2024 09:30:17 -0400 Subject: [PATCH] Expand coverage for `Block` model (#32480) --- spec/models/block_spec.rb | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/spec/models/block_spec.rb b/spec/models/block_spec.rb index 84f0f318f4..62d7e40e28 100644 --- a/spec/models/block_spec.rb +++ b/spec/models/block_spec.rb @@ -3,11 +3,37 @@ require 'rails_helper' RSpec.describe Block do - describe 'validations' do + describe 'Associations' do it { is_expected.to belong_to(:account).required } it { is_expected.to belong_to(:target_account).required } end + describe '#local?' do + it { is_expected.to_not be_local } + end + + describe 'Callbacks' do + describe 'Setting a URI' do + context 'when URI exists' do + subject { Fabricate.build :block, uri: 'https://uri/value' } + + it 'does not change' do + expect { subject.save } + .to not_change(subject, :uri) + end + end + + context 'when URI is blank' do + subject { Fabricate.build :follow, uri: nil } + + it 'populates the value' do + expect { subject.save } + .to change(subject, :uri).to(be_present) + end + end + end + end + it 'removes blocking cache after creation' do account = Fabricate(:account) target_account = Fabricate(:account)