Given this contrived example:
RSpec.describe City::Road::HouseController, type: :controller do
let(:house) { create :house }
describe 'index' do
context 'a request is received without a valid basic-auth header' do
it 'renders unauthorized' do
before { method_that_unsets_basic_auth_header }
get(:index, params: { house_id: house.id })
expect(response).to have_http_status(:unauthorized)
end
end
end
end
with the following routes:
namespace :city do
namespace :road do
resources :location, only: %i[show index] do
resources :house, only: %i[index], on: :member
end
end
end
Why do I keep getting this error?:
ActionController::UrlGenerationError:
No route matches {:action=>"index", :controller=>"city/road/house :house_id=>1}
I think it's because it's ignoring location.
I expect the route to be:
/city/road/location/:location_id/house
I've looked at the following questions/answers but none of them helped (though I admit I may have missed something):