我有一个我觉得应该毫无问题地通过的规范,但我相信,因为它是一个嵌套资源,它可能会抛出我的请求。我正在使用带有 Ruby 2.3.3 的 Rails 4.2。这是怎么回事?我知道这是一条有效的路线,因为当我击球时它出现rake routes
路线.rb
scope '/organizations/:organization_id' do
get 'dashboard', to: 'projects#dashboard'
resources :projects, except: [:delete] do
get 'configure', to: 'projects#configure'
post 'configure', to: 'projects#configure'
get 'team', to: 'projects#team'
get 'subprojects', to: 'projects#subprojects'
collection do
get 'search', to: 'projects#search'
get 'find', to: 'projects#find'
post 'create_by_sf_id', to: 'projects#create_by_sf_id'
end
resources :courses do
get 'module_progress', to: 'courses#module_progress'
get 'add_content', to: 'courses#add_content'
get 'summary', to: 'courses#summary'
post 'summary', to: 'courses#summary'
end
resources :tasks
end
end
projects_controller_spec.rb
describe 'GET project_team' do
it 'should render the project team page' do
get :team, organization_id: organization.id, id: project.id
expect(response.code).to eq '200'
end
end
项目控制器.rb
def team
@team = @project.project_team
end
...Aaaand 产生的错误:
1) ProjectsController when authenticating as a customer GET project_team should render the project team page
Failure/Error: get :team, organization_id: organization.id, id: project.id
ActionController::UrlGenerationError:
No route matches {:action=>"team", :controller=>"projects", :id=>"460", :organization_id=>"417"}
# ./spec/controllers/projects_controller_spec.rb:90:in `block (4 levels) in <top (required)>'