mirror of
https://github.com/discourse/discourse.git
synced 2025-05-01 03:04:37 +08:00
FIX: User can't remove bookmark from a deleted post.
This commit is contained in:
parent
870c584e25
commit
8ab9f30bbd
@ -383,9 +383,11 @@ class PostsController < ApplicationController
|
|||||||
PostAction.act(current_user, post, PostActionType.types[:bookmark])
|
PostAction.act(current_user, post, PostActionType.types[:bookmark])
|
||||||
else
|
else
|
||||||
post_action = PostAction.find_by(post_id: params[:post_id], user_id: current_user.id)
|
post_action = PostAction.find_by(post_id: params[:post_id], user_id: current_user.id)
|
||||||
post = post_action&.post
|
|
||||||
raise Discourse::NotFound unless post_action
|
raise Discourse::NotFound unless post_action
|
||||||
|
|
||||||
|
post = Post.with_deleted.find_by(id: post_action&.post_id)
|
||||||
|
raise Discourse::NotFound unless post
|
||||||
|
|
||||||
PostAction.remove_act(current_user, post, PostActionType.types[:bookmark])
|
PostAction.remove_act(current_user, post, PostActionType.types[:bookmark])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -476,6 +476,17 @@ describe PostsController do
|
|||||||
expect(PostAction.find_by(id: post_action.id)).to eq(nil)
|
expect(PostAction.find_by(id: post_action.id)).to eq(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "when post has been deleted" do
|
||||||
|
it "should still be able to remove a bookmark" do
|
||||||
|
post = post_action.post
|
||||||
|
post.trash!
|
||||||
|
|
||||||
|
xhr :put, :bookmark, post_id: post.id
|
||||||
|
|
||||||
|
expect(PostAction.find_by(id: post_action.id)).to eq(nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user