Commit 74c7f240 authored by Mario de la Ossa's avatar Mario de la Ossa

Add notification unsubscribe redirect path for epics

parent 40c725b4
class SentNotificationsController < ApplicationController class SentNotificationsController < ApplicationController
prepend EE::SentNotificationsController
skip_before_action :authenticate_user! skip_before_action :authenticate_user!
def unsubscribe def unsubscribe
...@@ -17,16 +19,20 @@ class SentNotificationsController < ApplicationController ...@@ -17,16 +19,20 @@ class SentNotificationsController < ApplicationController
flash[:notice] = "You have been unsubscribed from this thread." flash[:notice] = "You have been unsubscribed from this thread."
if current_user if current_user
case noteable redirect_to noteable_path(noteable)
when Issue
redirect_to issue_path(noteable)
when MergeRequest
redirect_to merge_request_path(noteable)
else
redirect_to root_path
end
else else
redirect_to new_user_session_path redirect_to new_user_session_path
end end
end end
def noteable_path(noteable)
case noteable
when Issue
issue_path(noteable)
when MergeRequest
merge_request_path(noteable)
else
root_path
end
end
end end
module EE
module SentNotificationsController
extend ::Gitlab::Utils::Override
private
override :noteable_path
def noteable_path(noteable)
return epic_path(noteable) if noteable.is_a?(Epic)
super
end
end
end
require 'rails_helper'
describe SentNotificationsController do
let(:user) { create(:user) }
context 'Unsubscribing from an epic' do
let(:epic) do
create(:epic, author: user) do |epic|
epic.subscriptions.create(user: user, project: nil, subscribed: true)
end
end
let(:sent_notification) { create(:sent_notification, project: nil, noteable: epic, recipient: user) }
before do
sign_in(user)
get(:unsubscribe, id: sent_notification.reply_key)
end
it 'unsubscribes the user' do
expect(epic.subscribed?(user)).to be_falsey
end
it 'sets the flash message' do
expect(controller).to set_flash[:notice].to(/unsubscribed/)
end
it 'redirects to the merge request page' do
expect(response)
.to redirect_to(group_epic_path(epic.group, epic))
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