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:
@@ -29,9 +29,7 @@ describe Admin::Api::StatsController, :admin do
|
||||
get :show, params: { event: "foo" }
|
||||
|
||||
expect(response).to be_ok
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [2, 1]
|
||||
expect(response.parsed_body).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [2, 1]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,9 +45,7 @@ describe Admin::Api::StatsController, :admin do
|
||||
get :show, params: { visits: true }
|
||||
|
||||
expect(response).to be_ok
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Visits" => [2, 1]
|
||||
expect(response.parsed_body).to eq "x" => ["2015-01-01", "2015-01-02"], "Visits" => [2, 1]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,9 +61,7 @@ describe Admin::Api::StatsController, :admin do
|
||||
get :show, params: { budget_investments: true }
|
||||
|
||||
expect(response).to be_ok
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
expect(data).to eq "x" => ["2017-04-01", "2017-04-02"], "Budget Investments" => [1, 2]
|
||||
expect(response.parsed_body).to eq "x" => ["2017-04-01", "2017-04-02"], "Budget Investments" => [1, 2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user