mardi 4 août 2015

"resources :post, except: :new" makes Rails think the route /posts/new would point to a post ID "new"

I have the following route:

resources :success_criteria, except: :new

The following spec fails:

describe SuccessCriteriaController do
  describe 'routing' do
    it 'routes to #new' do
      expect(get('/success_criteria/new')).to_not be_routable
    end
  end
end

Failure message:

Failure/Error: expect(get('/posts/new')).to_not be_routable
expected {:get=>"/posts/new"} not to be routable, but it routes to {:controller=>"posts", :action=>"show", :id=>"new"}

The controller looks like this:

class SuccessCriteriaController < InheritedResources::Base
  load_and_authorize_resource
end

Why does Rails think that posts/new would point to a post with the ID new? That's not right, is it? Does it maybe have to do with InheritedResources?

Aucun commentaire:

Enregistrer un commentaire