-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default version timestamp to "updated_at" #26
Conversation
Hi! One caveat: we should handle Thus we have to check that the And it would be great to make this feature configurable (i.e. custom ts column name). |
Thanks for the review. Going to update the PR soon. |
It would be great) |
spec/support/test_helpers.rb
Outdated
@@ -1,3 +1,4 @@ | |||
# rubocop:disable Lint/HandleExceptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/UnneededDisable: Unnecessary disabling of Lint/HandleExceptions.
Weird, Hound and Rubocop do not agree on code style. |
Looks good! 👍 Let's squash the last three commits into one and merge it. |
spec/integrations/timestamps_spec.rb
Outdated
describe "Logidze timestamps", :db do | ||
include_context "cleanup migrations" | ||
|
||
def self.setup_models(timestamp_column:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's convert this method into a shared context with a parameter to be more RSpec way.
…stamp() Fix code style according to Hound and Rubocop Make Hound agree with Rubocop refinements
Looks like github doesn't notify about a PR update when you squash your commits. Leaving this comment to force a notification. :) |
One more thing I forgot: please, update the changelog. |
Hi! A lot of Rails models have an
updated_at
property which is used for many things. Wouldn't it be more logical and natural to take the value from theupdated_at
column and use it as version's timestamp? If the record'supdated_at
isnil
or if the table doesn't have this column, version's timestamp will be set tonow()
.Also, it's a big benefit when testing. For example, I might want to use
Timecop.freeze
to freeze time and then update my record (e.x. testing my version decorator). However,Timecop.freeze
will not affect SQL. If version's timestamp is the same as record'supdated_at
, freezing time becomes trivial.Let me know what you think about my proposal.
Also submitting a small pull request.