Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 Upgrade - ActionController::UrlGenerationError - No route matches

I am trying to port my application from Rails 3.2.x to Rails 4.0.4. All the gems have been made compatible and I am in the phase of fixing failing tests.

I have this weird test failure.

My routes.rb

resources :my_reports, only: [:index] do
  collection do
    get "/report/:filename", to: :show, prefix: "pri/excl/rep", as: :show
  end
end

My spec which has been passing in Rails 3.2.x and now failing after update to 4.0.4

describe MyReportsController do
  describe "#show" do
    def make_request
      get :show, prefix: 'some/place', filename: 'foo', format: 'doc'
    end

    it "makes a simple request" do
      make_request
    end
  end
end

I am getting the following error

Failure/Error: get :show, prefix: 'some/place', filename: 'foo', format: 'doc'
     ActionController::UrlGenerationError:
       No route matches {:action=>"show", :controller=>"my_reports", 
        :filename=>"foo", :format=>"doc", :prefix=>"some/place"}

I am stuck at this point, hints are welcome. I am using rspec and rspec-rails versions 2.14.1.

like image 715
bragboy Avatar asked Apr 22 '14 12:04

bragboy


1 Answers

Passing a dummy :id in the test fixed the issue for me although I would not like it, tests pass.

get :show, id: "", prefix: 'some/place', filename: 'foo', format: 'doc'

Refer to state of rails releases here.

like image 190
bragboy Avatar answered Oct 10 '22 12:10

bragboy