From da0e37512a100bf9daf9d26b5f10dfdeaf5842aa Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 1 May 2019 11:36:48 -0400 Subject: [PATCH] FIX: Add test to confirm updating category works. Also replaces a missing translation key that 99.9% of users would never see. --- config/locales/server.en.yml | 2 ++ lib/reviewable/actions.rb | 1 + spec/models/reviewable_spec.rb | 11 +++++++++++ 3 files changed, 14 insertions(+) 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