From 7a15fa72ae6781a509f297fdfa50f91eec8e9a1f Mon Sep 17 00:00:00 2001 From: Espen Antonsen Date: Mon, 25 Apr 2011 17:38:10 +0800 Subject: [PATCH] rails_root deprecated --- app/uploaders/file_uploader.rb | 2 +- test/functional/sessions_controller_test.rb | 82 --------------------- vendor/plugins/princely/lib/prince.rb | 2 +- 3 files changed, 2 insertions(+), 84 deletions(-) delete mode 100644 test/functional/sessions_controller_test.rb diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index 4b6080f..d724472 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -11,7 +11,7 @@ class FileUploader < CarrierWave::Uploader::Base storage :s3 def cache_dir - "#{RAILS_ROOT}/tmp/uploads" if ENV['HEROKU'] == 'true' + "#{Rails.root.to_s}/tmp/uploads" if ENV['HEROKU'] == 'true' end else storage :file diff --git a/test/functional/sessions_controller_test.rb b/test/functional/sessions_controller_test.rb deleted file mode 100644 index e53bcd8..0000000 --- a/test/functional/sessions_controller_test.rb +++ /dev/null @@ -1,82 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'sessions_controller' - -# Re-raise errors caught by the controller. -class SessionsController; def rescue_action(e) raise e end; end - -class SessionsControllerTest < ActionController::TestCase - # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead - # Then, you can remove it from this and the units test. - include AuthenticatedTestHelper - - fixtures :users - - def test_should_login_and_redirect - post :create, :login => 'quentin', :password => 'monkey' - assert session[:user_id] - assert_response :redirect - end - - def test_should_fail_login_and_not_redirect - post :create, :login => 'quentin', :password => 'bad password' - assert_nil session[:user_id] - assert_response :success - end - - def test_should_logout - login_as :quentin - get :destroy - assert_nil session[:user_id] - assert_response :redirect - end - - def test_should_remember_me - @request.cookies["auth_token"] = nil - post :create, :login => 'quentin', :password => 'monkey', :remember_me => "1" - assert_not_nil @response.cookies["auth_token"] - end - - def test_should_not_remember_me - @request.cookies["auth_token"] = nil - post :create, :login => 'quentin', :password => 'monkey', :remember_me => "0" - puts @response.cookies["auth_token"] - assert @response.cookies["auth_token"].blank? - end - - def test_should_delete_token_on_logout - login_as :quentin - get :destroy - assert @response.cookies["auth_token"].blank? - end - - def test_should_login_with_cookie - users(:quentin).remember_me - @request.cookies["auth_token"] = cookie_for(:quentin) - get :new - assert @controller.send(:logged_in?) - end - - def test_should_fail_expired_cookie_login - users(:quentin).remember_me - users(:quentin).update_attribute :remember_token_expires_at, 5.minutes.ago - @request.cookies["auth_token"] = cookie_for(:quentin) - get :new - assert !@controller.send(:logged_in?) - end - - def test_should_fail_cookie_login - users(:quentin).remember_me - @request.cookies["auth_token"] = auth_token('invalid_auth_token') - get :new - assert !@controller.send(:logged_in?) - end - - protected - def auth_token(token) - CGI::Cookie.new('name' => 'auth_token', 'value' => token) - end - - def cookie_for(user) - auth_token users(user).remember_token - end -end diff --git a/vendor/plugins/princely/lib/prince.rb b/vendor/plugins/princely/lib/prince.rb index b46dc59..781b7e7 100644 --- a/vendor/plugins/princely/lib/prince.rb +++ b/vendor/plugins/princely/lib/prince.rb @@ -25,7 +25,7 @@ class Prince # Finds where the application lives, so we can call it. @exe_path = `which prince`.chomp @style_sheets = '' - @log_file = "#{RAILS_ROOT}/log/prince.log" + @log_file = "#{Rails.root.to_s}/log/prince.log" @logger = RAILS_DEFAULT_LOGGER end