api: refactor only param.

This commit is contained in:
evazion
2019-09-08 23:28:02 -05:00
parent 24202d51f0
commit 19f2cc1e74
4 changed files with 12 additions and 48 deletions

View File

@@ -206,6 +206,14 @@ class ApplicationControllerTest < ActionDispatch::IntegrationTest
assert_equal("max-age=#{5.minutes}, private", response.headers["Cache-Control"])
end
should "support the only parameter" do
create(:post)
get posts_path, as: :json, params: { only: "id,rating score" }
assert_response :success
assert_equal(%w[id rating score].sort, response.parsed_body.first.keys.sort)
end
should "return the correct root element name for empty xml responses" do
get tags_path, as: :xml