FIX: Sites with SSO that required approval were not creating reviewables

This commit is contained in:
Robin Ward 2019-04-10 12:53:30 -04:00
parent eae22548de
commit cab83596ec
2 changed files with 28 additions and 0 deletions

View File

@ -84,6 +84,9 @@ class DiscourseSingleSignOn < SingleSignOn
user.user_avatar.save! if user.user_avatar
user.save!
# The user might require approval
user.create_reviewable
if bio && (user.user_profile.bio_raw.blank? || SiteSetting.sso_overrides_bio)
user.user_profile.bio_raw = bio
user.user_profile.save!

View File

@ -102,6 +102,31 @@ describe DiscourseSingleSignOn do
expect(user.name).to eq("Bob O'Bob")
end
context "reviewables" do
let(:sso) do
DiscourseSingleSignOn.new.tap do |sso|
sso.username = "staged"
sso.name = "Bob O'Bob"
sso.email = "bob@obob.com"
sso.external_id = "B"
end
end
it "doesn't create reviewables if we aren't approving users" do
user = sso.lookup_or_create_user(ip_address)
reviewable = ReviewableUser.find_by(target: user)
expect(reviewable).to be_blank
end
it "creates reviewables if needed" do
SiteSetting.must_approve_users = true
user = sso.lookup_or_create_user(ip_address)
reviewable = ReviewableUser.find_by(target: user)
expect(reviewable).to be_present
expect(reviewable).to be_pending
end
end
it "can set admin and moderator" do
admin_group = Group[:admins]
mod_group = Group[:moderators]