1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/models
Sean Griffin 16ae3db5a5 Deprecate the behavior of AR::Dirty inside of after_(create|update|save) callbacks
We pretty frequently get bug reports that "dirty is broken inside of
after callbacks". Intuitively they are correct. You'd expect
`Model.after_save { puts changed? }; model.save` to do the same thing as
`model.save; puts model.changed?`, but it does not.

However, changing this goes much farther than just making the behavior
more intuitive. There are a _ton_ of places inside of AR that can be
drastically simplified with this change. Specifically, autosave
associations, timestamps, touch, counter cache, and just about anything
else in AR that works with callbacks have code to try to avoid "double
save" bugs which we will be able to flat out remove with this change.

We introduce two new sets of methods, both with names that are meant to
be more explicit than dirty. The first set maintains the old behavior,
and their names are meant to center that they are about changes that
occurred during the save that just happened. They are equivalent to
`previous_changes` when called outside of after callbacks, or once the
deprecation cycle moves.

The second set is the new behavior. Their names imply that they are
talking about changes from the database representation. The fact that
this is what we really care about became clear when looking at
`BelongsTo.touch_record` when tests were failing. I'm unsure that this
set of methods should be in the public API. Outside of after callbacks,
they are equivalent to the existing methods on dirty.

Dirty itself is not deprecated, nor are the methods inside of it. They
will only emit the warning when called inside of after callbacks. The
scope of this breakage is pretty large, but the migration path is
simple. Given how much this can improve our codebase, and considering
that it makes our API more intuitive, I think it's worth doing.
2016-11-01 13:16:33 -04:00
..
admin Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
autoloadable
publisher
admin.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
aircraft.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
arunit2_model.rb
author.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
auto_id.rb
binary.rb Add line endings to files which are missing them 2015-02-17 13:28:06 -07:00
bird.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
book.rb Add tests for ActiveRecord::Enum#enum when suffix specified 2016-09-12 08:52:02 +09:00
boolean.rb
bulb.rb Don't skip in-memory insertion of associations when loaded in validate 2016-09-29 14:57:31 -04:00
cake_designer.rb
car.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
carrier.rb Skip statement cache on through association reader 2015-08-12 21:17:30 -03:00
cat.rb Fix warning: method redefined; discarding old female 2016-03-12 17:06:43 +09:00
categorization.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
category.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
chef.rb Add missing source_type if provided on hmt which belongs to an sti record 2016-01-24 22:25:12 +05:30
citation.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
club.rb normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
college.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
column.rb
column_name.rb
comment.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
company.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
company_in_module.rb normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
computer.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
contact.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
content.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
contract.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
country.rb applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
course.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
customer.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
customer_carrier.rb Skip statement cache on through association reader 2015-08-12 21:17:30 -03:00
dashboard.rb
default.rb
department.rb
developer.rb applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
dog.rb
dog_lover.rb
doubloon.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
drink_designer.rb
edge.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
electron.rb Revert "Merge pull request #20080 from robertjlooby/fix_overwriting_by_dynamic_finders" 2015-09-09 06:08:57 -03:00
engine.rb normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
entrant.rb
essay.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
event.rb Add line endings to files which are missing them 2015-02-17 13:28:06 -07:00
eye.rb Deprecate the behavior of AR::Dirty inside of after_(create|update|save) callbacks 2016-11-01 13:16:33 -04:00
face.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
friendship.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
guid.rb Add line endings to files which are missing them 2015-02-17 13:28:06 -07:00
guitar.rb Errors can be indexed with nested attributes 2015-04-17 14:11:16 -04:00
hotel.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
image.rb Add foreign_type option for polymorphic has_one and has_many. 2014-12-08 18:13:15 -02:00
interest.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
invoice.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
item.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
job.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
joke.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
keyboard.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
legacy_thing.rb
lesson.rb
line_item.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
liquid.rb
man.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
matey.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
member.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
member_detail.rb Fix misleading errors for has_one through relations 2015-07-22 00:51:23 +03:00
member_type.rb
membership.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
mentor.rb normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
minimalistic.rb
minivan.rb applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
mixed_case_monkey.rb
mocktail_designer.rb Add missing source_type if provided on hmt which belongs to an sti record 2016-01-24 22:25:12 +05:30
molecule.rb
movie.rb
node.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
notification.rb Ensure suppressor runs before validations 2016-02-24 14:33:22 -05:00
order.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
organization.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
owner.rb applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
parrot.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
person.rb Add Style/EmptyLines in .rubocop.yml and remove extra empty lines 2016-08-07 17:50:59 +09:00
personal_legacy_thing.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
pet.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
pet_treasure.rb Fix undefined method `owners' for NullPreloader:Class 2016-04-06 00:46:55 -03:00
pirate.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
possession.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
post.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
price_estimate.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
professor.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
project.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
publisher.rb
randomly_named_c1.rb Fixes #18492 2015-01-14 21:36:58 +05:30
rating.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
reader.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
recipe.rb Fix leaky chain on polymorphic association 2015-03-15 10:39:42 -04:00
record.rb
reference.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
reply.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
ship.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
ship_part.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
shop.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
shop_account.rb Skip statement cache on through association reader 2015-08-12 21:17:30 -03:00
speedometer.rb
sponsor.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
string_key_object.rb
student.rb
subject.rb code gardening: removes redundant selfs 2016-08-08 01:12:38 +02:00
subscriber.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
subscription.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
tag.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
tagging.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
task.rb
topic.rb code gardening: removes redundant selfs 2016-08-08 01:12:38 +02:00
toy.rb
traffic_light.rb
treasure.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
treaty.rb applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
tree.rb Add pending test for the great-grandparent touching bug from #19324 2015-06-25 14:23:06 +02:00
tuning_peg.rb Errors can be indexed with nested attributes 2015-04-17 14:11:16 -04:00
tyre.rb Don't perform statement caching for find when called from a scope 2014-12-22 15:38:58 -07:00
user.rb applies new string literal convention in activerecord/test 2016-08-06 18:26:53 +02:00
uuid_child.rb
uuid_item.rb Fix issue #23625 2016-02-18 00:32:38 -05:00
uuid_parent.rb
vegetables.rb applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
vehicle.rb normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
vertex.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
warehouse_thing.rb
wheel.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
without_table.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
zine.rb modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00