Add validation spec for Form::Redirect model (#38011)

This commit is contained in:
Matt Jankowski
2026-02-27 12:05:29 -05:00
committed by GitHub
parent 7e5e96739f
commit 7f16397f3c

View File

@@ -0,0 +1,32 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Form::Redirect do
describe 'Validations' do
it { is_expected.to validate_presence_of(:acct) }
describe 'target account validation' do
subject { described_class.new(account:) }
context 'when target_account is missing' do
let(:account) { Fabricate.build :account }
it { is_expected.to_not allow_value(nil).for(:target_account).against(:acct).with_message(I18n.t('migrations.errors.not_found')) }
end
context 'when account already moved' do
let(:account) { Fabricate.build :account, moved_to_account_id: target_account.id }
let(:target_account) { Fabricate :account }
it { is_expected.to_not allow_value(target_account).for(:target_account).against(:acct).with_message(I18n.t('migrations.errors.already_moved')) }
end
context 'when moving to self' do
let(:account) { Fabricate :account }
it { is_expected.to_not allow_value(account).for(:target_account).against(:acct).with_message(I18n.t('migrations.errors.move_to_self')) }
end
end
end
end