Question: How to correctly send query parameters in RSpec with wrap parameters on?

Question

How to correctly send query parameters in RSpec with wrap parameters on?

Answers 0
Added at 2017-01-02 21:01
Tags
Question

I'm building a REST api with Rails 4.2.6. I recently discovered the use of wrap parameters, and set those to JSON, to simplify the requests that my clients have to make. So, for instance, from a controller called SubOrder, they can now send the request parameter of "name" instead of "sub_order[name]". That's all well and good, and it works in Postman. However, my RSpec tests are now failing, saying that I'm not sending the SubOrder parameter. I also set my sub_order_params method to:

def sub_order_params
    params.permit(:user_id, :title, :name, etc...)
end

Before the change, they looked like this:

def sub_order_params
    params.require(:sub_order).permit(:user_id, :title, :name, etc...)
end

So while the api works in the way that I've intended it to, I'd like to know how to structure my RSpec controller tests correctly to make them pass?

Answers
Source Show
◀ Wstecz