Explore more resplendent model validation specs for Form::AdminSettings (#32465)

This commit is contained in:
Matt Jankowski 2024-10-24 08:44:13 -04:00 committed by GitHub
parent 67504dbf9c
commit b16435e79f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,33 +3,17 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Form::AdminSettings do RSpec.describe Form::AdminSettings do
describe 'validations' do describe 'Validations' do
describe 'site_contact_username' do describe 'site_contact_username' do
context 'with no accounts' do context 'with no accounts' do
it 'is not valid' do it { is_expected.to_not allow_value('Test').for(:site_contact_username) }
setting = described_class.new(site_contact_username: 'Test')
setting.valid?
expect(setting).to model_have_error_on_field(:site_contact_username)
end
end end
context 'with an account' do context 'with an account' do
before { Fabricate(:account, username: 'Glorp') } before { Fabricate(:account, username: 'Glorp') }
it 'is not valid when account doesnt match' do it { is_expected.to_not allow_value('Test').for(:site_contact_username) }
setting = described_class.new(site_contact_username: 'Test') it { is_expected.to allow_value('Glorp').for(:site_contact_username) }
setting.valid?
expect(setting).to model_have_error_on_field(:site_contact_username)
end
it 'is valid when account matches' do
setting = described_class.new(site_contact_username: 'Glorp')
setting.valid?
expect(setting).to_not model_have_error_on_field(:site_contact_username)
end
end end
end end
end end