1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #14390 from huoxito/true-touch

Still touch associations when theres no timestamp
This commit is contained in:
Rafael Mendonça França 2014-03-25 15:13:22 -03:00
commit 833109cc99
2 changed files with 13 additions and 0 deletions

View file

@ -455,6 +455,8 @@ module ActiveRecord
changed_attributes.except!(*changes.keys)
primary_key = self.class.primary_key
self.class.unscoped.where(primary_key => self[primary_key]).update_all(changes) == 1
else
true
end
end

View file

@ -340,6 +340,17 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
assert_queries(1) { line_item.touch }
end
def test_belongs_to_with_touch_option_on_touch_without_updated_at_attributes
assert !LineItem.column_names.include?("updated_at")
line_item = LineItem.create!
invoice = Invoice.create!(line_items: [line_item])
initial = invoice.updated_at
line_item.touch
refute_equal initial, invoice.reload.updated_at
end
def test_belongs_to_with_touch_option_on_touch_and_removed_parent
line_item = LineItem.create!
Invoice.create!(line_items: [line_item])