Merge pull request #13081 from pacodelaluna/do-not-allow-spaces-in-external-billing-id

Do not allow spaces in external billing
This commit is contained in:
Filipe
2025-04-23 12:20:02 +01:00
committed by GitHub
2 changed files with 15 additions and 0 deletions

View File

@@ -133,6 +133,9 @@ class Enterprise < ApplicationRecord
message: Spree.t('errors.messages.invalid_instagram_url')
}, allow_blank: true
validate :validate_white_label_logo_link
validates :external_billing_id,
format: { with: /\A\S+\z/ },
allow_blank: true
before_validation :initialize_permalink, if: lambda { permalink.nil? }
before_validation :set_unused_address_fields

View File

@@ -415,6 +415,18 @@ RSpec.describe Enterprise do
expect(e).not_to be_valid
end
end
describe "external_billing_id" do
it "validates the external_billing_id attribute" do
e = build(:enterprise, external_billing_id: '123456')
expect(e).to be_valid
end
it "does not validate the external_billing_id attribute with spaces" do
e = build(:enterprise, external_billing_id: '123 456')
expect(e).not_to be_valid
end
end
end
describe "serialisation" do