aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-03-20 16:41:01 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-03-20 16:41:01 -0700
commitd1577cfe3d7f01f2876e3cbe682065012246697c (patch)
tree0fc5512f74f2c4938c0853d7444fc7112a695c8a
parent38d06478614adcf68a45947cb162c3152e2d7bb1 (diff)
parent2c8f34995378e4a18711cf5f947e8465227d3748 (diff)
downloadrails-d1577cfe3d7f01f2876e3cbe682065012246697c.tar.gz
rails-d1577cfe3d7f01f2876e3cbe682065012246697c.tar.bz2
rails-d1577cfe3d7f01f2876e3cbe682065012246697c.zip
Merge branch '3-2-stable' into fredwu-slow_view_loading_fix
* 3-2-stable: Merge pull request #9802 from newsline/fix-broken-action-missing Remove bad changelog entry from AR [ci skip] Wrong exception is occured when raising no translatable exception Don't crash exception translation w/ nil result attribute. Conflicts: actionpack/CHANGELOG.md
-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
-rw-r--r--activerecord/CHANGELOG.md5
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb4
-rw-r--r--activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb6
6 files changed, 32 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 19511225a0..9c872e5dec 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -6,6 +6,11 @@
*Fred Wu*
+* Fixed `ActionController#action_missing` not being called.
+ Fixes #9799.
+
+ *Janko Luin*
+
* `ActiveSupport::NumberHelper#number_to_human` returns the number unaltered when
the units hash does not contain the needed key, e.g. when the number provided is less
than the largest key proivided.
diff --git a/actionpack/lib/action_controller/metal/hide_actions.rb b/actionpack/lib/action_controller/metal/hide_actions.rb
index 109484d88c..1ded166491 100644
--- a/actionpack/lib/action_controller/metal/hide_actions.rb
+++ b/actionpack/lib/action_controller/metal/hide_actions.rb
@@ -28,7 +28,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 affa9a6add..a652d8ffad 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -86,6 +86,12 @@ end
class RecordIdentifierController < ActionController::Base
end
+class ActionMissingController < ActionController::Base
+ def action_missing(action)
+ render :text => "Response for #{action}"
+ end
+end
+
class ControllerClassTests < ActiveSupport::TestCase
def test_controller_path
@@ -196,6 +202,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
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index e55367662b..c0e0bb1dbc 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,5 +1,10 @@
## unreleased ##
+* Fix a problem wrong exception is occured
+ when raising no translatable exception in PostgreSQL.
+
+ *kennyj*
+
* Resets the postgres search path in the structure.sql after the structure
is dumped in order to find schema_migrations table when multiples schemas
are used.
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 8806693397..cbbb195458 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -1144,7 +1144,9 @@ module ActiveRecord
UNIQUE_VIOLATION = "23505"
def translate_exception(exception, message)
- case exception.result.error_field(PGresult::PG_DIAG_SQLSTATE)
+ return exception unless exception.respond_to?(:result)
+
+ case exception.result.try(:error_field, PGresult::PG_DIAG_SQLSTATE)
when UNIQUE_VIOLATION
RecordNotUnique.new(message, exception)
when FOREIGN_KEY_VIOLATION
diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
index 0de3786eb8..6c345cd8cc 100644
--- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
@@ -188,6 +188,12 @@ module ActiveRecord
assert_equal "DISTINCT posts.title, posts.updater_id AS alias_0", @connection.distinct("posts.title", ["posts.updater_id desc nulls last"])
end
+ def test_raise_error_when_cannot_translate_exception
+ assert_raise TypeError do
+ @connection.send(:log, nil) { @connection.execute(nil) }
+ end
+ end
+
private
def insert(ctx, data)
binds = data.map { |name, value|