mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:49:06 +08:00
FIX: Take action should agree with all pending flags
This commit is contained in:
parent
0fc798c2ef
commit
df1ab9259b
|
@ -89,6 +89,12 @@ class PostActionCreator
|
|||
PostActionNotifier.post_action_created(post_action)
|
||||
notify_subscribers
|
||||
|
||||
# agree with other flags
|
||||
if @take_action && reviewable = @post.reviewable_flag
|
||||
result.reviewable.perform(@created_by, :agree_and_keep)
|
||||
post_action.try(:update_counters)
|
||||
end
|
||||
|
||||
result.success = true
|
||||
result.post_action = post_action
|
||||
|
||||
|
@ -211,12 +217,6 @@ private
|
|||
|
||||
GivenDailyLike.increment_for(@created_by.id) if @post_action_type_id == PostActionType.types[:like]
|
||||
|
||||
# agree with other flags
|
||||
if @take_action && reviewable = @post.reviewable_flag
|
||||
reviewable.perform(@created_by, :agree_and_keep)
|
||||
post_action.try(:update_counters)
|
||||
end
|
||||
|
||||
post_action
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
# can happen despite being .create
|
||||
|
|
|
@ -101,4 +101,23 @@ describe PostActionCreator do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "take_action" do
|
||||
before do
|
||||
PostActionCreator.create(Fabricate(:user), post, :inappropriate)
|
||||
end
|
||||
|
||||
it "will agree with the old reviewable" do
|
||||
reviewable = PostActionCreator.new(
|
||||
Fabricate(:moderator),
|
||||
post,
|
||||
PostActionType.types[:spam],
|
||||
take_action: true
|
||||
).perform.reviewable
|
||||
scores = reviewable.reviewable_scores
|
||||
expect(scores[0]).to be_agreed
|
||||
expect(scores[1]).to be_agreed
|
||||
expect(reviewable.reload).to be_approved
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user