mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Better handling for toggling must_approve_users
If you turn it on now, default all users to approved since they were previously. Also support approving a user that doesn't have a reviewable record (it will be created first.) This also includes a refactor to move class method calls to `DiscourseEvent` into an initializer. Otherwise the load order of classes makes a difference in the test environment and some settings might be triggered and others not, randomly.
This commit is contained in:
@@ -56,12 +56,11 @@ RSpec.describe Admin::UsersController do
|
||||
end
|
||||
|
||||
describe '#approve' do
|
||||
let(:evil_trout) { Fabricate(:evil_trout) }
|
||||
before do
|
||||
SiteSetting.must_approve_users = true
|
||||
end
|
||||
|
||||
let(:evil_trout) { Fabricate(:evil_trout) }
|
||||
|
||||
it "raises an error when the user doesn't have permission" do
|
||||
sign_in(user)
|
||||
put "/admin/users/#{evil_trout.id}/approve.json"
|
||||
@@ -70,6 +69,15 @@ RSpec.describe Admin::UsersController do
|
||||
expect(evil_trout.approved).to eq(false)
|
||||
end
|
||||
|
||||
it "will create a reviewable if one does not exist" do
|
||||
evil_trout.update!(active: true)
|
||||
expect(ReviewableUser.find_by(target: evil_trout)).to be_blank
|
||||
put "/admin/users/#{evil_trout.id}/approve.json"
|
||||
expect(response.code).to eq("200")
|
||||
expect(ReviewableUser.find_by(target: evil_trout)).to be_present
|
||||
expect(evil_trout.reload).to be_approved
|
||||
end
|
||||
|
||||
it 'calls approve' do
|
||||
Jobs.run_immediately!
|
||||
evil_trout.activate
|
||||
|
||||
Reference in New Issue
Block a user