diff --git a/app/models/account.rb b/app/models/account.rb index 7321cff3db..6258857b1b 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -119,11 +119,11 @@ class Account < ApplicationRecord validates :note, note_length: { maximum: NOTE_LENGTH_LIMIT }, if: -> { local? && will_save_change_to_note? } validates :fields, length: { maximum: DEFAULT_FIELDS_SIZE }, if: -> { local? && will_save_change_to_fields? } validates_with EmptyProfileFieldNamesValidator, if: -> { local? && will_save_change_to_fields? } - with_options on: :create do - validates :uri, absence: true, if: :local? - validates :inbox_url, absence: true, if: :local? - validates :shared_inbox_url, absence: true, if: :local? - validates :followers_url, absence: true, if: :local? + with_options on: :create, if: :local? do + validates :followers_url, absence: true + validates :inbox_url, absence: true + validates :shared_inbox_url, absence: true + validates :uri, absence: true end normalizes :username, with: ->(username) { username.squish } diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 3e9b36652f..5b995b4af6 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -595,6 +595,11 @@ RSpec.describe Account do it { is_expected.to allow_value(fields_empty_name_value).for(:fields) } it { is_expected.to_not allow_values(fields_over_limit, fields_empty_name).for(:fields) } + + it { is_expected.to validate_absence_of(:followers_url).on(:create) } + it { is_expected.to validate_absence_of(:inbox_url).on(:create) } + it { is_expected.to validate_absence_of(:shared_inbox_url).on(:create) } + it { is_expected.to validate_absence_of(:uri).on(:create) } end context 'when account is remote' do