diff options
author | Zeger-Jan van de Weg <mail@zjvandeweg.nl> | 2016-01-09 19:32:03 +0100 |
---|---|---|
committer | Zeger-Jan van de Weg <mail@zjvandeweg.nl> | 2016-01-09 19:32:03 +0100 |
commit | 26cedc7e0bd83fc488da3a4dc5265d395639215f (patch) | |
tree | d50a46a486267e84ff112d4745c89757be1b6d49 | |
parent | 36d858bcf98868426256ce51a28e7029b38e0c2d (diff) | |
download | gitlab-ce-26cedc7e0bd83fc488da3a4dc5265d395639215f.tar.gz |
Minor improvements, unsubscribe from email footer
-rw-r--r-- | app/controllers/sent_notifications_controller.rb | 4 | ||||
-rw-r--r-- | app/mailers/emails/notes.rb | 8 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 32 |
4 files changed, 23 insertions, 23 deletions
diff --git a/app/controllers/sent_notifications_controller.rb b/app/controllers/sent_notifications_controller.rb index 93dcc16094f..b7008c82bf2 100644 --- a/app/controllers/sent_notifications_controller.rb +++ b/app/controllers/sent_notifications_controller.rb @@ -3,14 +3,14 @@ class SentNotificationsController < ApplicationController def unsubscribe @sent_notification = SentNotification.for(params[:id]) - return render_404 unless @sent_notification && !@sent_notification.for_commit? + return render_404 unless @sent_notification && @sent_notification.can_unsubscribe? noteable = @sent_notification.noteable noteable.unsubscribe(@sent_notification.recipient) flash[:notice] = "You have been unsubscribed from this thread." if current_user - case @sent_notification.noteable + case noteable when Issue redirect_to issue_path(noteable) when MergeRequest diff --git a/app/mailers/emails/notes.rb b/app/mailers/emails/notes.rb index ccd33b880f7..f9650df9a74 100644 --- a/app/mailers/emails/notes.rb +++ b/app/mailers/emails/notes.rb @@ -1,7 +1,7 @@ module Emails module Notes def note_commit_email(recipient_id, note_id) - note_mail_with_notification(note_id, recipient_id) + setup_note_mail(note_id, recipient_id) @commit = @note.noteable @target_url = namespace_project_commit_url(*note_target_url_options) @@ -13,7 +13,7 @@ module Emails end def note_issue_email(recipient_id, note_id) - note_mail_with_notification(note_id, recipient_id) + setup_note_mail(note_id, recipient_id) @issue = @note.noteable @target_url = namespace_project_issue_url(*note_target_url_options) @@ -21,7 +21,7 @@ module Emails end def note_merge_request_email(recipient_id, note_id) - note_mail_with_notification(note_id, recipient_id) + setup_note_mail(note_id, recipient_id) @merge_request = @note.noteable @target_url = namespace_project_merge_request_url(*note_target_url_options) @@ -42,7 +42,7 @@ module Emails } end - def note_mail_with_notification(note_id, recipient_id) + def setup_note_mail(note_id, recipient_id) @note = Note.find(note_id) @project = @note.project diff --git a/config/routes.rb b/config/routes.rb index 2739e4961f7..0fd72ae78eb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -88,7 +88,7 @@ Rails.application.routes.draw do end end - resources :sent_notifications, only: [], constraints: { id: /[0-9a-f]{32}/ } do + resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do member do get :unsubscribe end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 08ade644643..8f86c491d3f 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -108,7 +108,7 @@ describe Notify do it { is_expected.to have_body_text /unsubscribe/ } end - shared_examples "a user can not unsubscribe through footer link" do + shared_examples "a user cannot unsubscribe through footer link" do it { is_expected.not_to have_body_text /unsubscribe/ } end @@ -123,7 +123,7 @@ describe Notify do it_behaves_like 'an email sent from GitLab' it_behaves_like 'a new user email', new_user_address it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like 'a user can not unsubscribe through footer link' + it_behaves_like 'a user cannot unsubscribe through footer link' it 'contains the password text' do is_expected.to have_body_text /Click here to set your password/ @@ -152,7 +152,7 @@ describe Notify do it_behaves_like 'an email sent from GitLab' it_behaves_like 'a new user email', new_user_address it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like 'a user can not unsubscribe through footer link' + it_behaves_like 'a user cannot unsubscribe through footer link' it 'should not contain the new user\'s password' do is_expected.not_to have_body_text /password/ @@ -166,7 +166,7 @@ describe Notify do it_behaves_like 'an email sent from GitLab' it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like 'a user can not unsubscribe through footer link' + it_behaves_like 'a user cannot unsubscribe through footer link' it 'is sent to the new user' do is_expected.to deliver_to key.user.email @@ -191,7 +191,7 @@ describe Notify do subject { Notify.new_email_email(email.id) } it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like 'a user can not unsubscribe through footer link' + it_behaves_like 'a user cannot unsubscribe through footer link' it 'is sent to the new user' do is_expected.to deliver_to email.user.email @@ -465,7 +465,7 @@ describe Notify do it_behaves_like 'an email sent from GitLab' it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'has the correct subject' do is_expected.to have_subject /Project was moved/ @@ -488,7 +488,7 @@ describe Notify do it_behaves_like 'an email sent from GitLab' it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'has the correct subject' do is_expected.to have_subject /Access to project was granted/ @@ -539,7 +539,7 @@ describe Notify do it_behaves_like 'a note email' it_behaves_like 'an answer to an existing thread', 'commit' it_behaves_like 'it should show Gmail Actions View Commit link' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'has the correct subject' do is_expected.to have_subject /#{commit.title} \(#{commit.short_id}\)/ @@ -603,7 +603,7 @@ describe Notify do it_behaves_like 'an email sent from GitLab' it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'has the correct subject' do is_expected.to have_subject /Access to group was granted/ @@ -632,7 +632,7 @@ describe Notify do subject { ActionMailer::Base.deliveries.last } it_behaves_like 'an email sent from GitLab' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'is sent to the new user' do is_expected.to deliver_to 'new-email@mail.com' @@ -655,7 +655,7 @@ describe Notify do subject { Notify.repository_push_email(project.id, 'devs@company.name', author_id: user.id, ref: 'refs/heads/master', action: :create) } it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -684,7 +684,7 @@ describe Notify do subject { Notify.repository_push_email(project.id, 'devs@company.name', author_id: user.id, ref: 'refs/tags/v1.0', action: :create) } it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -712,7 +712,7 @@ describe Notify do subject { Notify.repository_push_email(project.id, 'devs@company.name', author_id: user.id, ref: 'refs/heads/master', action: :delete) } it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -736,7 +736,7 @@ describe Notify do subject { Notify.repository_push_email(project.id, 'devs@company.name', author_id: user.id, ref: 'refs/tags/v1.0', action: :delete) } it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -764,7 +764,7 @@ describe Notify do subject { Notify.repository_push_email(project.id, 'devs@company.name', author_id: user.id, ref: 'refs/heads/master', action: :push, compare: compare, reverse_compare: false, send_from_committer_email: send_from_committer_email) } it_behaves_like 'it should not have Gmail Actions links' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -870,7 +870,7 @@ describe Notify do subject { Notify.repository_push_email(project.id, 'devs@company.name', author_id: user.id, ref: 'refs/heads/master', action: :push, compare: compare) } it_behaves_like 'it should show Gmail Actions View Commit link' - it_behaves_like "a user can not unsubscribe through footer link" + it_behaves_like "a user cannot unsubscribe through footer link" it 'is sent as the author' do sender = subject.header[:from].addrs[0] |