I think I just discovered a bug in functional testing.
Here''s the test:
post :create,
{ :seller => { :screen_name =>
''blah'',
:screen_name_confirmation =>
''blah'',
:screen_name_password =>
''blah'',
:screen_name_password_confirmation =>
''blah'',
:name =>
''blah'',
:description =>
''blah'',
:rate => 1,
:minimum_units => 0,
:minimum_dollars => 0,
:unit_id => 1 } },
{ :user_id => 4 }
This is against a model with these validations:
validates_presence_of :minimum_units
validates_numericality_of :minimum_units, :only_integer => 1
validates_presence_of :minimum_dollars
validates_numericality_of :minimum_dollars
What is strange is that the POST above fails if :minimum_units
or :minimum_dollars is zero.
If I set them to something else, it works fine.
My app is so broken due to restructuring, I cannot test whether it
works outside of tests.
I guess the question is this: Does validates_presence_of fail if the
value is zero?
This is 0.14.1
--
-- Tom Mornini
Based on "activesupport/lib/active_support/core_ext/blank.rb", 0.blank? is the same as 0.zero?. On 10/24/05, Tom Mornini <tmornini-W/9V78bTXriB+jHODAdFcQ@public.gmane.org> wrote:> I think I just discovered a bug in functional testing. > > Here''s the test: > > post :create, > { :seller => { :screen_name => ''blah'', > :screen_name_confirmation => ''blah'', > :screen_name_password => ''blah'', > :screen_name_password_confirmation => ''blah'', > :name => ''blah'', > :description => ''blah'', > :rate => 1, > :minimum_units => 0, > :minimum_dollars => 0, > :unit_id => 1 } }, > { :user_id => 4 } > > This is against a model with these validations: > > validates_presence_of :minimum_units > validates_numericality_of :minimum_units, :only_integer => 1 > > validates_presence_of :minimum_dollars > validates_numericality_of :minimum_dollars > > What is strange is that the POST above fails if :minimum_units > or :minimum_dollars is zero. > > If I set them to something else, it works fine. > > My app is so broken due to restructuring, I cannot test whether it > works outside of tests. > > I guess the question is this: Does validates_presence_of fail if the > value is zero? > > This is 0.14.1 > > -- > -- Tom Mornini > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
This may also off interest: http://www.rcrchive.net/rcr/show/295 On 10/24/05, Cuong Tran <cuong.tran-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Based on "activesupport/lib/active_support/core_ext/blank.rb", > 0.blank? is the same as 0.zero?. > > > On 10/24/05, Tom Mornini <tmornini-W/9V78bTXriB+jHODAdFcQ@public.gmane.org> wrote: > > I think I just discovered a bug in functional testing. > > > > Here''s the test: > > > > post :create, > > { :seller => { :screen_name => ''blah'', > > :screen_name_confirmation => ''blah'', > > :screen_name_password => ''blah'', > > :screen_name_password_confirmation => ''blah'', > > :name => ''blah'', > > :description => ''blah'', > > :rate => 1, > > :minimum_units => 0, > > :minimum_dollars => 0, > > :unit_id => 1 } }, > > { :user_id => 4 } > > > > This is against a model with these validations: > > > > validates_presence_of :minimum_units > > validates_numericality_of :minimum_units, :only_integer => 1 > > > > validates_presence_of :minimum_dollars > > validates_numericality_of :minimum_dollars > > > > What is strange is that the POST above fails if :minimum_units > > or :minimum_dollars is zero. > > > > If I set them to something else, it works fine. > > > > My app is so broken due to restructuring, I cannot test whether it > > works outside of tests. > > > > I guess the question is this: Does validates_presence_of fail if the > > value is zero? > > > > This is 0.14.1 > > > > -- > > -- Tom Mornini > > > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >