mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
FIX: Don't allow users to edit topic information when the OP is locked
see: https://meta.discourse.org/t/user-able-to-edit-title-of-locked-post/104826
This commit is contained in:
parent
6fec4982d9
commit
e8b9f38374
@ -97,7 +97,9 @@ module TopicGuardian
|
||||
)
|
||||
|
||||
return false if topic.archived
|
||||
is_my_own?(topic) && !topic.edit_time_limit_expired?
|
||||
is_my_own?(topic) &&
|
||||
!topic.edit_time_limit_expired? &&
|
||||
!Post.where(topic_id: topic.id, post_number: 1).where.not(locked_by_id: nil).exists?
|
||||
end
|
||||
|
||||
# Recovery Method
|
||||
|
@ -1419,6 +1419,16 @@ describe Guardian do
|
||||
expect(Guardian.new(coding_horror).can_edit?(topic)).to be_falsey
|
||||
end
|
||||
|
||||
context "locked" do
|
||||
let(:post) { Fabricate(:post, locked_by_id: admin.id) }
|
||||
let(:topic) { post.topic }
|
||||
|
||||
it "doesn't allow users to edit locked topics" do
|
||||
expect(Guardian.new(topic.user).can_edit?(topic)).to eq(false)
|
||||
expect(Guardian.new(admin).can_edit?(topic)).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not archived' do
|
||||
it 'returns true as a moderator' do
|
||||
expect(Guardian.new(moderator).can_edit?(topic)).to eq(true)
|
||||
|
Loading…
Reference in New Issue
Block a user