mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
FEATURE: bypass topic bump when disable_category_edit_notifications is enabled (#14754)
This commit is contained in:
@ -387,8 +387,11 @@ class TopicsController < ApplicationController
|
|||||||
success = true
|
success = true
|
||||||
|
|
||||||
if changes.length > 0
|
if changes.length > 0
|
||||||
|
|
||||||
|
bypass_bump = changes[:category_id].present? && SiteSetting.disable_category_edit_notifications
|
||||||
|
|
||||||
first_post = topic.ordered_posts.first
|
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?
|
if !success && topic.errors.blank?
|
||||||
topic.errors.add(:base, :unable_to_update)
|
topic.errors.add(:base, :unable_to_update)
|
||||||
|
@ -1358,6 +1358,37 @@ RSpec.describe TopicsController do
|
|||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
end
|
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
|
describe "when first post is locked" do
|
||||||
it "blocks non-staff from editing even if 'trusted_users_can_edit_others' is true" do
|
it "blocks non-staff from editing even if 'trusted_users_can_edit_others' is true" do
|
||||||
SiteSetting.trusted_users_can_edit_others = true
|
SiteSetting.trusted_users_can_edit_others = true
|
||||||
|
Reference in New Issue
Block a user