From 6797395bd09ade259f03776749ec87ebe590a0c4 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 7 Aug 2018 10:05:43 +1000 Subject: [PATCH] FIX: staff should be allowed to agree and keep post --- app/controllers/admin/flags_controller.rb | 6 ++++-- spec/requests/admin/flags_controller_spec.rb | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/flags_controller.rb b/app/controllers/admin/flags_controller.rb index 8924cc96616..63f2ffdc247 100644 --- a/app/controllers/admin/flags_controller.rb +++ b/app/controllers/admin/flags_controller.rb @@ -83,9 +83,11 @@ class Admin::FlagsController < Admin::AdminController elsif restore_post PostAction.agree_flags!(post, current_user, delete_post) PostDestroyer.new(current_user, post).recover - elsif !keep_post + else PostAction.agree_flags!(post, current_user, delete_post) - PostAction.hide_post!(post, post_action_type) + if !keep_post + PostAction.hide_post!(post, post_action_type) + end end render body: nil diff --git a/spec/requests/admin/flags_controller_spec.rb b/spec/requests/admin/flags_controller_spec.rb index c8ebc0ea779..d252eedc775 100644 --- a/spec/requests/admin/flags_controller_spec.rb +++ b/spec/requests/admin/flags_controller_spec.rb @@ -34,7 +34,22 @@ RSpec.describe Admin::FlagsController do end context '#agree' do - it 'should work' do + it 'should be able to agree and keep content' do + SiteSetting.queue_jobs = false + + post_action = PostAction.act(user, post_1, PostActionType.types[:spam], message: 'bad') + + post "/admin/flags/agree/#{post_1.id}.json", params: { action_on_post: 'keep' } + expect(response.status).to eq(200) + + post_action.reload + expect(post_action.agreed_by_id).to eq(admin.id) + + post_1.reload + expect(post_1.deleted_at).to eq(nil) + end + + it 'should be able to hide spam' do SiteSetting.allow_user_locale = true SiteSetting.queue_jobs = false @@ -42,7 +57,6 @@ RSpec.describe Admin::FlagsController do admin.update!(locale: 'ja') post "/admin/flags/agree/#{post_1.id}.json" - expect(response.status).to eq(200) post_action.reload