From 30215c37d1da0cf611854fcc246fe115d166008b Mon Sep 17 00:00:00 2001 From: Gibheer Date: Tue, 6 Aug 2013 14:15:54 +0200 Subject: make it possible to push lists as paramters This makes it possible to push lists as paramters by naming the variables with `[]` at the end, for example `foo[]`. --- spec/unit/zero/request/parameter/payload_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'spec/unit') diff --git a/spec/unit/zero/request/parameter/payload_spec.rb b/spec/unit/zero/request/parameter/payload_spec.rb index 563b21d..9cf1198 100644 --- a/spec/unit/zero/request/parameter/payload_spec.rb +++ b/spec/unit/zero/request/parameter/payload_spec.rb @@ -31,6 +31,25 @@ describe Zero::Request::Parameter, '#payload' do its(:payload) { should == {'bar' => 'foo bar'} } end + context 'with multiple parameters' do + let(:env) do + EnvGenerator.post('/foo', { + :input => 'bar=foo&foo=bar', 'CONTENT_TYPE' => 'multipart/form-data' + }) + end + its(:payload) { should == {'foo' => 'bar', 'bar' => 'foo'} } + end + + context 'with a list' do + let(:env) do + EnvGenerator.post('/foo', { + :input => 'bar[]=foo&bar[]=bar', + 'CONTENT_TYPE' => 'multipart/form-data' + }) + end + its(:payload) { should == {'bar[]' => ['foo', 'bar']} } + end + # TODO behaves like this, but is this really good like this? context 'with a post body and content type application/json' do let(:env) do -- cgit v1.2.3-70-g09d2