FIX: update user preferences was failing if custom_fields is blank string
This commit is contained in:
parent
d472b4e10a
commit
d6a562658a
|
@ -66,7 +66,7 @@ class UserUpdater
|
|||
user_profile.send("#{attribute}=", attributes[attribute])
|
||||
end
|
||||
|
||||
if fields = attributes[:custom_fields]
|
||||
if fields = attributes[:custom_fields] and fields.present?
|
||||
user.custom_fields = fields
|
||||
end
|
||||
|
||||
|
|
|
@ -91,5 +91,17 @@ describe UserUpdater do
|
|||
expect(user.reload.user_profile.website).to eq 'http://example.com'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when custom_fields is empty string' do
|
||||
it "update is successful" do
|
||||
user = Fabricate(:user)
|
||||
user.custom_fields = {'import_username' => 'my_old_username'}
|
||||
user.save
|
||||
updater = described_class.new(acting_user, user)
|
||||
|
||||
updater.update(website: 'example.com', custom_fields: '')
|
||||
user.reload.custom_fields.should == {'import_username' => 'my_old_username'}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue