FIX: display correct status on unsubscribe page (#10294)

There was a bug that even when `email_digest` was set to false but
`digest_after_minutes` was positive, we were not displaying correct
status.

In addition, the message is improved when the user is unsubscribed +
unsubscribe from all is hidden.
This commit is contained in:
Krzysztof Kotlarek
2020-07-23 16:20:10 +10:00
committed by GitHub
parent e027acd367
commit 4b053462c0
5 changed files with 47 additions and 12 deletions

View File

@ -191,6 +191,24 @@ RSpec.describe EmailController do
expect(response.body).to include(I18n.t("unsubscribe.different_user_description"))
end
it 'displays correct label when email_digests is set to false' do
user.user_option.update!(email_digests: false, digest_after_minutes: 10080)
navigate_to_unsubscribe
expect(body).to include("You are not receiving summary emails")
expect(body).to include("Don't send me any mail from Discourse")
end
it 'hides unsubscribe from all checkbox when user already unsubscribed' do
user.user_option.update!(email_digests: false, mailing_list_mode: false, email_level: 2, email_messages_level: 2)
navigate_to_unsubscribe
expect(body).to include("You are not receiving summary emails")
expect(body).not_to include("Don't send me any mail from Discourse")
end
it 'correctly handles mailing list mode' do
user.user_option.update_columns(mailing_list_mode: true)