Forum: Ruby on Rails model test

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
02df39df2b2c6f417dcb719acd143347?d=identicon&s=25 Arshak Navruzyan (arshak)
on 2009-02-22 18:16
Hello,

I have a before_validation_on_create callback on one of my models.  It
works fine when I run it through the console in dev/prod but in test
(also going against mysql) it doesn't seem to fire.

Anything special about rake test and callbacks?

Thanks,

Arshak
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-02-22 19:30
(Received via mailing list)
Arshak Navruzyan wrote:
> Hello,
>
> I have a before_validation_on_create callback on one of my models.  It
> works fine when I run it through the console in dev/prod but in test
> (also going against mysql) it doesn't seem to fire.

Post your test code. It should raise an exception on create! , and
should return
nil on create(). So if you miss either of those, the validation appears
to not work.
This topic is locked and can not be replied to.