[rspec-devel] [ rspec-Bugs-6959 ] Calls to render and redirect in controllers should return true

noreply at rubyforge.org noreply at rubyforge.org
Wed Nov 29 10:58:14 EST 2006


Bugs item #6959, was opened at 2006-11-29 15:58
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6959&group_id=797

Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Steve Tooke (stevetooke)
Assigned to: Nobody (None)
Summary: Calls to render and redirect in controllers should return true

Initial Comment:
I think I've come across a small bug which causes the "do and return"
pattern to fail with render or redirect_to inside an controller
action.

According to changeset 462 (http://dev.rubyonrails.org/changeset/462)
render and redirect_to should both return true, this does not appear
to happen when running specs

e.g.

class PersonController < ApplicationController
  
  def show
    @person = Person.find(params[:id])
    show_404 and return unless @person
    render :template => 'person/show'
  end

  protected
  def show_404
    render( :file => "#{RAILS_ROOT}/public/404.html",
            :status => "404 Not Found" )
  end
  
end

------

context "attempt to show a person that doesn't exist" do
  controller_name :person
  
  setup do
    Person.stub!(:find)
  end

  specify "should not assign a person" do
    get 'show', :id => 'broken'
    assigns[:person].should == nil
  end

  specify "should render 404 file" do
    controller.should_render :file => "#{RAILS_ROOT}/public/404.html",
                             :status => "404 Not Found"
    get 'show', :id => 'broken'
  end
end

Both of these specs will fail with an
"ActionController::DoubleRenderError", demonstrating that the return
call is being ignored, and that render is not returning true.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6959&group_id=797


More information about the rspec-devel mailing list