Skip to content

Commit

Permalink
Make the Action Pack tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Mendonça França committed Sep 25, 2012
1 parent df8df30 commit c9f89de
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 5 deletions.
2 changes: 2 additions & 0 deletions active_record-observers.gemspec
Expand Up @@ -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
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/active_record-observers/active_model/active_model.rb
@@ -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
2 changes: 1 addition & 1 deletion lib/active_record-observers/active_model/observing.rb
@@ -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'
Expand Down
1 change: 1 addition & 0 deletions lib/active_record-observers/activerecord/observer.rb
@@ -1,3 +1,4 @@
require 'active_record-observers/active_model/active_model'

module ActiveRecord
# = Active Record Observer
Expand Down
53 changes: 53 additions & 0 deletions test/actionpack/controller/filters_test.rb
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.