tracks/vendor/rails/actionpack/lib/action_view/test_case.rb
Luke Melia 901a58f8a3 Upgraded to Rails 2.1. This can have wide ranging consequences, so please help track down any issues introduced by the upgrade. Requires environment.rb modifications.
Changes you will need to make:

 * In your environment.rb, you will need to update references to a few files per environment.rb.tmpl
 * In your environment.rb, you will need to specify the local time zone of the computer that is running your Tracks install.

Other notes on my changes:

 * Modified our code to take advantage of Rails 2.1's slick time zone support.
 * Upgraded will_paginate for compatibility
 * Hacked the Selenium on Rails plugin, which has not been updated in some time and does not support Rails 2.1
 * Verified that all tests pass on my machine, including Selenium tests -- I'd like confirmation from others, too.
2008-06-17 01:13:25 -04:00

58 lines
1.5 KiB
Ruby

require 'active_support/test_case'
module ActionView
class TestCase < ActiveSupport::TestCase
class_inheritable_accessor :helper_class
@@helper_class = nil
class << self
def tests(helper_class)
self.helper_class = helper_class
end
def helper_class
if current_helper_class = read_inheritable_attribute(:helper_class)
current_helper_class
else
self.helper_class = determine_default_helper_class(name)
end
end
def determine_default_helper_class(name)
name.sub(/Test$/, '').constantize
rescue NameError
nil
end
end
ActionView::Base.helper_modules.each do |helper_module|
include helper_module
end
include ActionController::PolymorphicRoutes
include ActionController::RecordIdentifier
setup :setup_with_helper_class
def setup_with_helper_class
if helper_class && !self.class.ancestors.include?(helper_class)
self.class.send(:include, helper_class)
end
end
class TestController < ActionController::Base
attr_accessor :request, :response
def initialize
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
end
private
def method_missing(selector, *args)
controller = TestController.new
return controller.send!(selector, *args) if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
super
end
end
end