rails
rails copied to clipboard
Validate option keys passed to #change()
Summary
DateTime#change
and Time#change
receive nearly identical keyword arguments, with one subtle difference: DateTime#change
also supports start:
.
The change
method silently ignores invalid/unsupported keyword arguments, which makes it error-prone to typos and makes transitioning legacy codebases from DateTime
to Time
difficult.
The same problem affects related classes Date
and TimeWithZone
.
This PR enforces that all arguments passed to change
are actually supported, and updates a stale comment to include :nsec
and :usec
as supported arguments to DateTime#change
.
👋 Hey @vlad-pisanov, would you mind rebasing your branch again please to address conflicts? Thanks!
I think we also need to require "active_support/core_ext/hash/keys.rb"
in both of the calculations.rb
files to make use of #assert_valid_keys
@adrianna-chang-shopify done! And thanks for the require
reminder 🙏