Skip to content

Commit

Permalink
Don't allow spaces in external billing id
Browse files Browse the repository at this point in the history
  • Loading branch information
pacodelaluna committed Jan 19, 2025
1 parent 33f7d8d commit dbb2515
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/enterprise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/models/enterprise_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dbb2515

Please sign in to comment.