mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:41:31 +08:00
DEV: Add a test to make sure that flagged replies are ignored when calling the delete_and_agree_replies method
This commit is contained in:
parent
0c6f2892c6
commit
17aed8d84b
|
@ -144,18 +144,8 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
|
|||
end
|
||||
|
||||
it "delete_and_ignore_replies ignores the flags and deletes post + replies" do
|
||||
reply = PostCreator.create(
|
||||
Fabricate(:user),
|
||||
raw: 'this is the reply text',
|
||||
reply_to_post_number: post.post_number,
|
||||
topic_id: post.topic_id
|
||||
)
|
||||
nested_reply = PostCreator.create(
|
||||
Fabricate(:user),
|
||||
raw: 'this is the reply text2',
|
||||
reply_to_post_number: reply.post_number,
|
||||
topic_id: post.topic_id
|
||||
)
|
||||
reply = create_reply(post)
|
||||
nested_reply = create_reply(reply)
|
||||
post.reload
|
||||
|
||||
reviewable.perform(moderator, :delete_and_ignore_replies)
|
||||
|
@ -174,18 +164,8 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
|
|||
end
|
||||
|
||||
it "delete_and_agree_replies agrees w/ the flags and deletes post + replies" do
|
||||
reply = PostCreator.create(
|
||||
Fabricate(:user),
|
||||
raw: 'this is the reply text',
|
||||
reply_to_post_number: post.post_number,
|
||||
topic_id: post.topic_id
|
||||
)
|
||||
nested_reply = PostCreator.create(
|
||||
Fabricate(:user),
|
||||
raw: 'this is the reply text2',
|
||||
reply_to_post_number: reply.post_number,
|
||||
topic_id: post.topic_id
|
||||
)
|
||||
reply = create_reply(post)
|
||||
nested_reply = create_reply(reply)
|
||||
post.reload
|
||||
|
||||
reviewable.perform(moderator, :delete_and_agree_replies)
|
||||
|
@ -287,6 +267,19 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#perform_delete_and_agree_replies" do
|
||||
it 'ignore flagged replies' do
|
||||
flagged_post = Fabricate(:reviewable_flagged_post)
|
||||
reply = create_reply(flagged_post.target)
|
||||
flagged_post.target.update(reply_count: 1)
|
||||
flagged_reply = Fabricate(:reviewable_flagged_post, target: reply)
|
||||
|
||||
flagged_post.perform(moderator, :delete_and_agree_replies)
|
||||
|
||||
expect(flagged_reply.reload.status).to eq(Reviewable.statuses[:ignored])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#perform_disagree_and_restore" do
|
||||
it "notifies the user about the flagged post being restored" do
|
||||
reviewable = Fabricate(:reviewable_flagged_post)
|
||||
|
@ -304,4 +297,13 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
|
|||
expect(job["args"][0]["user_id"]).to eq(user_id)
|
||||
expect(job["args"][0]["message_type"]).to eq(pm_type)
|
||||
end
|
||||
|
||||
def create_reply(post)
|
||||
PostCreator.create(
|
||||
Fabricate(:user),
|
||||
raw: 'this is the reply text',
|
||||
reply_to_post_number: post.post_number,
|
||||
topic_id: post.topic
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user