collectiveidea / audited

Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.
MIT License
3.34k stars 645 forks source link

created_at value has the timezone offset applied twice (>= 5.0.0) #683

Open Fosfen opened 9 months ago

Fosfen commented 9 months ago

Hello ! I've been upgrading a Rails app to Rails 5, and needed to upgrade audited to a newer version (>= 5.0.0).

Some of our unit tests failed because of timezone offset being applied twice on the created_at field for audits. Here is an example of what happens:

Supposed server time is 1970-01-01 10:00:00 +02:00 > SomeModel.last.update!(audited_column: "fake value")

> SomeModel.last.audits.last.created_at => 1970-01-01 12:00:00 +02:00

Expected behavior: > SomeModel.last.audits.last.created_at => 1970-01-01 10:00:00 +02:00

Obviously no problem appears when the app runs on a UTC local time. The issue seems to happen only with audits (no other model is impacted), is there a way to get the correct timestamp for audits ?