mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-22 12:58:06 +01:00
Simplify model validation specs for AccountMigration
(#32494)
This commit is contained in:
parent
86132f7dd3
commit
15f6336cdd
1 changed files with 5 additions and 11 deletions
|
@ -9,8 +9,8 @@ RSpec.describe AccountMigration do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'validations' do
|
describe 'Validations' do
|
||||||
subject { described_class.new(account: source_account, acct: target_acct) }
|
subject { Fabricate.build :account_migration, account: source_account }
|
||||||
|
|
||||||
let(:source_account) { Fabricate(:account) }
|
let(:source_account) { Fabricate(:account) }
|
||||||
let(:target_acct) { target_account.acct }
|
let(:target_acct) { target_account.acct }
|
||||||
|
@ -26,9 +26,7 @@ RSpec.describe AccountMigration do
|
||||||
allow(service_double).to receive(:call).with(target_acct, anything).and_return(target_account)
|
allow(service_double).to receive(:call).with(target_acct, anything).and_return(target_account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'passes validations' do
|
it { is_expected.to allow_value(target_account.acct).for(:acct) }
|
||||||
expect(subject).to be_valid
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with unresolvable account' do
|
context 'with unresolvable account' do
|
||||||
|
@ -40,17 +38,13 @@ RSpec.describe AccountMigration do
|
||||||
allow(service_double).to receive(:call).with(target_acct, anything).and_return(nil)
|
allow(service_double).to receive(:call).with(target_acct, anything).and_return(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has errors on acct field' do
|
it { is_expected.to_not allow_value(target_acct).for(:acct) }
|
||||||
expect(subject).to model_have_error_on_field(:acct)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a space in the domain part' do
|
context 'with a space in the domain part' do
|
||||||
let(:target_acct) { 'target@remote. org' }
|
let(:target_acct) { 'target@remote. org' }
|
||||||
|
|
||||||
it 'has errors on acct field' do
|
it { is_expected.to_not allow_value(target_acct).for(:acct) }
|
||||||
expect(subject).to model_have_error_on_field(:acct)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue