thoughtbot/factory_girl — Issue #300: timestamps attributes gets the wrong date
Author: lucapette
Created: 2012-02-19 22:43:58+00:00
State: open

Actually, I'm not sure if factory_girl supports the setting of the `created_at` and the `updated_at` fields. Anyway, I find a bit weird that they always gets the yesterday of the day you're passing to the factory.

For example, the following:

````shell
rails new blog
cd blog
echo "gem 'factory_girl_rails'" >> Gemfile
bundle install
rails g model post title voted_at:date
rake db:migrate && rake db:test:prepare
rails runner 'puts Date.today; puts Factory.build(:post, updated_at: Date.today).updated_at'
rails runner 'puts Date.today; puts Factory.build(:post, voted_at:Date.today).voted_at'
````

gives the following output:

````shell
2012-02-19
2012-02-18 23:00:00 UTC
2012-02-19
2012-02-19
````

I included a date field to point out the difference between ordinary date fields and timestamps. Same thing for `created_at`. Of course, I tried other dates but I got always the *yesterday* date.

I'm using Rails 3.2.1 and Rubu 1.9.3-p125. I suspected that something *fancy* was going on with timezones but I haven't been able to find something that explains this behaviour.

Thank you very much for working on this fantastic gem. I'm using it on all my projects. It's indispensable.