mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 02:35:46 +08:00
FIX: Granting staff status should auto-approve users waiting approval (#8533)
* FIX: Granting staff status should auto-approve users waiting approval * Update app/models/concerns/roleable.rb Co-Authored-By: Robin Ward <robin.ward@gmail.com>
This commit is contained in:
@ -2240,4 +2240,39 @@ describe User do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Granting admin or moderator status' do
|
||||
it 'approves the associated reviewable when granting admin status' do
|
||||
reviewable_user = Fabricate(:reviewable_user)
|
||||
|
||||
reviewable_user.target.grant_admin!
|
||||
|
||||
expect(reviewable_user.reload.status).to eq Reviewable.statuses[:approved]
|
||||
end
|
||||
|
||||
it 'does nothing when the user is already approved' do
|
||||
reviewable_user = Fabricate(:reviewable_user)
|
||||
reviewable_user.perform(Discourse.system_user, :approve_user)
|
||||
|
||||
reviewable_user.target.grant_admin!
|
||||
|
||||
expect(reviewable_user.reload.status).to eq Reviewable.statuses[:approved]
|
||||
end
|
||||
|
||||
it 'approves the associated reviewable when granting moderator status' do
|
||||
reviewable_user = Fabricate(:reviewable_user)
|
||||
|
||||
reviewable_user.target.grant_moderation!
|
||||
|
||||
expect(reviewable_user.reload.status).to eq Reviewable.statuses[:approved]
|
||||
end
|
||||
|
||||
it 'approves the user if there is no reviewable' do
|
||||
user = Fabricate(:user, approved: false)
|
||||
|
||||
user.grant_admin!
|
||||
|
||||
expect(user.approved).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user