mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user