Remove the default_invitee_trust_level+1 privilege from trust level 3.

This commit is contained in:
Neil Lalonde 2014-04-17 15:05:15 -04:00
parent 87e5e4b8d0
commit 890e53cd6e
2 changed files with 1 additions and 30 deletions

View File

@ -17,15 +17,7 @@ InviteRedeemer = Struct.new(:invite) do
username = suggestion unless match || available username = suggestion unless match || available
end end
user = User.new(email: invite.email, username: username, name: username, active: true) user = User.new(email: invite.email, username: username, name: username, active: true, trust_level: SiteSetting.default_invitee_trust_level)
if invite.invited_by and invite.invited_by.has_trust_level?(:leader)
# People invited by users with trust level 3 will start at the default trust level + 1,
# unless the default trust level is 2 or higher.
user.trust_level = SiteSetting.default_invitee_trust_level
user.trust_level += 1 if user.trust_level < TrustLevel.levels[:regular]
else
user.trust_level = SiteSetting.default_invitee_trust_level
end
user.save! user.save!
DiscourseHub.username_operation { DiscourseHub.register_username(username, invite.email) } DiscourseHub.username_operation { DiscourseHub.register_username(username, invite.email) }

View File

@ -173,31 +173,10 @@ describe Invite do
end end
context 'invite trust levels' do context 'invite trust levels' do
it "returns the trust level in default_invitee_trust_level" do it "returns the trust level in default_invitee_trust_level" do
SiteSetting.stubs(:default_invitee_trust_level).returns(TrustLevel.levels[:leader]) SiteSetting.stubs(:default_invitee_trust_level).returns(TrustLevel.levels[:leader])
invite.redeem.trust_level.should == TrustLevel.levels[:leader] invite.redeem.trust_level.should == TrustLevel.levels[:leader]
end end
context "invited by a trust level 3 user" do
let(:leader) { Fabricate(:user, trust_level: TrustLevel.levels[:leader]) }
let(:invitation) { Fabricate(:invite, invited_by: leader) }
it "default_invitee_trust_level is 1, then invited user should be trust level 2" do
SiteSetting.stubs(:default_invitee_trust_level).returns(TrustLevel.levels[:basic])
invitation.redeem.trust_level.should == TrustLevel.levels[:regular]
end
it "default_invitee_trust_level is 2, then invited user should be trust level 2" do
SiteSetting.stubs(:default_invitee_trust_level).returns(TrustLevel.levels[:regular])
invitation.redeem.trust_level.should == TrustLevel.levels[:regular]
end
it "default_invitee_trust_level is 3, then invited user should be trust level 3" do
SiteSetting.stubs(:default_invitee_trust_level).returns(TrustLevel.levels[:leader])
invitation.redeem.trust_level.should == TrustLevel.levels[:leader]
end
end
end end
context 'inviting when must_approve_users? is enabled' do context 'inviting when must_approve_users? is enabled' do