[rspec-users] Simple Association Redirect on delete

Craig Demyanovich cdemyanovich at gmail.com
Mon Feb 28 09:21:37 EST 2011

On Sun, Feb 27, 2011 at 10:57 PM, Charley <charley.stran at gmail.com> wrote:

> it "redirects to the bugs list" do
>  Bug.stub(:find) { mock_bug }
>  delete :destroy, :id => "1"
>  response.should redirect_to(bugs_url)
> end
> This fails for obvious reasons. A bug belongs to a project so the
> redirect should go to the projects_url("someproject_id_I_dont_know")
> I am sure this is a fairly simple and common thing. Can anyone help
> put me on the right path?

Make the mock_bug respond to project_id. Then verify that the request's
response goes to project_path(:id => mock_bug.project_id).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110228/da425203/attachment.html>

More information about the rspec-users mailing list