spec/functional_spec.rb in praxis-2.0.pre.5 vs spec/functional_spec.rb in praxis-2.0.pre.6
- old
+ new
@@ -329,16 +329,19 @@
end
end
end
context 'wildcard verb routing' do
+ let(:content_type){ 'application/json' }
it 'can terminate instances with POST' do
- post '/api/clouds/23/instances/1/terminate?api_version=1.0', '', 'global_session' => session
+ post '/api/clouds/23/instances/1/terminate?api_version=1.0', nil, 'CONTENT_TYPE' => content_type, 'global_session' => session
+ puts last_response.body
+ #binding.pry
expect(last_response.status).to eq(200)
end
it 'can terminate instances with DELETE' do
- post '/api/clouds/23/instances/1/terminate?api_version=1.0', '', 'global_session' => session
+ post '/api/clouds/23/instances/1/terminate?api_version=1.0', nil, 'CONTENT_TYPE' => content_type, 'global_session' => session
expect(last_response.status).to eq(200)
end
end
@@ -353,31 +356,31 @@
end
end
context 'auth_plugin' do
it 'can terminate' do
- post '/api/clouds/23/instances/1/terminate?api_version=1.0', '', 'global_session' => session
+ post '/api/clouds/23/instances/1/terminate?api_version=1.0', nil, 'global_session' => session
expect(last_response.status).to eq(200)
end
it 'can not stop' do
post '/api/clouds/23/instances/1/stop?api_version=1.0', '', 'global_session' => session
expect(last_response.status).to eq(403)
end
end
context 'with mismatch between Content-Type and payload' do
- let(:body) { '{}' }
- let(:content_type) { 'application/x-www-form-urlencoded' }
+ let(:body) { 'some-text' }
+ let(:content_type) { 'application/json' }
before do
post '/api/clouds/1/instances/2/terminate?api_version=1.0', body, 'CONTENT_TYPE' => content_type, 'global_session' => session
end
it 'returns a useful error message' do
body = JSON.parse(last_response.body)
expect(body['name']).to eq('ValidationError')
- expect(body['summary']).to match("Error loading payload. Used Content-Type: 'application/x-www-form-urlencoded'")
+ expect(body['summary']).to match("Error loading payload. Used Content-Type: 'application/json'")
expect(body['errors']).to_not be_empty
end
end
context 'update' do