Frederick Cheung wrote in post #1035416:
> On 6 Dec 2011, at 16:10, Ori Kremer <[email protected]> wrote:
>
>>    belongs_to :payment_type
>>
>>  PaymentType.all.include?(payment_type)
>>
>> evaluates to 'true'.
>>
>> Any ideas why it fails when running only integration tests?
>>
>
> The call to validates (and thus the evaluation of its argument) happens
> when your order class is loaded. If this happens before your fixtures
> are loaded then you'll effectively be doing validates :blah, :inclusion
> => []
>
> Why running rake test versus rake test:integration matters I don't know
> - perhaps one has extra dependencies that force fixtures to be loaded
> earlier or later, but either way I've generally tried to avoid this sort
> of thing. I'm not sure what your current code gets you over just
> validating the presence of the payment_type
>
> Fred

Thanks Fred.
You're right, when debugging the validate inclusion code, I see that the 
PaymentType.all returns [].

I guess, like you said, that when the Order class is loaded and the 
inclusion is evaluated the PaymentType fixture wasn't loaded yet.

But that brings up another question, isn't that a bug in rake/rails?

Why aren't the fixtures being loaded prior to being used? Why isn't 
PaymentType loaded before Order is?

Ori

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to