Rails/Rspec JSON integers being converted to strings when testing post call
In Rails 5, use as: :json
instead of format: :json
, e.g. post :consider, params: automatic_approve_params, as: :json
After replicating the issue you are having I managed to resolve it in a controller spec using the following:
post :consider, automatic_approve_params.merge(format: :json)
In my local tests I removed the
request.env["HTTP_ACCEPT"] = 'application/json'
and it still worked as you expect it to. Hope it helps.