mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Guardian#can_remove_allowed_users? shouldn't break for ownerless topics
A topic can outlive its original author. TopicGuardian should still work in this situation.
This commit is contained in:
@@ -3503,6 +3503,21 @@ describe Guardian do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "anonymous users" do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
|
||||
it 'should be false' do
|
||||
expect(Guardian.new.can_remove_allowed_users?(topic)).to eq(false)
|
||||
end
|
||||
|
||||
it 'should be false when the topic does not have a user (for example because the user was removed)' do
|
||||
DB.exec("UPDATE topics SET user_id=NULL WHERE id=#{topic.id}")
|
||||
topic.reload
|
||||
|
||||
expect(Guardian.new.can_remove_allowed_users?(topic)).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#auth_token' do
|
||||
|
||||
Reference in New Issue
Block a user