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
Privacy: teacher sign-up now requires email opt-in #22379
Privacy: teacher sign-up now requires email opt-in #22379
Conversation
While the opt-in is written to EmailPreference, and not to User, we rely on the User model to do the validation of this attribute so that the teacher sign-up UI can still show error messages for all the validation failures each time a submit is attempted. Because there might be other ways to create a User, the teacher sign-up UI's controller passes an additional parameter to the User object indicating that email preference opt-in is required.
Still need to add tests but wanted to share what's working so far. |
@@ -12,7 +12,8 @@ class RegistrationsControllerTest < ActionController::TestCase | |||
email: 'an@email.address', | |||
gender: 'F', | |||
age: '13', | |||
user_type: 'student' | |||
user_type: 'student', | |||
email_preference_opt_in: 'yes' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to work out why this is necessary given that we're not setting email_preference_opt_in_required: true
at the same time.
Unit tests now added. Ready for review. |
@@ -208,6 +208,20 @@ class User < ActiveRecord::Base | |||
|
|||
after_create :associate_with_potential_pd_enrollments | |||
|
|||
after_create :save_email_preference, if: -> {!email_preference_opt_in.nil?} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer if: -> {email_preference_opt_in.present?}
|
||
email_preference = EmailPreference.last | ||
assert_equal "an@email.address", email_preference[:email] | ||
assert_equal true, email_preference[:opt_in] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note this can just be assert email_preference[:opt_in]
|
||
email_preference = EmailPreference.last | ||
assert_equal "an@email.address", email_preference[:email] | ||
assert_equal false, email_preference[:opt_in] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be refute email_preference[:opt_in]
While the opt-in is written to EmailPreference, and not to User, we rely on the User model to do the validation of this attribute so that the teacher sign-up UI can still show error messages for all the validation failures each time a submit is attempted. Because there might be other ways to create a User, the teacher sign-up UI's controller passes an additional parameter to the User object indicating that email preference opt-in is required.
This is a followup to #22283
Huge thanks to @aoby for help on this.
on teacher sign-up
and when not filled out during submit