diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 77dcb2c1958..0a0d2fb4077 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -127,6 +127,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 diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index de519e52e84..b34121d65fc 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -415,6 +415,13 @@ expect(e).not_to be_valid end end + + describe "external_billing_id" do + it "does not validate the external_billing_id attribute with a space" do + e = build(:enterprise, external_billing_id: 'with spaces') + expect(e).not_to be_valid + end + end end describe "serialisation" do