Skip to content

Commit

Permalink
Added some unit tests #706
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@775 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Feb 23, 2005
1 parent 9a929b6 commit 11a2bb9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions actionpack/test/controller/filters_test.rb
Expand Up @@ -179,6 +179,30 @@ def initialize
append_around_filter AppendedAroundFilter.new
end

class MixedSpecializationController < ActionController::Base
class OutOfOrder < StandardError; end

before_filter :first
before_filter :second, :only => :foo

def foo
render_text 'foo'
end

def bar
render_text 'bar'
end

protected
def first
@first = true
end

def second
raise OutOfOrder unless @first
end
end


def test_added_filter_to_inheritance_graph
assert_equal [ :fire_flash, :ensure_login ], TestController.before_filters
Expand Down Expand Up @@ -285,6 +309,18 @@ def test_rendering_breaks_filtering_chain
assert !response.template.assigns["ran_action"]
end

def test_filters_with_mixed_specialization_run_in_order
assert_nothing_raised do
response = test_process(MixedSpecializationController, 'bar')
assert_equal 'bar', response.body
end

assert_nothing_raised do
response = test_process(MixedSpecializationController, 'foo')
assert_equal 'foo', response.body
end
end

private
def test_process(controller, action = "show")
request = ActionController::TestRequest.new
Expand Down

0 comments on commit 11a2bb9

Please sign in to comment.