Files
openfoodnetwork/spec/lib/action_dispatch/request_spec.rb
Maikel Linke dcb6f4676d Remove all unnecessary spec_helper require statements
The `.rspec` file is doing this for us.
2026-01-21 12:35:34 +11:00

24 lines
650 B
Ruby

# frozen_string_literal: true
RSpec.describe ActionDispatch::Request do
it "strips nils from arrays" do
expect(parse_query_parameters('key[]=value&key[]')).to eq({ "key" => ["value"] })
end
it "strips nils from nested arrays" do
expect(
parse_query_parameters('key1[key2][]=value&key1[key2][]')
).to eq({ "key1" => { "key2" => ["value"] } })
end
it "doesn't convert an empty array to nil" do
expect(parse_query_parameters('key[]')).to eq({ "key" => [] })
end
private
def parse_query_parameters(query_parameters)
ActionDispatch::Request.new("QUERY_STRING" => query_parameters).query_parameters
end
end