mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: update user preferences was failing if custom_fields is blank string
This commit is contained in:
parent
d472b4e10a
commit
d6a562658a
2 changed files with 13 additions and 1 deletions
|
@ -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 a new issue