A platform for community discussion. Free, open, simple.
FEATURE: bypass topic bump when disable_category_edit_notifications is enabled (#14754)
Jean92f4cdd3309d
diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rbindex 099cc16c751..c2d98ae5d0d 100644--- a/app/controllers/topics_controller.rb+++ b/app/controllers/topics_controller.rb@@ -387,8 +387,11 @@ class TopicsController < ApplicationControllersuccess = trueif changes.length > 0++ bypass_bump = changes[:category_id].present? && SiteSetting.disable_category_edit_notifications+first_post = topic.ordered_posts.first- success = PostRevisor.new(first_post, topic).revise!(current_user, changes, validate_post: false)+ success = PostRevisor.new(first_post, topic).revise!(current_user, changes, validate_post: false, bypass_bump: bypass_bump)if !success && topic.errors.blank?topic.errors.add(:base, :unable_to_update)diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rbindex 2aa3b858b2f..0171366710e 100644--- a/spec/requests/topics_controller_spec.rb+++ b/spec/requests/topics_controller_spec.rb@@ -1358,6 +1358,37 @@ RSpec.describe TopicsController doexpect(response.status).to eq(200)end+ context 'when using SiteSetting.disable_category_edit_notifications' do+ it "doesn't bump the topic if the setting is enabled" do+ SiteSetting.disable_category_edit_notifications = true+ last_bumped_at = topic.bumped_at+ expect(last_bumped_at).not_to be_nil++ expect do+ put "/t/#{topic.slug}/#{topic.id}.json", params: {+ category_id: category.id+ }+ end.to change { topic.reload.category_id }.to(category.id)++ expect(response.status).to eq(200)+ expect(topic.reload.bumped_at).to eq_time(last_bumped_at)+ end++ it "bumps the topic if the setting is disabled" do+ last_bumped_at = topic.bumped_at+ expect(last_bumped_at).not_to be_nil++ expect do+ put "/t/#{topic.slug}/#{topic.id}.json", params: {+ category_id: category.id+ }+ end.to change { topic.reload.category_id }.to(category.id)++ expect(response.status).to eq(200)+ expect(topic.reload.bumped_at).not_to eq_time(last_bumped_at)+ end+ end+describe "when first post is locked" doit "blocks non-staff from editing even if 'trusted_users_can_edit_others' is true" doSiteSetting.trusted_users_can_edit_others = true