-
Notifications
You must be signed in to change notification settings - Fork 17
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
Unsubscribe button on document collection pages #3409
Conversation
e2269fe
to
8e20744
Compare
a704091
to
a2b5c0c
Compare
This was missing from #2535
a2b5c0c
to
7135e31
Compare
7135e31
to
3370ad9
Compare
3370ad9
to
c8c3985
Compare
Document collection email subscriptions are complicated[1] The expected behaviour is: If a document collection has a taxonomy topic email override in its links, render the signup link component, and subscribe the user to the taxonomy topic instead of to the document collection itself. In all other cases, render a single page notification button. The button is a gem component, and it uses the value of the attribute `skip_account` to determine the form action of this button[2] - If the user has an active govuk-account session, the button should post to email-alert-frontend's /email/subscriptions/single-page/new endpoint. This endpoint enforces the gov.uk account[3]. - If the user is not logged into their account (or they don't have an account) then the button should post to email-alert-api's magic link endpoint, /email-signup instead. This endpoint does not enforce the govuk account. Current behaviour: Prior to this commit, we were passing skip_account = "true" to the button component on all document collection pages, and therefore hardcoding the button to post to the account free endpoint regardless of whether or not they were logged into their account. New behaviour: What this commit does, is to only set the value of skip_account to "true" for users without an active govuk-account session. Why are we making this change? For users with an existing subscription returning to a document collection page, the single page notification button doesn't allow them to unsubscribe. The button text is "Stop getting emails about this page", but instead of posting to email/subscriptions/single-page/new, which supports both subscribing AND unsubscribing[4] it is hardcoded to post to /email-signup which supports sign up only. This means they must log into their govuk accounts in order to manage their subscriptions. [1] https://docs.publishing.service.gov.uk/manual/document-collection-emails-a-special-case.html [2] https://github.com/alphagov/govuk_publishing_components/blob/main/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb#L58-L64 [3] https://github.com/alphagov/email-alert-frontend/blob/main/app/controllers/govuk_account_signups_controller.rb#L15-L17 [4] https://github.com/alphagov/email-alert-frontend/blob/main/app/controllers/govuk_account_signups_controller.rb#L27-L34
c8c3985
to
bf81934
Compare
Commit 3: I kind of forget what the equivalence is, but I think controller tests are the olde-world version of request tests, which is probably reasonable for this test case (we're not testing the actual user interaction in the test, which would make it an integration/system test, just what is returned for a specific request - ie given an account or not, does the signup control in the returned page point to the account or magic link endpoint?) |
bf81934
to
c53a907
Compare
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.
LGTM
What
Fix two issues with the email subscription signup process on Document Collection pages.
First commit: Display a flash message to confirm subscription.
This should have been added in #2535
Second commit: Fix unsubscribe button
Allow users with a gov.uk account to unsubscribe from a document collection via the single page notification button. See commit message for full explanation and links to documentation.
Trello