mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:11:09 +08:00
FEATURE: New "Dropdown" user field type
This commit is contained in:
@ -16,6 +16,18 @@ describe Admin::UserFieldsController do
|
||||
expect(response).to be_success
|
||||
}.to change(UserField, :count).by(1)
|
||||
end
|
||||
|
||||
it "creates a user field with options" do
|
||||
expect {
|
||||
xhr :post, :create, {user_field: {name: 'hello',
|
||||
description: 'hello desc',
|
||||
field_type: 'dropdown',
|
||||
options: ['a', 'b', 'c']} }
|
||||
expect(response).to be_success
|
||||
}.to change(UserField, :count).by(1)
|
||||
|
||||
expect(UserFieldOption.count).to eq(3)
|
||||
end
|
||||
end
|
||||
|
||||
context '.index' do
|
||||
@ -50,6 +62,18 @@ describe Admin::UserFieldsController do
|
||||
expect(user_field.name).to eq('fraggle')
|
||||
expect(user_field.field_type).to eq('confirm')
|
||||
end
|
||||
|
||||
it "updates the user field options" do
|
||||
xhr :put, :update, id: user_field.id, user_field: {name: 'fraggle',
|
||||
field_type: 'dropdown',
|
||||
description: 'muppet',
|
||||
options: ['hello', 'hello', 'world']}
|
||||
expect(response).to be_success
|
||||
user_field.reload
|
||||
expect(user_field.name).to eq('fraggle')
|
||||
expect(user_field.field_type).to eq('dropdown')
|
||||
expect(user_field.user_field_options.size).to eq(2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user