2
作者有很多作品。作品属于作者。RSpecing:嵌套资源的更新操作
resources :authors do
resources :works
end
而RSpec的:
it "should redirect to :show" do
work = FactoryGirl.create(:work)
controller.stub(:resource) { work }
work.should_receive(:update_attributes) { true }
put :update, id: work.id, author_id: work.author.id, work: {}
response.should redirect_to(admin_author_work_path(work.author, work))
end
和错误:
Expected response to be a redirect to <http://test.host/admin/authors/353/works/166>
but was a redirect to <http://test.host/admin/authors/353/works>
为什么不能重定向到works_controller的:表演动作?我错过了什么吗?
我正在使用inherited-resources,因此controller.stub(:resource)。我也注意到assign(:work, work) throws undefined method 'assign'
?它在视图中工作,它不应该也适用于控制器吗?