mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Before people were unable to remove coordinator fees from an order cycle because Rails was converting the empty :coordinator_fee_ids array paramter into nil. This issue was introduced to Rails in v4.0.0.beta1 and isn't fixed until v5.0.0.beta1 Another way to fix this could be to do something like 'params[:coordinator_fee_ids] ||= []' but it seems like this issue could problems in other parts of the app so a more general fix might be better. Fixes #6224
19 lines
511 B
Ruby
19 lines
511 B
Ruby
require 'spec_helper'
|
|
|
|
describe ActionDispatch::Request do
|
|
it "strips nils from arrays" do
|
|
assert_parses({ "key" => ["value"] }, 'key[]=value&key[]')
|
|
assert_parses({ "key1" => { "key2" => ["value"] } }, 'key1[key2][]=value&key1[key2][]')
|
|
end
|
|
|
|
it "doesn't convert an empty array to nil" do
|
|
assert_parses({ "key" => [] }, 'key[]')
|
|
end
|
|
|
|
private
|
|
|
|
def assert_parses(expected, actual)
|
|
assert_equal expected, ActionDispatch::Request.new('QUERY_STRING' => actual).query_parameters
|
|
end
|
|
end
|