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

Skip online domain validation of dev user email #11321

Merged
merged 2 commits into from
Aug 7, 2023

Conversation

mkllnk
Copy link
Member

@mkllnk mkllnk commented Aug 3, 2023

What? Why?

Whenever I ran rails db:reset the default test user couldn't be created because my internet service provider doesn't resolve the example.com domain. Skipping the validation solves this.

What should we test?

  • No test.

Release notes

Changelog Category: Technical changes

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

We improved the email address validation to check the domain for
existing DNS entries. But our default user has the example.com domain
which is not resolved by my internet service provider.

I couldn't find a better way to deactivate this one check than
overriding the method in the validator. The code does not affect other
parts of the app unless you run multiple rake tasks in the same command
line with the database setup.
The `<<` operation saves the association already.
@mkllnk mkllnk self-assigned this Aug 3, 2023
@@ -58,10 +58,13 @@ def create_admin_user
admin = Spree::User.new(attributes)
admin.skip_confirmation!
admin.skip_confirmation_notification!

# The default domain example.com is not resolved by all nameservers.
ValidEmail2::Address.define_method(:valid_mx?) { true }
Copy link
Member Author

Choose a reason for hiding this comment

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

The alternative would be a new attribute on the User model to skip mx domain validation. But I decided to avoid it as long as we don't have other use cases because it would be more code in a much used class.

@mkllnk mkllnk marked this pull request as ready for review August 3, 2023 00:42
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.

👍

@rioug
Copy link
Collaborator

rioug commented Aug 7, 2023

No test required, merging.

@rioug rioug merged commit 430aa68 into openfoodfoundation:master Aug 7, 2023
50 checks passed
@mkllnk mkllnk deleted the dev-user-valid branch August 14, 2023 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants