Add and apply Rails/ResponseParsedBody rubocop rule
This rule was introduced in rubocop-rails 2.18.0. Since using `response.parsed_body` is shorter than using `JSON.parse(response.body)`, this also means we can group some lines in one.
This commit is contained in:
@@ -408,6 +408,9 @@ Rails/RelativeDateConstant:
|
|||||||
Rails/RequestReferer:
|
Rails/RequestReferer:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
Rails/ResponseParsedBody:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
Rails/ReversibleMigration:
|
Rails/ReversibleMigration:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,7 @@ describe Admin::Api::StatsController, :admin do
|
|||||||
get :show, params: { event: "foo" }
|
get :show, params: { event: "foo" }
|
||||||
|
|
||||||
expect(response).to be_ok
|
expect(response).to be_ok
|
||||||
|
expect(response.parsed_body).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [2, 1]
|
||||||
data = JSON.parse(response.body)
|
|
||||||
expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [2, 1]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -47,9 +45,7 @@ describe Admin::Api::StatsController, :admin do
|
|||||||
get :show, params: { visits: true }
|
get :show, params: { visits: true }
|
||||||
|
|
||||||
expect(response).to be_ok
|
expect(response).to be_ok
|
||||||
|
expect(response.parsed_body).to eq "x" => ["2015-01-01", "2015-01-02"], "Visits" => [2, 1]
|
||||||
data = JSON.parse(response.body)
|
|
||||||
expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Visits" => [2, 1]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -65,9 +61,7 @@ describe Admin::Api::StatsController, :admin do
|
|||||||
get :show, params: { budget_investments: true }
|
get :show, params: { budget_investments: true }
|
||||||
|
|
||||||
expect(response).to be_ok
|
expect(response).to be_ok
|
||||||
|
expect(response.parsed_body).to eq "x" => ["2017-04-01", "2017-04-02"], "Budget Investments" => [1, 2]
|
||||||
data = JSON.parse(response.body)
|
|
||||||
expect(data).to eq "x" => ["2017-04-01", "2017-04-02"], "Budget Investments" => [1, 2]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ describe GraphqlController, type: :request do
|
|||||||
get "/graphql", params: { query: "{ proposal(id: #{proposal.id}) { title } }" }
|
get "/graphql", params: { query: "{ proposal(id: #{proposal.id}) { title } }" }
|
||||||
|
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(JSON.parse(response.body)["data"]["proposal"]["title"]).to eq(proposal.title)
|
expect(response.parsed_body["data"]["proposal"]["title"]).to eq(proposal.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "with malformed query string" do
|
specify "with malformed query string" do
|
||||||
@@ -30,7 +30,7 @@ describe GraphqlController, type: :request do
|
|||||||
get "/graphql"
|
get "/graphql"
|
||||||
|
|
||||||
expect(response).to have_http_status(:bad_request)
|
expect(response).to have_http_status(:bad_request)
|
||||||
expect(JSON.parse(response.body)["message"]).to eq("Query string not present")
|
expect(response.parsed_body["message"]).to eq("Query string not present")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ describe GraphqlController, type: :request do
|
|||||||
headers: json_headers
|
headers: json_headers
|
||||||
|
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(JSON.parse(response.body)["data"]["proposal"]["title"]).to eq(proposal.title)
|
expect(response.parsed_body["data"]["proposal"]["title"]).to eq(proposal.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "with raw query string inside body" do
|
specify "with raw query string inside body" do
|
||||||
@@ -51,7 +51,7 @@ describe GraphqlController, type: :request do
|
|||||||
headers: graphql_headers
|
headers: graphql_headers
|
||||||
|
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(JSON.parse(response.body)["data"]["proposal"]["title"]).to eq(proposal.title)
|
expect(response.parsed_body["data"]["proposal"]["title"]).to eq(proposal.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "with malformed query string" do
|
specify "with malformed query string" do
|
||||||
@@ -65,7 +65,7 @@ describe GraphqlController, type: :request do
|
|||||||
post "/graphql", headers: json_headers
|
post "/graphql", headers: json_headers
|
||||||
|
|
||||||
expect(response).to have_http_status(:bad_request)
|
expect(response).to have_http_status(:bad_request)
|
||||||
expect(JSON.parse(response.body)["message"]).to eq("Query string not present")
|
expect(response.parsed_body["message"]).to eq("Query string not present")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ describe InstallationController, type: :request do
|
|||||||
get "/consul.json"
|
get "/consul.json"
|
||||||
|
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(JSON.parse(response.body)["release"]).not_to be_empty
|
expect(response.parsed_body["release"]).not_to be_empty
|
||||||
expect(JSON.parse(response.body)["features"]).to eq(test_process_settings)
|
expect(response.parsed_body["features"]).to eq(test_process_settings)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user