diff options
-rw-r--r-- | actionpack/CHANGELOG.md | 9 | ||||
-rw-r--r-- | actionview/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations/confirmation.rb | 2 | ||||
-rw-r--r-- | activerecord/CHANGELOG.md | 5 | ||||
-rw-r--r-- | activerecord/lib/active_record/type/binary.rb | 10 | ||||
-rw-r--r-- | activerecord/lib/active_record/type/serialized.rb | 5 | ||||
-rw-r--r-- | activerecord/test/cases/dirty_test.rb | 16 | ||||
-rw-r--r-- | guides/source/4_2_release_notes.md | 8 | ||||
-rw-r--r-- | guides/source/association_basics.md | 16 | ||||
-rw-r--r-- | railties/CHANGELOG.md | 9 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 10 | ||||
-rw-r--r-- | railties/test/generators/actions_test.rb | 10 |
12 files changed, 79 insertions, 27 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 050ec5e649..32a6d5449c 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,6 +1,7 @@ * Allow `config.action_dispatch.trusted_proxies` to accept an IPAddr object. Example: + # config/environments/production.rb config.action_dispatch.trusted_proxies = IPAddr.new('4.8.15.0/16') @@ -55,7 +56,7 @@ *Prem Sichanugrist* -* Deprecated TagAssertions. +* Deprecated `TagAssertions`. *Kasper Timm Hansen* @@ -87,11 +88,11 @@ If you render a different template, you can now pass the `:template` option to include its digest instead: - fresh_when @post, template: 'widgets/show' + fresh_when @post, template: 'widgets/show' Pass `template: false` to skip the lookup. To turn this off entirely, set: - config.action_controller.etag_with_template_digest = false + config.action_controller.etag_with_template_digest = false *Jeremy Kemper* @@ -145,7 +146,7 @@ *Godfrey Chan* * Prepend a JS comment to JSONP callbacks. Addresses CVE-2014-4671 - ("Rosetta Flash") + ("Rosetta Flash"). *Greg Campbell* diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 396249ac37..f5c520937c 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -26,11 +26,11 @@ *Joel Junström*, *Lucas Uyezu* * Return an absolute instead of relative path from an asset url in the case - of the `asset_host` proc returning nil + of the `asset_host` proc returning nil. *Jolyon Pawlyn* -* Fix `html_escape_once` to properly handle hex escape sequences (e.g. ᨫ) +* Fix `html_escape_once` to properly handle hex escape sequences (e.g. ᨫ). *John F. Douthat* @@ -63,7 +63,7 @@ *Zuhao Wan* -* Bring `cache_digest` rake tasks up-to-date with the latest API changes +* Bring `cache_digest` rake tasks up-to-date with the latest API changes. *Jiri Pospisil* diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb index a51523912f..1b11c28087 100644 --- a/activemodel/lib/active_model/validations/confirmation.rb +++ b/activemodel/lib/active_model/validations/confirmation.rb @@ -54,7 +54,7 @@ module ActiveModel # # Configuration options: # * <tt>:message</tt> - A custom error message (default is: "doesn't match - # confirmation"). + # <tt>%{translated_attribute_name}</tt>"). # # There is also a list of default options supported by every validator: # +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+. diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index b9af8584ae..9d6eb6ad21 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -12,7 +12,7 @@ * Fix has_many :through relation merging failing when dynamic conditions are passed as a lambda with an arity of one. - Fixes #16128 + Fixes #16128. *Agis Anastasopoulos* @@ -27,6 +27,7 @@ will not rescue those errors anymore, and just bubble them up, as the other callbacks. This adds a opt-in flag to enable that behaviour, of not rescuing the errors. + Example: # For not swallow errors in after_commit/after_rollback callbacks. @@ -51,7 +52,7 @@ * Fix regression on after_commit that didnt fire when having nested transactions. - Fixes #16425 + Fixes #16425. *arthurnn* diff --git a/activerecord/lib/active_record/type/binary.rb b/activerecord/lib/active_record/type/binary.rb index d29ff4e494..005a48ef0d 100644 --- a/activerecord/lib/active_record/type/binary.rb +++ b/activerecord/lib/active_record/type/binary.rb @@ -22,6 +22,11 @@ module ActiveRecord Data.new(super) end + def changed_in_place?(raw_old_value, value) + old_value = type_cast_from_database(raw_old_value) + old_value != value + end + class Data # :nodoc: def initialize(value) @value = value.to_s @@ -30,10 +35,15 @@ module ActiveRecord def to_s @value end + alias_method :to_str, :to_s def hex @value.unpack('H*')[0] end + + def ==(other) + other == to_s || super + end end end end diff --git a/activerecord/lib/active_record/type/serialized.rb b/activerecord/lib/active_record/type/serialized.rb index abeea769c4..5b512433b0 100644 --- a/activerecord/lib/active_record/type/serialized.rb +++ b/activerecord/lib/active_record/type/serialized.rb @@ -26,6 +26,11 @@ module ActiveRecord end end + def changed_in_place?(raw_old_value, value) + return false if value.nil? + subtype.changed_in_place?(raw_old_value, coder.dump(value)) + end + def accessor ActiveRecord::Store::IndifferentHashAccessor end diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb index 0c77eedb52..5cb6b97117 100644 --- a/activerecord/test/cases/dirty_test.rb +++ b/activerecord/test/cases/dirty_test.rb @@ -682,6 +682,22 @@ class DirtyTest < ActiveRecord::TestCase assert_not pirate.changed? end + test "in place mutation for binary" do + klass = Class.new(ActiveRecord::Base) do + self.table_name = :binaries + serialize :data + end + + klass.create!(data: "foo") + binary = klass.first + + assert_not binary.changed? + + binary.data << "bar" + + assert binary.changed? + end + private def with_partial_writes(klass, on = true) old = klass.partial_writes? diff --git a/guides/source/4_2_release_notes.md b/guides/source/4_2_release_notes.md index 5401b34542..b2f64453dd 100644 --- a/guides/source/4_2_release_notes.md +++ b/guides/source/4_2_release_notes.md @@ -60,7 +60,7 @@ TODO: add some technical details ### Web Console -New applications generated from Rails 4.2 now comes with the Web Console gem by +New applications generated from Rails 4.2 now come with the Web Console gem by default. Web Console is a set of debugging tools for your Rails application. It will add @@ -123,7 +123,7 @@ Please refer to the [Changelog][railties] for detailed changes. ### Notable changes * Introduced `web-console` in the default application Gemfile. - ([Pull Request](https://github.com/rails/rails/pull/16532)) + ([Pull Request](https://github.com/rails/rails/pull/11667)) * Added a `required` option to the model generator for associations. ([Pull Request](https://github.com/rails/rails/pull/16062)) @@ -256,9 +256,9 @@ Please refer to the [Changelog][action-pack] for detailed changes. skip_filter => skip_action_callback ``` - If your application is depending on these methods, you should use the + If your application currently depends on these methods, you should use the replacement `*_action` methods instead. These methods will be deprecated in - the future and eventually removed from Rails. + the future and will eventually be removed from Rails. (Commit [1](https://github.com/rails/rails/commit/6c5f43bab8206747a8591435b2aa0ff7051ad3de), [2](https://github.com/rails/rails/commit/489a8f2a44dc9cea09154ee1ee2557d1f037c7d4)) diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index daf4113b66..c9e0fcd939 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -1321,9 +1321,9 @@ When you declare a `has_many` association, the declaring class automatically gai * `collection<<(object, ...)` * `collection.delete(object, ...)` * `collection.destroy(object, ...)` -* `collection=objects` +* `collection=(objects)` * `collection_singular_ids` -* `collection_singular_ids=ids` +* `collection_singular_ids=(ids)` * `collection.clear` * `collection.empty?` * `collection.size` @@ -1399,7 +1399,7 @@ The `collection.destroy` method removes one or more objects from the collection WARNING: Objects will _always_ be removed from the database, ignoring the `:dependent` option. -##### `collection=objects` +##### `collection=(objects)` The `collection=` method makes the collection contain only the supplied objects, by adding and deleting as appropriate. @@ -1411,7 +1411,7 @@ The `collection_singular_ids` method returns an array of the ids of the objects @order_ids = @customer.order_ids ``` -##### `collection_singular_ids=ids` +##### `collection_singular_ids=(ids)` The `collection_singular_ids=` method makes the collection contain only the objects identified by the supplied primary key values, by adding and deleting as appropriate. @@ -1810,9 +1810,9 @@ When you declare a `has_and_belongs_to_many` association, the declaring class au * `collection<<(object, ...)` * `collection.delete(object, ...)` * `collection.destroy(object, ...)` -* `collection=objects` +* `collection=(objects)` * `collection_singular_ids` -* `collection_singular_ids=ids` +* `collection_singular_ids=(ids)` * `collection.clear` * `collection.empty?` * `collection.size` @@ -1895,7 +1895,7 @@ The `collection.destroy` method removes one or more objects from the collection @part.assemblies.destroy(@assembly1) ``` -##### `collection=objects` +##### `collection=(objects)` The `collection=` method makes the collection contain only the supplied objects, by adding and deleting as appropriate. @@ -1907,7 +1907,7 @@ The `collection_singular_ids` method returns an array of the ids of the objects @assembly_ids = @part.assembly_ids ``` -##### `collection_singular_ids=ids` +##### `collection_singular_ids=(ids)` The `collection_singular_ids=` method makes the collection contain only the objects identified by the supplied primary key values, by adding and deleting as appropriate. diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 2a09ccf61a..7d6521b2a8 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,6 +1,13 @@ +* Fix a bug in the `gem` method for Rails templates when non-String options + are used. + + Fixes #16709. + + *Yves Senn* + * The [web-console](https://github.com/rails/web-console) gem is now installed by default for new applications. It can help you debug - development exceptions by spawnig an interactive console in its cause + development exceptions by spawning an interactive console in its cause binding. *Ryan Dao*, *Genadi Samokovarov*, *Guillermo Iguaran* diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 4709914947..b2c9d12996 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -268,11 +268,13 @@ module Rails # Surround string with single quotes if there is no quotes. # Otherwise fall back to double quotes - def quote(str) - if str.include?("'") - str.inspect + def quote(value) + return value.inspect unless value.is_a? String + + if value.include?("'") + value.inspect else - "'#{str}'" + "'#{value}'" end end end diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index a4337926d1..2206e389b5 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -79,6 +79,16 @@ class ActionsTest < Rails::Generators::TestCase assert_file 'Gemfile', /gem 'rspec', github: 'dchelimsky\/rspec', tag: '1\.2\.9\.rc1'/ end + def test_gem_with_non_string_options + run_generator + + action :gem, 'rspec', require: false + action :gem, 'rspec-rails', group: [:development, :test] + + assert_file 'Gemfile', /^gem 'rspec', require: false$/ + assert_file 'Gemfile', /^gem 'rspec-rails', group: \[:development, :test\]$/ + end + def test_gem_falls_back_to_inspect_if_string_contains_single_quote run_generator |