FIX: Disable "Make Personal Message" if they are disabled

This commit is contained in:
Robin Ward 2018-03-02 20:28:39 -05:00
parent b11dd21356
commit cd6c5fc5fb
2 changed files with 6 additions and 0 deletions

View File

@ -84,6 +84,7 @@ module TopicGuardian
end
def can_convert_topic?(topic)
return false unless SiteSetting.enable_personal_messages?
return false if topic.blank?
return false if topic && topic.trashed?
return false if Category.where("topic_id = ?", topic.id).exists?

View File

@ -1095,6 +1095,11 @@ describe Guardian do
it 'returns true when an admin' do
expect(Guardian.new(admin).can_convert_topic?(topic)).to be_truthy
end
it 'returns false when personal messages are disabled' do
SiteSetting.enable_personal_messages = false
expect(Guardian.new(admin).can_convert_topic?(topic)).to be_falsey
end
end
describe 'can_edit?' do