FIX: Export false on confirm user fields when using user invites (#26332)
This commit is contained in:
parent
636488264c
commit
fd83107674
|
@ -125,6 +125,7 @@ class InviteRedeemer
|
|||
fields = user.custom_fields
|
||||
|
||||
user_fields.each do |f|
|
||||
field_params[f.id.to_s] = nil if field_params[f.id.to_s] === "false"
|
||||
field_val = field_params[f.id.to_s]
|
||||
fields["#{User::USER_FIELD_PREFIX}#{f.id}"] = field_val[
|
||||
0...UserField.max_length
|
||||
|
|
|
@ -390,6 +390,32 @@ RSpec.describe InviteRedeemer do
|
|||
expect(user.custom_fields["user_field_#{optional_field.id}"]).to eq("value2")
|
||||
end
|
||||
|
||||
it "can set custom fields with field_type confirm properly" do
|
||||
optional_field_1 = Fabricate(:user_field, field_type: "confirm", required: false)
|
||||
optional_field_2 = Fabricate(:user_field, field_type: "confirm", required: false)
|
||||
optional_field_3 = Fabricate(:user_field, field_type: "confirm", required: false)
|
||||
user_fields = {
|
||||
optional_field_1.id.to_s => "false",
|
||||
optional_field_2.id.to_s => "true",
|
||||
optional_field_3.id.to_s => "",
|
||||
}
|
||||
|
||||
user =
|
||||
InviteRedeemer.new(
|
||||
invite: invite,
|
||||
email: invite.email,
|
||||
username: username,
|
||||
name: name,
|
||||
password: password,
|
||||
user_custom_fields: user_fields,
|
||||
).redeem
|
||||
|
||||
expect(user).to be_present
|
||||
expect(user.custom_fields["user_field_#{optional_field_1.id}"]).to eq(nil)
|
||||
expect(user.custom_fields["user_field_#{optional_field_2.id}"]).to eq("true")
|
||||
expect(user.custom_fields["user_field_#{optional_field_3.id}"]).to eq(nil)
|
||||
end
|
||||
|
||||
it "does not add user to group if inviter does not have permissions" do
|
||||
group = Fabricate(:group, grant_trust_level: 2)
|
||||
InvitedGroup.create(group_id: group.id, invite_id: invite.id)
|
||||
|
|
Loading…
Reference in New Issue