Allows mod posts to be created for category group moderators on closed/archived topics (#10399)

This commit is contained in:
jbrw 2020-08-10 15:21:01 -04:00 committed by GitHub
parent e3bc8f34ed
commit d67f7a7984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 4 deletions

View File

@ -65,7 +65,7 @@ module TopicGuardian
return false if topic.trashed?
return true if is_admin?
trusted = (authenticated? && user.has_trust_level?(TrustLevel[4])) || is_moderator?
trusted = (authenticated? && user.has_trust_level?(TrustLevel[4])) || is_moderator? || can_perform_action_available_to_group_moderators?(topic)
(!(topic.closed? || topic.archived?) || trusted) && can_create_post?(topic)
end

View File

@ -879,15 +879,45 @@ RSpec.describe TopicsController do
expect(response.status).to eq(200)
expect(topic.reload.closed).to eq(true)
expect(topic.posts.last.action_code).to eq('closed.enabled')
end
it 'should allow a group moderator to open a closed topic' do
topic.update!(closed: true)
expect do
put "/t/#{topic.id}/status.json", params: {
status: 'closed', enabled: 'false'
}
end.to change { topic.reload.posts.count }.by(1)
expect(response.status).to eq(200)
expect(topic.reload.closed).to eq(false)
expect(topic.posts.last.action_code).to eq('closed.disabled')
end
it 'should allow a group moderator to archive a topic' do
put "/t/#{topic.id}/status.json", params: {
status: 'archived', enabled: 'true'
}
expect do
put "/t/#{topic.id}/status.json", params: {
status: 'archived', enabled: 'true'
}
end.to change { topic.reload.posts.count }.by(1)
expect(response.status).to eq(200)
expect(topic.reload.archived).to eq(true)
expect(topic.posts.last.action_code).to eq('archived.enabled')
end
it 'should allow a group moderator to unarchive an archived topic' do
topic.update!(archived: true)
put "/t/#{topic.id}/status.json", params: {
status: 'archived', enabled: 'false'
}
expect(response.status).to eq(200)
expect(topic.reload.archived).to eq(false)
expect(topic.posts.last.action_code).to eq('archived.disabled')
end
it 'should not allow a group moderator to pin a topic' do