FIX: Allow invites if must_approve_users is true (#13257)
This commit is contained in:
parent
435c4817cb
commit
36e0e6a322
|
@ -354,7 +354,7 @@ class Guardian
|
|||
return false if !authenticated?
|
||||
|
||||
invites_available = SiteSetting.max_invites_per_day.to_i.positive?
|
||||
trust_level_requirement_met = !SiteSetting.must_approve_users? && @user.has_trust_level?(SiteSetting.min_trust_level_to_allow_invite.to_i)
|
||||
trust_level_requirement_met = @user.has_trust_level?(SiteSetting.min_trust_level_to_allow_invite.to_i)
|
||||
|
||||
if !is_staff?
|
||||
return false if !invites_available
|
||||
|
|
|
@ -506,11 +506,6 @@ describe Guardian do
|
|||
expect(Guardian.new(moderator).can_invite_to_forum?).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false when the site requires approving users and is regular' do
|
||||
SiteSetting.expects(:must_approve_users?).returns(true)
|
||||
expect(Guardian.new(user).can_invite_to_forum?).to be_falsey
|
||||
end
|
||||
|
||||
context 'with groups' do
|
||||
let(:groups) { [group, another_group] }
|
||||
|
||||
|
|
|
@ -85,6 +85,22 @@ describe InviteRedeemer do
|
|||
expect(user.approved).to eq(true)
|
||||
expect(user.active).to eq(false)
|
||||
end
|
||||
|
||||
it "does not automatically approve users if must_approve_users is true" do
|
||||
SiteSetting.must_approve_users = true
|
||||
|
||||
invite = Fabricate(:invite, email: 'test@example.com')
|
||||
user = InviteRedeemer.create_user_from_invite(invite: invite, email: invite.email, username: 'test')
|
||||
expect(user.approved).to eq(false)
|
||||
end
|
||||
|
||||
it "approves user if invited by staff" do
|
||||
SiteSetting.must_approve_users = true
|
||||
|
||||
invite = Fabricate(:invite, email: 'test@example.com', invited_by: Fabricate(:admin))
|
||||
user = InviteRedeemer.create_user_from_invite(invite: invite, email: invite.email, username: 'test')
|
||||
expect(user.approved).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#redeem" do
|
||||
|
|
Loading…
Reference in New Issue