views:

116

answers:

1

I don't know what and when happend on my code but I got hundereds similar erros (not failures)

of this :

NameError: uninitialized constant ActiveSupport::Callbacks::Callback::NORMAL

And my tests function just go useless now, as even I put something like:

should "failed" do
   assert false
end

It still returns passed, any idea ?

Thanks

A: 

The problem been addressed.

Thanks for helps anyway.

The problem is uninitialized constant ActiveSupport::Callbacks::Callback::NORMAL

I found a validation in the model

  validates_presence_of :time_purchased,         :if => "self.usage_type == NORMAL"

NORMAL is a string of type I want to check, in this error, it is really confusing , make me belive it is something wrong with the ActiveSupport.

The correct one should be

validates_presence_of :time_purchased,         :if => "self.usage_type == 'NORMAL'"
Shuoling Liu
The confusion happens because Ruby (or one of the libraries) puts "self.usage_type == NORMAL" through an eval() function: it actually executes the string, so it looks for a constant named NORMAL. ActiveSupport::Callbacks::Callback is the first place that Ruby expected to find the constant within the current context.
Mike Woodhouse
I strongly suggest putting this check into a protected method and then giving just the name of that method (symbol) to ":if". Also, you should mark that your answer answers your question.
mislav
Thank Mike and mislav, yes, it is looking constant which may named NORMAL, it is confusing.Re: mislav, I must wait 48 hours before accpeting my own answer.
Shuoling Liu