Preserve user-field options when updating user-fields

Avoid deleting options of the user-field when no options are
transmitted.
This commit is contained in:
Jonathan Brachthaeuser
2015-08-17 19:01:15 +02:00
parent d87520a2cf
commit c0e88724c2
2 changed files with 23 additions and 4 deletions

View File

@ -74,6 +74,25 @@ describe Admin::UserFieldsController do
expect(user_field.field_type).to eq('dropdown')
expect(user_field.user_field_options.size).to eq(2)
end
it "keeps options when updating the user field" do
xhr :put, :update, id: user_field.id, user_field: {name: 'fraggle',
field_type: 'dropdown',
description: 'muppet',
options: ['hello', 'hello', 'world'],
position: 1}
expect(response).to be_success
user_field.reload
expect(user_field.user_field_options.size).to eq(2)
xhr :put, :update, id: user_field.id, user_field: {name: 'fraggle',
field_type: 'dropdown',
description: 'muppet',
position: 2}
expect(response).to be_success
user_field.reload
expect(user_field.user_field_options.size).to eq(2)
end
end
end