FEATURE: bypass topic bump when disable_category_edit_notifications is enabled (#14754)

This commit is contained in:
Jean 2021-10-27 17:05:10 -04:00 committed by GitHub
parent 5a851dec0e
commit 92f4cdd330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 1 deletions

View File

@ -387,8 +387,11 @@ class TopicsController < ApplicationController
success = true
if 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)

View File

@ -1358,6 +1358,37 @@ RSpec.describe TopicsController do
expect(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" do
it "blocks non-staff from editing even if 'trusted_users_can_edit_others' is true" do
SiteSetting.trusted_users_can_edit_others = true