Skip to content

Commit

Permalink
Merge branch '3-2-stable' into fredwu-slow_view_loading_fix
Browse files Browse the repository at this point in the history
* 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
tenderlove committed Mar 20, 2013
2 parents 38d0647 + 2c8f349 commit d1577cf
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions actionpack/CHANGELOG.md
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/metal/hide_actions.rb
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions actionpack/test/controller/base_test.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions 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.
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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|
Expand Down

0 comments on commit d1577cf

Please sign in to comment.