Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not allow spaces in external billing #13081

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pacodelaluna
Copy link
Contributor

@pacodelaluna pacodelaluna commented Jan 19, 2025

⚠️ when working on this use #12942 Invoicing ID clockify code

What? Why?

I forgot to add a basic validation on the external_billing_id field on my last PR.

What should we test?

  • Visit an enterprise page as superadmin
  • Try to change the External Billing Id field on Primary Details tab
  • Verify that adding a space on the value is failing the form submission

Release notes

  • Do not allow spaces in external billing id on enterprises

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

@pacodelaluna pacodelaluna force-pushed the do-not-allow-spaces-in-external-billing-id branch from dbb2515 to 39825a9 Compare January 19, 2025 19:57
@rioug rioug added the user facing changes Thes pull requests affect the user experience label Jan 20, 2025
Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you address the rubocop warning ?

@pacodelaluna
Copy link
Contributor Author

@rioug I have requested the merge of the last master changes, and it seems that the Rubocop warning is gone, but now I have a test failing, it seems to be a flaky one. Do you know waht to do in this case? Can I trigger the checks without pushing a commit?

@rioug
Copy link
Collaborator

rioug commented Jan 27, 2025

Can I trigger the checks without pushing a commit?

On your fork you should be able to, but probably not in the OFN repo, but I can :) All good now, thanks !

Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@@ -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/ },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't familiar with the \A or \Z, so I tested this out. A website like regexr.com is really handy for testing and perfecting regular expressions.

I don't think this is what was intended, and it would always be considered invalid. Can you please add at least one other test to ensure that a valid Billing ID is validated correctly.

Screenshot 2025-01-28 at 12 47 40 pm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it seems I messed up with the regex, not sure how the tests is passing... I will update with a standard one : /^\S+$/.
image

@@ -127,6 +127,9 @@
message: Spree.t('errors.messages.invalid_instagram_url')
}, allow_blank: true
validate :validate_white_label_logo_link
validates :external_billing_id,
format: { with: /^\S+$/ },

Check failure

Code scanning / Brakeman

Insufficient validation for external_billing_id using /^\S+$/. Use \A and \z as anchors. Error

Insufficient validation for external\_billing\_id using /^\S+$/. Use \A and \z as anchors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user facing changes Thes pull requests affect the user experience
Projects
Status: In Progress ⚙
Development

Successfully merging this pull request may close these issues.

Don't allow spaces in external billing id
3 participants