mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FIX: Respect the cooldown window when editing a flagged topic. (#16046)
When staff decides to hide a flagged post, and it's the first post on the topic, the post owner shouldn't be able to edit either of them until the cooldown finishes. Edit either of them automatically, unhides the post, and makes the topic visible when there's a flag involved. Reported on meta: https://meta.discourse.org/t/users-can-edit-flagged-topic-title-when-they-should-not-be-able-to/217796
This commit is contained in:
@ -1641,6 +1641,17 @@ describe Guardian do
|
||||
expect(Guardian.new(coding_horror).can_edit?(topic)).to be_falsey
|
||||
end
|
||||
|
||||
context 'first post is hidden' do
|
||||
let!(:topic) { Fabricate(:topic, user: user) }
|
||||
let!(:post) { Fabricate(:post, topic: topic, user: topic.user, hidden: true, hidden_at: Time.zone.now) }
|
||||
|
||||
it 'returns false for editing your own post while inside the cooldown window' do
|
||||
SiteSetting.cooldown_minutes_after_hiding_posts = 30
|
||||
|
||||
expect(Guardian.new(topic.user).can_edit?(topic)).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "locked" do
|
||||
let(:post) { Fabricate(:post, locked_by_id: admin.id) }
|
||||
let(:topic) { post.topic }
|
||||
|
Reference in New Issue
Block a user