Commit a119c16f authored by Alex Buijs's avatar Alex Buijs

Add user setting for opting into marketing emails

Used for determining whether to send marketing emails
parent d4e96792
...@@ -42,6 +42,7 @@ export default class Profile { ...@@ -42,6 +42,7 @@ export default class Profile {
$('#user_notification_email').on('select2-selecting', (event) => { $('#user_notification_email').on('select2-selecting', (event) => {
setTimeout(this.submitForm.bind(event.currentTarget)); setTimeout(this.submitForm.bind(event.currentTarget));
}); });
$('#user_email_opted_in').on('change', this.submitForm);
$('#user_notified_of_own_activity').on('change', this.submitForm); $('#user_notified_of_own_activity').on('change', this.submitForm);
this.form.on('submit', this.onSubmitForm); this.form.on('submit', this.onSubmitForm);
} }
......
...@@ -29,7 +29,7 @@ class Profiles::NotificationsController < Profiles::ApplicationController ...@@ -29,7 +29,7 @@ class Profiles::NotificationsController < Profiles::ApplicationController
end end
def user_params def user_params
params.require(:user).permit(:notification_email, :notified_of_own_activity) params.require(:user).permit(:notification_email, :email_opted_in, :notified_of_own_activity)
end end
private private
......
...@@ -4,3 +4,7 @@ ...@@ -4,3 +4,7 @@
= form.select :notification_email, @user.public_verified_emails, { include_blank: false }, class: "select2", disabled: local_assigns.fetch(:email_change_disabled, nil) = form.select :notification_email, @user.public_verified_emails, { include_blank: false }, class: "select2", disabled: local_assigns.fetch(:email_change_disabled, nil)
.help-block .help-block
= local_assigns.fetch(:help_text, nil) = local_assigns.fetch(:help_text, nil)
.form-group
%label{ for: 'user_email_opted_in' }
= form.check_box :email_opted_in
%span= _('Receive product marketing emails')
---
title: Add user setting for opting into marketing emails
merge_request: 53921
author:
type: added
...@@ -56,6 +56,8 @@ Your **Global notification settings** are the default settings unless you select ...@@ -56,6 +56,8 @@ Your **Global notification settings** are the default settings unless you select
- This is the email address your notifications are sent to. - This is the email address your notifications are sent to.
- Global notification level - Global notification level
- This is the default [notification level](#notification-levels) which applies to all your notifications. - This is the default [notification level](#notification-levels) which applies to all your notifications.
- Receive product marketing emails
- Check this checkbox if you want to receive periodic emails related to GitLab features.
- Receive notifications about your own activity. - Receive notifications about your own activity.
- Check this checkbox if you want to receive notification about your own activity. Default: Not checked. - Check this checkbox if you want to receive notification about your own activity. Default: Not checked.
......
...@@ -24060,6 +24060,9 @@ msgstr "" ...@@ -24060,6 +24060,9 @@ msgstr ""
msgid "Receive notifications about your own activity" msgid "Receive notifications about your own activity"
msgstr "" msgstr ""
msgid "Receive product marketing emails"
msgstr ""
msgid "Recent" msgid "Recent"
msgstr "" msgstr ""
......
...@@ -119,10 +119,11 @@ RSpec.describe Profiles::NotificationsController do ...@@ -119,10 +119,11 @@ RSpec.describe Profiles::NotificationsController do
it 'updates only permitted attributes' do it 'updates only permitted attributes' do
sign_in(user) sign_in(user)
put :update, params: { user: { notification_email: 'new@example.com', notified_of_own_activity: true, admin: true } } put :update, params: { user: { notification_email: 'new@example.com', email_opted_in: true, notified_of_own_activity: true, admin: true } }
user.reload user.reload
expect(user.notification_email).to eq('new@example.com') expect(user.notification_email).to eq('new@example.com')
expect(user.email_opted_in).to eq(true)
expect(user.notified_of_own_activity).to eq(true) expect(user.notified_of_own_activity).to eq(true)
expect(user.admin).to eq(false) expect(user.admin).to eq(false)
expect(controller).to set_flash[:notice].to('Notification settings saved') expect(controller).to set_flash[:notice].to('Notification settings saved')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment