Hi all;

Should Hobo's home_page method be returning a trailing "/" as well to be 
consistent with route helpers (i.e. "http://test.host/";)

Here's why I'm asking: Something simple tripped me up for a while with a 
Controller test. 

My test:

describe TitlesController do 

  it "Regular user should not be able to see Titles index" do
    controller_test_signin @user  #Defined in test_helper.rb
    get :index
    assert_redirected_to( root_url )
  end

In my environment/test.rb file, I have

  Rails.application.routes.default_url_options[:host] = 'test.host'

to satisfy url_for's demand for a 'host to link' to
(*ArgumentError: Missing host to link to! Please provide the :host 
parameter, set default_url_options[:host], or set :only_path to true*)


However, running this controller test using was giving me:

*Expected response to be a redirect to <http://test.host/> but was a 
redirect to <http://test.host>*

(Notice the absence of the "/" at the end of the actual redirect url?)

I tracked it down to my use of Hobo's home_page method in a before_filter I 
had in my ApplicationController:

  def lto_only  
    if !current_user.administrator? && !current_user.officer?
      redirect_to home_page 
      return
    end

It turns out that to get my assert_redirected_to test to pass, this needed 
to be:

  def lto_only  
    if !current_user.administrator? && !current_user.officer?
      redirect_to root_url 
      return
    end

Of course, my use of root_url requires me to have 'root' defined in my 
routes.rb file. 

  root :to => 'front#index'


Tim



-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to