diff options
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 11 | ||||
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/quoting.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/transactions.rb | 8 | ||||
-rw-r--r-- | activerecord/test/cases/connection_adapters/quoting_test.rb | 13 | ||||
-rw-r--r-- | activerecord/test/cases/transaction_callbacks_test.rb | 31 | ||||
-rw-r--r-- | activesupport/CHANGELOG.md | 55 |
7 files changed, 97 insertions, 31 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 8fc0f283fc..58c67e2cbe 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -460,12 +460,12 @@ module ActionDispatch normalize_options! normalize_controller_action_id! use_relative_controller! - controller.sub!(%r{^/}, '') if controller + normalize_controller! handle_nil_action! end def controller - @controller ||= @options[:controller] + @options[:controller] end def current_controller @@ -522,10 +522,15 @@ module ActionDispatch old_parts = current_controller.split('/') size = controller.count("/") + 1 parts = old_parts[0...-size] << controller - @controller = @options[:controller] = parts.join("/") + @options[:controller] = parts.join("/") end end + # Remove leading slashes from controllers + def normalize_controller! + @options[:controller] = controller.sub(%r{^/}, '') if controller + end + # This handles the case of :action => nil being explicitly passed. # It is identical to :action => "index" def handle_nil_action! diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index e5345754cd..d356187ca8 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -829,6 +829,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal original_options, options end + def test_url_for_does_not_modify_controller + controller = '/projects' + options = {:controller => controller, :action => 'status', :only_path => true} + url = url_for(options) + + assert_equal '/projects/status', url + assert_equal '/projects', controller + end + # tests the arguments modification free version of define_hash_access def test_named_route_with_no_side_effects original_options = { :host => 'test.host' } diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb index 44ac37c498..6f9f0399db 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb @@ -34,6 +34,7 @@ module ActiveRecord when Numeric then value.to_s when Date, Time then "'#{quoted_date(value)}'" when Symbol then "'#{quote_string(value.to_s)}'" + when Class then "'#{value.to_s}'" else "'#{quote_string(YAML.dump(value))}'" end diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 743dfc5a38..64e5640791 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -302,12 +302,8 @@ module ActiveRecord def remember_transaction_record_state #:nodoc: @_start_transaction_state ||= {} @_start_transaction_state[:id] = id if has_attribute?(self.class.primary_key) - unless @_start_transaction_state.include?(:new_record) - @_start_transaction_state[:new_record] = @new_record - end - unless @_start_transaction_state.include?(:destroyed) - @_start_transaction_state[:destroyed] = @destroyed - end + @_start_transaction_state[:new_record] = @new_record + @_start_transaction_state[:destroyed] = @destroyed @_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) + 1 end diff --git a/activerecord/test/cases/connection_adapters/quoting_test.rb b/activerecord/test/cases/connection_adapters/quoting_test.rb new file mode 100644 index 0000000000..59dcb96ebc --- /dev/null +++ b/activerecord/test/cases/connection_adapters/quoting_test.rb @@ -0,0 +1,13 @@ +require "cases/helper" + +module ActiveRecord + module ConnectionAdapters + module Quoting + class QuotingTest < ActiveRecord::TestCase + def test_quoting_classes + assert_equal "'Object'", AbstractAdapter.new(nil).quote(Object) + end + end + end + end +end diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb index f8b3e01a49..9846f5b12d 100644 --- a/activerecord/test/cases/transaction_callbacks_test.rb +++ b/activerecord/test/cases/transaction_callbacks_test.rb @@ -290,3 +290,34 @@ class TransactionObserverCallbacksTest < ActiveRecord::TestCase assert_equal %w{ after_rollback }, topic.history end end + +class SaveFromAfterCommitBlockTest < ActiveRecord::TestCase + self.use_transactional_fixtures = false + + class TopicWithSaveInCallback < ActiveRecord::Base + self.table_name = :topics + after_commit :cache_topic, :on => :create + after_commit :call_update, :on => :update + attr_accessor :cached, :record_updated + + def call_update + self.record_updated = true + end + + def cache_topic + unless cached + self.cached = true + self.save + else + self.cached = false + end + end + end + + def test_after_commit_in_save + topic = TopicWithSaveInCallback.new() + topic.save + assert_equal true, topic.cached + assert_equal true, topic.record_updated + end +end diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index b02cefa600..c0d780789a 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,41 +1,52 @@ ## Rails 4.0.0 (unreleased) ## -* `deep_dup` works more expectedly now and duplicates also values in +Hash+ instances and elements in +Array+ instances. *Alexey Gaziev* +* `deep_dup` works more expectedly now and duplicates also values in +Hash+ instances and elements in +Array+ instances. *Alexey Gaziev* -* Inflector no longer applies ice -> ouse to words like slice, police, ets *Wes Morgan* +* Inflector no longer applies ice -> ouse to words like slice, police, ets *Wes Morgan* -* Add `ActiveSupport::Deprecations.behavior = :silence` to completely ignore Rails runtime deprecations *twinturbo* +* Add `ActiveSupport::Deprecations.behavior = :silence` to completely ignore Rails runtime deprecations *twinturbo* -* Make Module#delegate stop using `send` - can no longer delegate to private methods. *dasch* +* Make Module#delegate stop using `send` - can no longer delegate to private methods. *dasch* -* AS::Callbacks: deprecate `:rescuable` option. *Bogdan Gusiev* +* AS::Callbacks: deprecate `:rescuable` option. *Bogdan Gusiev* -* Adds Integer#ordinal to get the ordinal suffix string of an integer. *Tim Gildea* +* Adds Integer#ordinal to get the ordinal suffix string of an integer. *Tim Gildea* -* AS::Callbacks: `:per_key` option is no longer supported +* AS::Callbacks: `:per_key` option is no longer supported -* `AS::Callbacks#define_callbacks`: add `:skip_after_callbacks_if_terminated` option. +* `AS::Callbacks#define_callbacks`: add `:skip_after_callbacks_if_terminated` option. -* Add html_escape_once to ERB::Util, and delegate escape_once tag helper to it. *Carlos Antonio da Silva* +* Add html_escape_once to ERB::Util, and delegate escape_once tag helper to it. *Carlos Antonio da Silva* -* Remove ActiveSupport::TestCase#pending method, use `skip` instead. *Carlos Antonio da Silva* +* Remove ActiveSupport::TestCase#pending method, use `skip` instead. *Carlos Antonio da Silva* -* Deprecates the compatibility method Module#local_constant_names, - use Module#local_constants instead (which returns symbols). *fxn* +* Deprecates the compatibility method Module#local_constant_names, + use Module#local_constants instead (which returns symbols). *fxn* -* Deletes the compatibility method Module#method_names, - use Module#methods from now on (which returns symbols). *fxn* +* Deletes the compatibility method Module#method_names, + use Module#methods from now on (which returns symbols). *fxn* -* Deletes the compatibility method Module#instance_method_names, - use Module#instance_methods from now on (which returns symbols). *fxn* +* Deletes the compatibility method Module#instance_method_names, + use Module#instance_methods from now on (which returns symbols). *fxn* -* BufferedLogger is deprecated. Use ActiveSupport::Logger, or the logger - from Ruby stdlib. +* BufferedLogger is deprecated. Use ActiveSupport::Logger, or the logger + from Ruby stdlib. -* Unicode database updated to 6.1.0. +* Unicode database updated to 6.1.0. -* Adds `encode_big_decimal_as_string` option to force JSON serialization of BigDecimals as numeric instead - of wrapping them in strings for safety. +* Adds `encode_big_decimal_as_string` option to force JSON serialization of BigDecimals as numeric instead + of wrapping them in strings for safety. + + +## Rails 3.2.4 (unreleased) ## + +* Added #beginning_of_hour and #end_of_hour to Time and DateTime core + extensions. *Mark J. Titorenko* + + +## Rails 3.2.3 (March 30, 2012) ## + +* No changes. ## Rails 3.2.2 (March 1, 2012) ## @@ -230,7 +241,7 @@ * Hash.from_xml no longer loses attributes on tags containing only whitespace *André Arko* -## Rails 3.0.6 (April 5, 2011) ## +## Rails 3.0.6 (April 5, 2011) ## * No changes. |