Content

File: October 2009

Every once in a while I see this little code snippet show up somewhere: script_console_running = ENV.include?(‘RAILS_ENV’) && IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?(‘console_with_helpers’) rails_running = ENV.include?(‘RAILS_ENV’) && !(IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?(‘console_with_helpers’)) irb_standalone_running = !script_console_running && !rails_running if script_console_running require ‘logger’ Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT)) end You see, if you drop this little gem in ~/.irbrc you’ll start getting the SQL [...]

 ::  (Read the rest of this)

A basic authentication scheme should go to some length to do a little bit of remembering in the event your user hits a restricted page before they are actually authenticated. First, some context. I’ve got this in my ApplicationController: def require_user unless current_user store_location redirect_to login_path return false end end def store_location session[:return_to] = request.request_uri [...]

1 comment  ::  (Read the rest of this)

2009-10-09 :: admin // tests
coverage testing

Here’s a little bit of rcov love to ensure that your test suites are covering what they should be. http://gist.github.com/206379 This should give you: rake test:rcov rake test:rcov:units rake test:rcov:functionals rake test:rcov:helpers …with a tailored coverage report for each. Hopefully this can give you a better idea of where your tests are lacking. As it [...]

 ::  (Read the rest of this)