Kill all mutants in Zero::Request::Parameter
I've also changed "extract_query_params" because it does not matter, if the query string it empty or not for the "parse_string" method.
This commit is contained in:
parent
3bb53d7343
commit
cd97198e22
|
@ -79,14 +79,15 @@ module Zero
|
||||||
# extracts the key value pairs from the environment
|
# extracts the key value pairs from the environment
|
||||||
# @return Hash all key value pairs from query string
|
# @return Hash all key value pairs from query string
|
||||||
def extract_query_params(environment)
|
def extract_query_params(environment)
|
||||||
return {} if environment[ENV_KEY_QUERY].length == 0
|
|
||||||
parse_string(environment[ENV_KEY_QUERY])
|
parse_string(environment[ENV_KEY_QUERY])
|
||||||
end
|
end
|
||||||
|
|
||||||
# extracts the key value pairs from the body
|
# extracts the key value pairs from the body
|
||||||
# @return Hash all key value pairs from the payload
|
# @return Hash all key value pairs from the payload
|
||||||
def extract_payload_params(environment)
|
def extract_payload_params(environment)
|
||||||
return {} unless PAYLOAD_CONTENT_TYPES.include?(environment[ENV_KEY_CONTENT_TYPE])
|
unless PAYLOAD_CONTENT_TYPES.include?(environment[ENV_KEY_CONTENT_TYPE])
|
||||||
|
return {}
|
||||||
|
end
|
||||||
parse_string(environment[ENV_KEY_PAYLOAD].read)
|
parse_string(environment[ENV_KEY_PAYLOAD].read)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,4 +15,9 @@ describe Zero::Request::Parameter, '#custom' do
|
||||||
|
|
||||||
expect(subject.custom['foo']).to eq('latest')
|
expect(subject.custom['foo']).to eq('latest')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'is empty if no custom parameter is set' do
|
||||||
|
expect(subject.custom).to eq({})
|
||||||
|
expect(env['zero.params.custom']).to eq({})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,8 @@ require 'spec_helper'
|
||||||
describe Zero::Request::Parameter, '#initialize' do
|
describe Zero::Request::Parameter, '#initialize' do
|
||||||
subject { Zero::Request::Parameter.new(env) }
|
subject { Zero::Request::Parameter.new(env) }
|
||||||
let(:env) { EnvGenerator.get('/get', {
|
let(:env) { EnvGenerator.get('/get', {
|
||||||
'zero.params.custom' => {'foo' => 'bar'} }) }
|
'zero.params.custom' => {'foo' => 'bar'}
|
||||||
|
}) }
|
||||||
|
|
||||||
it 'does not overwrite parameters' do
|
it 'does not overwrite parameters' do
|
||||||
subject
|
subject
|
||||||
|
|
|
@ -30,4 +30,14 @@ describe Zero::Request::Parameter, '#payload' do
|
||||||
end
|
end
|
||||||
its(:payload) { should == {'bar' => 'foo bar'} }
|
its(:payload) { should == {'bar' => 'foo bar'} }
|
||||||
end
|
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
|
||||||
|
EnvGenerator.post('/foo', {
|
||||||
|
:input => '"foobar"', 'CONTENT_TYPE' => 'application/json'
|
||||||
|
})
|
||||||
|
end
|
||||||
|
its(:payload) { should == {} }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user