著者は多くの作品を持っています。作品は作者のものです。
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の:showアクションにリダイレクトされないのですか?私は何かが足りないのですか?
私はinherited-resourcesを使用しているため、controller.stub(:resource)を使用しています。
私も気づきましたassign(:work, work) throws undefined method 'assign'
か?ビューで機能しますが、コントローラーでも機能するのではないでしょうか。