mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-13 02:35:22 -04:00
allow nil/blank qtys for plantings/seeds
This commit is contained in:
@@ -23,7 +23,9 @@ class Planting < ActiveRecord::Base
|
||||
|
||||
default_scope order("created_at desc")
|
||||
|
||||
validates :quantity, :numericality => { :only_integer => true }
|
||||
validates :quantity,
|
||||
:numericality => { :only_integer => true },
|
||||
:allow_nil => true
|
||||
|
||||
SUNNINESS_VALUES = %w(sun semi-shade shade)
|
||||
validates :sunniness, :inclusion => { :in => SUNNINESS_VALUES,
|
||||
|
||||
@@ -8,7 +8,9 @@ class Seed < ActiveRecord::Base
|
||||
belongs_to :crop
|
||||
belongs_to :owner, :class_name => 'Member', :foreign_key => 'owner_id'
|
||||
|
||||
validates :quantity, :numericality => { :only_integer => true }
|
||||
validates :quantity,
|
||||
:numericality => { :only_integer => true },
|
||||
:allow_nil => true
|
||||
|
||||
TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally)
|
||||
validates :tradable_to, :inclusion => { :in => TRADABLE_TO_VALUES,
|
||||
|
||||
@@ -67,9 +67,9 @@ describe Planting do
|
||||
|
||||
it "allows blank quantities" do
|
||||
@planting = FactoryGirl.build(:planting, :quantity => nil)
|
||||
@planting.should_not be_valid
|
||||
@planting.should be_valid
|
||||
@planting = FactoryGirl.build(:planting, :quantity => '')
|
||||
@planting.should_not be_valid
|
||||
@planting.should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ describe Seed do
|
||||
|
||||
it "allows blank quantities" do
|
||||
@seed = FactoryGirl.build(:seed, :quantity => nil)
|
||||
@seed.should_not be_valid
|
||||
@seed.should be_valid
|
||||
@seed = FactoryGirl.build(:seed, :quantity => '')
|
||||
@seed.should_not be_valid
|
||||
@seed.should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user