On 19 December 2014 at 00:54, Michael Sutyak <msut...@gmail.com> wrote:
> am running a test with mailers within Ruby on Rails, and I am getting the
> following errors:
>
> *********-C02MGBVJFD57:myapp ************$ bundle exec rake test:mailers
>
> # Running:
>
> EE
>
> Finished in 0.110500s, 18.0995 runs/s, 0.0000 assertions/s.
>
>   1) Error:
> UserMailerTest#test_account_activation:
> ActiveRecord::StatementInvalid: Mysql2::Error: Incorrect datetime value:
> '2014-12-18 01:07:49 UTC' for column 'activated_at' at row 1: INSERT INTO
> `users` (`name`, `email`, `password_digest`, `admin`, `activated`,
> `activated_at`, `created_at`, `updated_at`, `id`) VALUES ('Michael Example',
> 'mich...@example.com',
> '$2a$04$hz6pvZctid6gZEuv0.qAe.0mEfbEjxso9GrXwC3yHRhIThIJ7Vx5m', 1, 1,
> '2014-12-18 01:07:49 UTC', '2014-12-18 01:07:49', '2014-12-18 01:07:49',
> 762146111)
>
>
>
>   2) Error:
> UserMailerTest#test_password_reset:
> ActiveRecord::StatementInvalid: Mysql2::Error: Incorrect datetime value:
> '2014-12-18 01:07:49 UTC' for column 'activated_at' at row 1: INSERT INTO
> `users` (`name`, `email`, `password_digest`, `admin`, `activated`,
> `activated_at`, `created_at`, `updated_at`, `id`) VALUES ('Michael Example',
> 'mich...@example.com',
> '$2a$04$XTAWn5P9kikgOXqxQgiJqOjP027p4HnucHZ6pth2aaLwolaFcehsm', 1, 1,
> '2014-12-18 01:07:49 UTC', '2014-12-18 01:07:49', '2014-12-18 01:07:49',
> 762146111)
>
>
> 2 runs, 0 assertions, 0 failures, 2 errors, 0 skips
>
> When I check my fixtures users.yml file, I see that I am using the time zone
> ruby stamp:
>
> michael:
>   name: Michael Example
>   email: mich...@example.com
>   password_digest: <%= User.digest('password') %>
>   admin: true
>   activated: true
>   activated_at: <%= Time.zone.now %>


Google found this which, whilst it is old, may be relevant.

http://jitu-blog.blogspot.co.uk/2009/04/datetime-with-zone-support-in-rails.html

However I also suggest that using time.now in a fixture is not a good
idea as it means the data are different each time the test is run,
which could give inconsistent results.  I suggest instead using fixed
times, something like

activated_at:  2014-07-14 20:53:32

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuPUtcWZDwQ9BEjVJd8Yhq4M47Nte37U3t3oj0NNReHvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to