mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
Remove the default_invitee_trust_level+1 privilege from trust level 3.
This commit is contained in:
parent
87e5e4b8d0
commit
890e53cd6e
@ -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) }
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user