mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 10:28:20 +08:00
FEATURE: Add Revise... option for queued post reviewable (#23454)
This commit adds a new Revise... action that can be taken for queued post reviewables. This will open a modal where the user can select a Reason from a preconfigured list (or by choosing Other..., a custom reason) and provide feedback to the user about their post. The post will be rejected still, but a PM will also be sent to the user so they have an opportunity to improve their post when they resubmit it.
This commit is contained in:
@ -125,6 +125,61 @@ RSpec.describe ReviewableQueuedPost, type: :model do
|
||||
end
|
||||
end
|
||||
|
||||
context "with revise_and_reject_post" do
|
||||
it "doesn't create the post the user intended" do
|
||||
post_count = Post.public_posts.count
|
||||
result = reviewable.perform(moderator, :revise_and_reject_post)
|
||||
expect(result.success?).to eq(true)
|
||||
expect(result.created_post).to be_nil
|
||||
expect(Post.public_posts.count).to eq(post_count)
|
||||
end
|
||||
|
||||
it "creates a private message to the creator of the post" do
|
||||
args = { revise_reason: "Duplicate", revise_feedback: "This is old news" }
|
||||
expect { reviewable.perform(moderator, :revise_and_reject_post, args) }.to change {
|
||||
Topic.where(archetype: Archetype.private_message).count
|
||||
}
|
||||
|
||||
topic = Topic.where(archetype: Archetype.private_message).last
|
||||
expect(topic.title).to eq(
|
||||
I18n.t(
|
||||
"system_messages.reviewable_queued_post_revise_and_reject.subject_template",
|
||||
topic_title: reviewable.topic.title,
|
||||
),
|
||||
)
|
||||
translation_params = {
|
||||
username: reviewable.target_created_by.username,
|
||||
topic_title: reviewable.topic.title,
|
||||
topic_url: reviewable.topic.url,
|
||||
reason: args[:revise_reason],
|
||||
feedback: args[:revise_feedback],
|
||||
original_post: reviewable.payload["raw"],
|
||||
site_name: SiteSetting.title,
|
||||
}
|
||||
expect(topic.first_post.raw.chomp).to eq(
|
||||
I18n.t(
|
||||
"system_messages.reviewable_queued_post_revise_and_reject.text_body_template",
|
||||
translation_params,
|
||||
).chomp,
|
||||
)
|
||||
end
|
||||
|
||||
it "supports sending a custom revise reason" do
|
||||
args = {
|
||||
revise_reason: "Other...",
|
||||
revise_feedback: "This is old news",
|
||||
revise_custom_reason: "Boring",
|
||||
}
|
||||
expect { reviewable.perform(moderator, :revise_and_reject_post, args) }.to change {
|
||||
Topic.where(archetype: Archetype.private_message).count
|
||||
}
|
||||
topic = Topic.where(archetype: Archetype.private_message).last
|
||||
|
||||
expect(topic.first_post.raw).not_to include("Other...")
|
||||
expect(topic.first_post.raw).to include("Boring")
|
||||
end
|
||||
end
|
||||
|
||||
context "with delete_user" do
|
||||
it "deletes the user and rejects the post" do
|
||||
other_reviewable =
|
||||
|
Reference in New Issue
Block a user