Project

General

Profile

Feature #26709 » api_test.rb.patch

+ spec - Pavel Rosický, 2017-09-15 22:43

View differences:

api_test.rb (working copy)
assert_response :ok
assert_equal '', response.body
end
def test_accept_header_on_show
get '/users/1', :headers => credentials('admin').merge({'Accept' => 'application/xml'})
assert_response :ok
assert_equal 'application/xml', response.content_type
assert_include '<?xml', response.body
end
def test_accept_header_on_create
put '/users/7', :params => '<user><login>foo</login></user>', :headers => credentials('admin').merge({'Accept' => 'application/xml', 'Content-type' => 'application/xml'})
assert_response :ok
assert_equal 'application/xml', response.content_type
assert_equal User.find(7).login, 'foo'
end
def test_accept_header_on_error
put '/users/7', :params => '<user><login></login></user>', :headers => credentials('admin').merge({'Accept' => 'application/xml', 'Content-type' => 'application/xml'})
assert_response 422
assert_equal 'application/xml', response.content_type
assert_include '<?xml', response.body
assert_include '<error>', response.body
end
end
(3-3/3)