mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 22:50:45 +08:00
FIX: Unsubscribing via key associated with deleted topic (#20275)
Currently, clicking on the unsubscribe link with a `key` associated with a deleted topic results in an HTTP 500 response. This change fixes that by skipping any attempt to run topic related flow if topic isn't present.
This commit is contained in:
parent
9704d9aed6
commit
5a6e5a4012
|
@ -8,6 +8,8 @@ module EmailControllerHelper
|
|||
|
||||
topic = unsubscribe_key.associated_topic
|
||||
|
||||
return if topic.blank?
|
||||
|
||||
controller.instance_variable_set(:@topic, topic)
|
||||
controller.instance_variable_set(
|
||||
:@watching_topic,
|
||||
|
|
|
@ -317,6 +317,15 @@ RSpec.describe EmailController do
|
|||
expect(response.body).not_to include("unwatch_category")
|
||||
end
|
||||
|
||||
it "displays form even if topic is deleted" do
|
||||
post.topic.trash!
|
||||
|
||||
navigate_to_unsubscribe
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.body).to include(I18n.t("unsubscribe.all", sitename: SiteSetting.title))
|
||||
end
|
||||
|
||||
def create_category_user(notification_level)
|
||||
CategoryUser.create!(
|
||||
user_id: user.id,
|
||||
|
|
Loading…
Reference in New Issue
Block a user