[rspec-devel] Calls to render and redirect in controllers should return true (rspec-on-rails)
David Chelimsky
dchelimsky at gmail.com
Wed Nov 29 10:43:35 EST 2006
Would you please submit this directly to the tracker?
http://rubyforge.org/tracker/?group_id=797
Thanks,
David
On 11/29/06, Steve Tooke <steve.tooke at gmail.com> wrote:
> Sorry for the duplicate, I managed to send the incomplete email by accident!
>
> 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 MyController < ApplicationController
>
> def index
> @page = Page.find(:first, :condtions => ['name = ?', params[:name]])
> show_404 and return unless @page
> render :action => :page
> end
>
> protected
> def show_404
> render( :file => "#{RAILS_ROOT}/public/404.html",
> :status => "404 Not Found")
> end
> end
>
> ----------------
>
> context "a GET to index with an unrecognised page" do
> controller_name :my_controller
>
> setup do
> Page.stub!(:find)
> end
>
> specify "should not assign a page" do
> get 'index', :name => 'broken'
> assigns['page'].should == nil
> end
>
> specify "should render 404 file" do
> controller.should_render :file => "#{RAILS_ROOT}/public/404.html",
> :status => "404 Not Found"
> get 'index', :name => 'broken'
> end
> end
>
> -------------
>
> Both of these specs will fail with an
> "ActionController::DoubleRenderError", demonstrating that the return
> call is being ignored.
>
> Regards,
> Steve
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>
More information about the rspec-devel
mailing list