Sehnsucht nach Ruhe
Filed under: German, Inspiration on June 29th, 2008 | No Comments »
Filed under: German, Inspiration on June 29th, 2008 | No Comments »
If you want to provide a username and password for a HTTP Basic Authentication in one of your functional tests, simply use the following:
def test_should_get_index
@request.env["HTTP_AUTHORIZATION"] = “Basic ” + Base64::encode64(”username:password”)
get :index
assert_response :success
assert_not_nil assigns(:articles)
end
Keywords: rails test, functionals, authorization, basic http authentication, how to test
Filed under: English, Rails 2.0, Rails 2.1, Ruby, Ruby 1.8, Ruby On Rails on June 23rd, 2008 | 1 Comment »
If you need to show a 404 error page from your controller without using an exception, this could help:
render :file => “#{RAILS_ROOT}/public/404.html”, :status => 404 and return
Filed under: English, Ruby, Ruby On Rails on June 21st, 2008 | No Comments »
I’ve tried to use the new authenticate_or_request_with_http_basic function of Rails 2 to include a simple authentication for some special pages in an application. But Apache kept refusing authorization, even if the authenticate_or_request_with_http_basic-block was set to be always true.
To fix this, add or change this in your public/.htaccess (if using FastCGI):
RewriteRule ^(.*)$ dispatch.fcgi [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]
Keywords: rails2 rails [...]
Filed under: English, Rails 2.0, Rails 2.1, Ruby, Ruby On Rails on June 12th, 2008 | No Comments »