From 6d2f865862dcadcc6046c2b81df25e51bae134a0 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 23 Oct 2024 02:39:19 -0400 Subject: [PATCH] Add coverage for `AccountAlias` validations (#31936) --- spec/models/account_alias_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/models/account_alias_spec.rb b/spec/models/account_alias_spec.rb index fc8c6bd250..17c83967a4 100644 --- a/spec/models/account_alias_spec.rb +++ b/spec/models/account_alias_spec.rb @@ -8,4 +8,26 @@ RSpec.describe AccountAlias do it { is_expected.to normalize(:acct).from(' @username@domain ').to('username@domain') } end end + + describe 'Validations' do + subject { described_class.new(account:) } + + let(:account) { Fabricate :account } + + it { is_expected.to_not allow_values(nil, '').for(:uri).against(:acct).with_message(not_found_message) } + + it { is_expected.to_not allow_values(account_uri).for(:uri).against(:acct).with_message(self_move_message) } + + def account_uri + ActivityPub::TagManager.instance.uri_for(subject.account) + end + + def not_found_message + I18n.t('migrations.errors.not_found') + end + + def self_move_message + I18n.t('migrations.errors.move_to_self') + end + end end