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

Privacy: teacher sign-up now requires email opt-in #22379

Merged
merged 4 commits into from May 14, 2018

Conversation

breville
Copy link
Member

@breville breville commented May 12, 2018

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

screenshot 2018-05-14 13 33 27

and when not filled out during submit

screenshot 2018-05-14 13 32 41

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.
@breville breville requested a review from aoby May 12, 2018 20:56
@breville
Copy link
Member Author

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'
Copy link
Member Author

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.

@breville
Copy link
Member Author

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?}
Copy link
Contributor

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]
Copy link
Contributor

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]
Copy link
Contributor

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]

@breville breville merged commit 4d16f61 into staging May 14, 2018
@breville breville deleted the privacy-teacher-sign-up-optin-now-mandatory branch May 14, 2018 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants