Open Fosfen opened 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.update!(audited_column: "fake value")
> SomeModel.last.audits.last.created_at => 1970-01-01 12:00:00 +02:00
> 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
=> 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 ?
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 ?