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'
?它在視圖中工作,它不應該也適用於控制器嗎?