Permalink
Browse files

Make the Action Pack tests pass

  • Loading branch information...
1 parent df8df30 commit c9f89dedc3bc6a597d868988797986c0e95434d4 Rafael Mendonça França committed Sep 25, 2012
@@ -18,6 +18,8 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'minitest', '>= 3'
gem.add_development_dependency 'mocha'
gem.add_development_dependency 'activerecord', '~> 4.0.0.beta'
+ gem.add_development_dependency 'activemodel', '~> 4.0.0.beta'
gem.add_development_dependency 'actionmailer', '~> 4.0.0.beta'
+ gem.add_development_dependency 'actionpack', '~> 4.0.0.beta'
gem.add_development_dependency 'sqlite3', '~> 1.3'
end
@@ -2,8 +2,8 @@ module ActionController #:nodoc:
module Caching
eager_autoload do
- autoload :Sweeper, 'action_controller/caching/sweeping'
- autoload :Sweeping, 'action_controller/caching/sweeping'
+ autoload :Sweeper, 'active_record-observers/actionpack/action_controller/caching/sweeping'
+ autoload :Sweeping, 'active_record-observers/actionpack/action_controller/caching/sweeping'
end
include Sweeping if defined?(ActiveRecord)
@@ -1,4 +1,4 @@
module ActiveModel
- autoload :Observer, 'active_model/observing'
- autoload :Observing
+ autoload :Observer, 'active_record-observers/active_model/observing'
+ autoload :Observing, 'active_record-observers/active_model/observing'
end
@@ -1,5 +1,5 @@
require 'singleton'
-require 'active_model/observer_array'
+require 'active_record-observers/active_model/observer_array'
require 'active_support/core_ext/module/aliasing'
require 'active_support/core_ext/module/remove_method'
require 'active_support/core_ext/string/inflections'
@@ -1,3 +1,4 @@
+require 'active_record-observers/active_model/active_model'
module ActiveRecord
# = Active Record Observer
@@ -1,5 +1,39 @@
+require 'minitest/autorun'
+require 'action_controller'
+require 'active_record-observers/activerecord/observer'
+require 'active_record-observers/actionpack/action_controller/caching'
+
+SharedTestRoutes = ActionDispatch::Routing::RouteSet.new
+
+module ActionController
+ class Base
+ include SharedTestRoutes.url_helpers
+ end
+end
+
class FilterTest < ActionController::TestCase
+ class TestController < ActionController::Base
+ before_filter :ensure_login
+ after_filter :clean_up
+
+ def show
+ render :inline => "ran action"
+ end
+
+ private
+ def ensure_login
+ @ran_filter ||= []
+ @ran_filter << "ensure_login"
+ end
+
+ def clean_up
+ @ran_after_filter ||= []
+ @ran_after_filter << "clean_up"
+ end
+ end
+
class ::AppSweeper < ActionController::Caching::Sweeper; end
+
class SweeperTestController < ActionController::Base
cache_sweeper :app_sweeper
def show
@@ -11,6 +45,16 @@ def error
end
end
+ def setup
+ @routes = SharedTestRoutes
+
+ @routes.draw do
+ get ':controller(/:action)'
+ end
+
+ super
+ end
+
def test_sweeper_should_not_ignore_no_method_error
sweeper = ActionController::Caching::Sweeper.send(:new)
assert_raise NoMethodError do
@@ -39,5 +83,14 @@ def test_after_method_of_sweeper_should_always_return_nil
sweeper = ActionController::Caching::Sweeper.send(:new)
assert_nil sweeper.after(TestController.new)
end
+
+ private
+ def test_process(controller, action = "show")
+ @controller = controller.is_a?(Class) ? controller.new : controller
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+
+ process(action)
+ end
end

0 comments on commit c9f89de

Please sign in to comment.