Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit d1577cfe3d7f01f2876e3cbe682065012246697c 2 parents 38d0647 + 2c8f349
Aaron Patterson tenderlove authored
5 actionpack/CHANGELOG.md
View
@@ -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.
2  actionpack/lib/action_controller/metal/hide_actions.rb
View
@@ -28,7 +28,7 @@ def hide_action(*args)
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
12 actionpack/test/controller/base_test.rb
View
@@ -86,6 +86,12 @@ def url_options
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 @@ def test_get_on_hidden_should_fail
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
5 activerecord/CHANGELOG.md
View
@@ -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.
4 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
View
@@ -1144,7 +1144,9 @@ def postgresql_version
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
6 activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
View
@@ -188,6 +188,12 @@ def test_distinct_with_nulls
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|
Please sign in to comment.
Something went wrong with that request. Please try again.