Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add test for dynamic dispatch based on action_name accessor.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1757 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit afbf54bc3dc8f9d1aeb670d927097a46e78c1515 1 parent bd832a2
@jeremy jeremy authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 actionpack/test/controller/filters_test.rb
View
21 actionpack/test/controller/filters_test.rb
@@ -203,6 +203,18 @@ def second
end
end
+ class DynamicDispatchController < ActionController::Base
+ before_filter :choose
+
+ %w(foo bar baz).each do |action|
+ define_method(action) { render :text => action }
+ end
+
+ private
+ def choose
+ self.action_name = params[:choose]
+ end
+ end
def test_added_filter_to_inheritance_graph
assert_equal [ :fire_flash, :ensure_login ], TestController.before_filters
@@ -321,6 +333,15 @@ def test_filters_with_mixed_specialization_run_in_order
end
end
+ def test_dynamic_dispatch
+ %w(foo bar baz).each do |action|
+ request = ActionController::TestRequest.new
+ request.query_parameters[:choose] = action
+ response = DynamicDispatchController.process(request, ActionController::TestResponse.new)
+ assert_equal action, response.body
+ end
+ end
+
private
def test_process(controller, action = "show")
request = ActionController::TestRequest.new
Please sign in to comment.
Something went wrong with that request. Please try again.