mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:25:35 +08:00
Allows mod posts to be created for category group moderators on closed/archived topics (#10399)
This commit is contained in:
parent
e3bc8f34ed
commit
d67f7a7984
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user