diff options
author | Maximiliano Perez Coto <maxi@assembla.com> | 2016-07-13 20:56:54 -0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-20 09:52:57 +0200 |
commit | b335730817e096bb4c68e5e4a4a2a3ec29b25243 (patch) | |
tree | 58e66bb4c97f139d68def7183fb7089166c5670f /spec/features/unsubscribe_links_spec.rb | |
parent | 95b9421ad3b2678da6e0af0131eafd52cdd0b2a5 (diff) | |
download | gitlab-ce-b335730817e096bb4c68e5e4a4a2a3ec29b25243.tar.gz |
Fix "Unsubscribe" link in notification emails that is triggered by anti-virus
* Created a force=true param that will continue with the previous
behaviour of the unsubscribe method
* Created a filter for not-logged users so they see a unsubsribe
confirmation page
* Added the List-Unsubscribe header on emails so the email client can
display it on top
Diffstat (limited to 'spec/features/unsubscribe_links_spec.rb')
-rw-r--r-- | spec/features/unsubscribe_links_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/features/unsubscribe_links_spec.rb b/spec/features/unsubscribe_links_spec.rb new file mode 100644 index 00000000000..eafad1a726d --- /dev/null +++ b/spec/features/unsubscribe_links_spec.rb @@ -0,0 +1,54 @@ +require 'spec_helper' + +describe 'Unsubscribe links', feature: true do + include Warden::Test::Helpers + + let(:recipient) { create(:user) } + let(:author) { create(:user) } + let(:project) { create(:empty_project, :public) } + let(:params) { { title: 'A bug!', description: 'Fix it!', assignee: recipient } } + let(:issue) { Issues::CreateService.new(project, author, params).execute } + + let(:mail) { ActionMailer::Base.deliveries.last } + let(:body) { Capybara::Node::Simple.new(mail.default_part_body.to_s) } + let(:header_link) { mail.header['List-Unsubscribe'] } + let(:body_link) { body.find_link('unsubscribe')['href'] } + + before do + perform_enqueued_jobs { issue } + end + + context 'when logged out' do + it 'redirects to the login page when visiting the link from the body' do + visit body_link + + expect(current_path).to eq new_user_session_path + expect(issue.subscribed?(recipient)).to be_truthy + end + + it 'unsubscribes from the issue when visiting the link from the header' do + visit header_link + + expect(page).to have_text('unsubscribed') + expect(issue.subscribed?(recipient)).to be_falsey + end + end + + context 'when logged in' do + before { login_as(recipient) } + + it 'unsubscribes from the issue when visiting the link from the email body' do + visit body_link + + expect(page).to have_text('unsubscribed') + expect(issue.subscribed?(recipient)).to be_falsey + end + + it 'unsubscribes from the issue when visiting the link from the header' do + visit header_link + + expect(page).to have_text('unsubscribed') + expect(issue.subscribed?(recipient)).to be_falsey + end + end +end |