Revision c85a1c66
Added by Marek Hulán about 7 years ago
app/controllers/concerns/parameter_attributes.rb | ||
---|---|---|
return unless model_params
|
||
parameter_params = model_params["#{parameter_class_mapping}_parameters_attributes"]
|
||
return unless parameter_params
|
||
# parameters may be either Array or indexed Hash
|
||
parameter_params = parameter_params.values unless parameter_params.kind_of?(Array)
|
||
|
||
param_names = parameter_params.map { |hash| hash[:name] }
|
||
|
test/controllers/api/v2/hosts_controller_test.rb | ||
---|---|---|
end
|
||
end
|
||
|
||
test "should update existing host parameters" do
|
||
test "should update existing host parameters using indexed hash format" do
|
||
host = FactoryGirl.create(:host, :with_parameter)
|
||
host_param = host.parameters.first
|
||
put :update, { :id => host.id, :host => { :host_parameters_attributes => { "0" => { :name => host_param.name, :value => "new_value" } } } }
|
||
assert_response :success
|
||
end
|
||
|
||
test "should update existing host parameters using array format" do
|
||
host = FactoryGirl.create(:host, :with_parameter)
|
||
host_param = host.parameters.first
|
||
put :update, { :id => host.id, :host => { :host_parameters_attributes => [{ :name => host_param.name, :value => "new_value" }] } }
|
Also available in: Unified diff
Fixes #18687 - restore hash format for parameter attributes