aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanko Luin <janko@luin.se>2013-03-19 12:55:26 +0100
committerJanko Luin <janko@luin.se>2013-03-20 08:20:54 +0100
commit0dfa6cb97c77775164f8009d6be82e697bd25add (patch)
tree53030ad666b0879bfebc183f86dfe679d4710387
parent66ac0c567dfcc6a31568d270dba335eb1971abc3 (diff)
downloadrails-0dfa6cb97c77775164f8009d6be82e697bd25add.tar.gz
rails-0dfa6cb97c77775164f8009d6be82e697bd25add.tar.bz2
rails-0dfa6cb97c77775164f8009d6be82e697bd25add.zip
Fix broken ActionController#action_missing
A recent change introduced the assumption that all controller actions are known beforehand, which is not true when using action_missing.
-rw-r--r--actionpack/CHANGELOG.md5
-rw-r--r--actionpack/lib/action_controller/metal/hide_actions.rb2
-rw-r--r--actionpack/test/controller/base_test.rb12
3 files changed, 18 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 97bd2bf97f..0dfda417c2 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Fixed ActionController#action_missing not being called.
+ Fixes GH#9799.
+
+ *Janko Luin*
+
* Ensure that digest authentication responds with a 401 status when a basic
header is received.
diff --git a/actionpack/lib/action_controller/metal/hide_actions.rb b/actionpack/lib/action_controller/metal/hide_actions.rb
index 2aa6b7adaf..af36ffa240 100644
--- a/actionpack/lib/action_controller/metal/hide_actions.rb
+++ b/actionpack/lib/action_controller/metal/hide_actions.rb
@@ -27,7 +27,7 @@ module ActionController
end
def visible_action?(action_name)
- action_methods.include?(action_name)
+ not hidden_actions.include?(action_name)
end
# Overrides AbstractController::Base#action_methods to remove any methods
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index 9b42e7631f..d4f18d55a6 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -68,6 +68,12 @@ class RecordIdentifierWithoutDeprecationController < ActionController::Base
include ActionView::RecordIdentifier
end
+class ActionMissingController < ActionController::Base
+ def action_missing(action)
+ render :text => "Response for #{action}"
+ end
+end
+
class ControllerClassTests < ActiveSupport::TestCase
def test_controller_path
@@ -186,6 +192,12 @@ class PerformActionTest < ActionController::TestCase
assert_raise(AbstractController::ActionNotFound) { get :hidden_action }
assert_raise(AbstractController::ActionNotFound) { get :another_hidden_action }
end
+
+ def test_action_missing_should_work
+ use_controller ActionMissingController
+ get :arbitrary_action
+ assert_equal "Response for arbitrary_action", @response.body
+ end
end
class UrlOptionsTest < ActionController::TestCase