Commit 0cbf4788 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'unsubscribed_email' into 'master'

Unsubscribed email and doc update

Fixes #152

/cc @jacobvosmaer @job @sytse

See merge request !159
parents ea5bdd84 b51b5d3e
v 7.3.0 v 7.3.0
- Add an option to change the LDAP sync time from default 1 hour - Add an option to change the LDAP sync time from default 1 hour
- User will receive an email when unsubscribed from admin notifications
v 7.2.0 v 7.2.0
- Improve Redmine integration - Improve Redmine integration
......
...@@ -10,7 +10,10 @@ class UnsubscribesController < ApplicationController ...@@ -10,7 +10,10 @@ class UnsubscribesController < ApplicationController
def create def create
@user = get_user @user = get_user
@user.admin_unsubscribe! if @user if @user
@user.admin_unsubscribe!
Notify.send_unsubscribed_notification(@user).deliver
end
redirect_to new_user_session_path, notice: 'You have been unsubscribed' redirect_to new_user_session_path, notice: 'You have been unsubscribed'
end end
......
...@@ -6,5 +6,10 @@ module Emails ...@@ -6,5 +6,10 @@ module Emails
@body = body @body = body
mail to: email, subject: subject mail to: email, subject: subject
end end
def send_unsubscribed_notification(user_id)
email = recipient(user_id)
mail to: email, subject: "Unsubscribed from GitLab administrator notifications"
end
end end
end end
%p
You have been unsubscribed from receiving GitLab administrator notifications.
You have been unsubscribed from receiving GitLab administrator notifications.
...@@ -13,3 +13,10 @@ Here you can simply compose an email. ...@@ -13,3 +13,10 @@ Here you can simply compose an email.
Which will be sent to all users or users of a chosen group or project. Which will be sent to all users or users of a chosen group or project.
![recipients](email3.png) ![recipients](email3.png)
## Note
User can choose to unsubscribe from receiving emails from GitLab by following the unsubscribe link from the email.
Unsubscribing is unauthenticated in order to keep the simplicity of this feature.
On unsubscribe, user will receive an email notifying that unsubscribe happened.
Endpoint that provides unsubscribe option is protected by request being rate-limited.
...@@ -9,3 +9,9 @@ Feature: Admin email ...@@ -9,3 +9,9 @@ Feature: Admin email
When I submit form with email notification info When I submit form with email notification info
Then I should see a notification email is begin sent Then I should see a notification email is begin sent
And admin emails are being sent And admin emails are being sent
Scenario: Create a new email notification
Given I visit unsubscribe from admin notification page
When I click unsubscribe
Then I get redirected to the sign in path
And unsubscribed email is sent
...@@ -29,4 +29,23 @@ class Spinach::Features::AdminEmail < Spinach::FeatureSteps ...@@ -29,4 +29,23 @@ class Spinach::Features::AdminEmail < Spinach::FeatureSteps
mail = ActionMailer::Base.deliveries.last mail = ActionMailer::Base.deliveries.last
expect(mail.text_part.body.decoded).to include @email_text expect(mail.text_part.body.decoded).to include @email_text
end end
step 'I visit unsubscribe from admin notification page' do
@user = create(:user)
urlsafe_email = Base64.urlsafe_encode64(@user.email)
visit unsubscribe_path(urlsafe_email)
end
step 'I click unsubscribe' do
click_button 'Unsubscribe'
end
step 'I get redirected to the sign in path' do
current_path.should == root_path
end
step 'unsubscribed email is sent' do
mail = ActionMailer::Base.deliveries.last
expect(mail.text_part.body.decoded).to include "You have been unsubscribed from receiving GitLab administrator notifications."
end
end end
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