Skip to content

A platform for community discussion. Free, open, simple.

FIX: Add test to confirm updating category works.

Robin Wardda0e37512a10
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 52e2302867e..5c4bc894bef 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -4452,6 +4452,8 @@ en:
title: "Delete Spammer"
description: "Remove the user and all their posts and topics."
confirm: "Are you sure you want to delete all that user's posts, topics, and block their IP and email addresses?"
+ delete_single:
+ title: "Delete"
delete:
title: "Delete..."
delete_and_ignore:
diff --git a/lib/reviewable/actions.rb b/lib/reviewable/actions.rb
index ae0e353f3e4..030ef673da8 100644
--- a/lib/reviewable/actions.rb
+++ b/lib/reviewable/actions.rb
@@ -15,6 +15,7 @@ class Reviewable < ActiveRecord::Base
{
approve: Action.new(:approve, 'thumbs-up', 'reviewables.actions.approve.title'),
reject: Action.new(:reject, 'thumbs-down', 'reviewables.actions.reject.title'),
+ delete: Action.new(:delete, 'trash-alt', 'reviewables.actions.delete_single.title')
}
end
diff --git a/spec/models/reviewable_spec.rb b/spec/models/reviewable_spec.rb
index c661ac25b38..fdc51e5814c 100644
--- a/spec/models/reviewable_spec.rb
+++ b/spec/models/reviewable_spec.rb
@@ -55,6 +55,17 @@ RSpec.describe Reviewable, type: :model do
expect(reviewable.category).to eq(post.topic.category)
end
+ it "will update the category if the topic category changes" do
+ post = Fabricate(:post)
+ moderator = Fabricate(:moderator)
+ reviewable = PostActionCreator.spam(moderator, post).reviewable
+ expect(reviewable.category).to eq(post.topic.category)
+ new_cat = Fabricate(:category)
+ PostRevisor.new(post).revise!(moderator, category_id: new_cat.id)
+ expect(post.topic.reload.category).to eq(new_cat)
+ expect(reviewable.reload.category).to eq(new_cat)
+ end
+
it "can create multiple objects with a NULL target" do
r0 = ReviewableQueuedPost.needs_review!(created_by: admin, payload: { raw: 'hello world I am a post' })
expect(r0).to be_present