mirror of https://github.com/rails/rails
Added some unit tests #706
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@775 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
9a929b67eb
commit
11a2bb91f5
|
@ -179,6 +179,30 @@ class FilterTest < Test::Unit::TestCase
|
||||||
append_around_filter AppendedAroundFilter.new
|
append_around_filter AppendedAroundFilter.new
|
||||||
end
|
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
|
def test_added_filter_to_inheritance_graph
|
||||||
assert_equal [ :fire_flash, :ensure_login ], TestController.before_filters
|
assert_equal [ :fire_flash, :ensure_login ], TestController.before_filters
|
||||||
|
@ -285,6 +309,18 @@ class FilterTest < Test::Unit::TestCase
|
||||||
assert !response.template.assigns["ran_action"]
|
assert !response.template.assigns["ran_action"]
|
||||||
end
|
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
|
private
|
||||||
def test_process(controller, action = "show")
|
def test_process(controller, action = "show")
|
||||||
request = ActionController::TestRequest.new
|
request = ActionController::TestRequest.new
|
||||||
|
|
Loading…
Reference in New Issue