LoginSignup
1
1

More than 5 years have passed since last update.

system testでdeliver_later実行時にSerializationError

Last updated at Posted at 2019-02-08

RailsのactionMailerでdeliver_laterする際、ブラウザから操作した場合は問題ないのにsystem test時に下記のエラーが発生。

ActiveJob::SerializationError: Unsupported argument type: Time

rspecかcapybaraかと思ったら、activeJobのバグと、ActionMailerに渡しているmockの書き方が原因だった。

myMailer.myMethod(params).deliver_later

paramsはAPIで取得するJSONをparseしたハッシュのため、テストの場合はmockにしていたが、TimeWithZone型をそのまま突っ込んでいた。
これをstringにすることで解決。

参考
- Mail and deliver_later doesn't work with date argument · Issue #18519 · rails/rails
- ActiveJobの引数にはなんでも突っ込んでいいわけではない - Qiita

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1