-
Notifications
You must be signed in to change notification settings - Fork 25
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
Does not work with database now() :) #7
Comments
Actually i've tried to pass Time.zone.now like this:
but it looks like it something breaks Delorean, becouse this code:
gives me:
but with normal use of Time.zone.now:
Delorean works fine. Any ideas why scope with Time.zone.now disables Delorean time changes? I'm using postgres. |
It might be the case that Delorean mocks Time.now but not Time.zone.now. Patches welcomed :) |
BTW, I don't think Delorean will ever be able to mock database's "now()" function |
I'm using Time.zone.now and it looks like Delorean mocks it fine, the problem appears when I pass Time.zone.now to database query - then mocking does not work for some reason. I'm using Time.zone.now instead of Time.now, becouse it looks like my database is using UTC time for timestamps, and as far as i know Time.zone.now returns UTC time, am I right? Or maybe my database is storing timestamps in my local time and Time.now returns UTC? |
Ok. That's because scope :active, lambda { where('expires_at IS NOT NULL AND expires_at > ?', Time.zone.now) } I'm closing this issue since no changes in Delorean are required |
Even that does not work, that Time.zone.now in that scope seems to be frozen somehow :| It does not changes within time_travel_to block of Delorean. I've just substracted some days from my product's expires_at date :) |
Few years later I faced with this issue. (...) .where("expires_at > ?::timestamp", Time.now) This is a trivial example but I had to manipulate times in Postgres with |
Hi!
I was trying to test my expiring activeness of product (just scope in activerecord):
but Delorean only travels in ruby time, not in db time :) I know it is highly impossible to mock db time. but maybe somebody have some idea about it? maybe it is better not to use database specific methods, such as random() or now(), but pass for example Time.now converted to database date format? something like this:
The text was updated successfully, but these errors were encountered: