FEATURE: allow moderators to convert a private message to public topic or vice versa
This commit is contained in:
parent
2950a82a7d
commit
b25d950d99
|
@ -256,7 +256,7 @@
|
|||
{{/if}}
|
||||
</li>
|
||||
|
||||
{{#if currentUser.admin}}
|
||||
{{#if currentUser.staff}}
|
||||
<li class="topic-admin-convert">
|
||||
{{#if model.isPrivateMessage}}
|
||||
{{d-button action="convertToPublicTopic" icon="comment" label="topic.actions.make_public"}}
|
||||
|
|
|
@ -59,7 +59,9 @@ module TopicGuardian
|
|||
end
|
||||
|
||||
def can_convert_topic?(topic)
|
||||
topic && !topic.trashed? && is_admin?
|
||||
return false if topic && topic.trashed?
|
||||
return true if is_admin?
|
||||
is_moderator? && can_create_post?(topic)
|
||||
end
|
||||
|
||||
def can_reply_as_new_topic?(topic)
|
||||
|
|
|
@ -881,8 +881,12 @@ describe Guardian do
|
|||
expect(Guardian.new.can_convert_topic?(topic)).to be_falsey
|
||||
end
|
||||
|
||||
it 'returns false when not admin' do
|
||||
expect(Guardian.new(moderator).can_convert_topic?(topic)).to be_falsey
|
||||
it 'returns false when not staff' do
|
||||
expect(Guardian.new(trust_level_4).can_convert_topic?(topic)).to be_falsey
|
||||
end
|
||||
|
||||
it 'returns true when a moderator' do
|
||||
expect(Guardian.new(moderator).can_convert_topic?(topic)).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns true when an admin' do
|
||||
|
|
Loading…
Reference in New Issue