I am currently testing a post request for a nested route with Rspec request.
It is set up like this:
describe 'POST /url_contents' do
let!(:role) { create(:role, name: "admin") }
let(:valid_attributes) {
{
jwt: "SAMPLE",
role: role
}
}
context 'when the url is valid' do
before { post "/#{role.name}/1", params: valid_attributes }
it 'returns a status code of 201' do
expect(response).to have_http_status(201)
end
end
end
I am hitting my controller, but when I check params, I am getting a nested params:
:params => { :params => { :jwt => "SAMPLE", :role => #<Role:0x0055959d32a888>" }, "controller"=> "auth"... }
How can I get the params to point to :jwt
for my controller?
I've found a solution but would be happy to hear other ideas.
context 'when the jwt is valid' do
before { post "/#{role.name}/1", {
jwt: "SAMPLE",
role: role
}
}
Now params is not nested.