mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-24 09:43:24 -04:00
Prevent the creation of a garden with a negative number for the area. If entered, the area must be greater than or equal to zero.
This commit is contained in:
@@ -26,7 +26,7 @@ class Garden < ActiveRecord::Base
|
||||
}
|
||||
|
||||
validates :area,
|
||||
:numericality => { :only_integer => false },
|
||||
:numericality => { :only_integer => false, :greater_than_or_equal_to => 0 },
|
||||
:allow_nil => true
|
||||
|
||||
AREA_UNITS_VALUES = {
|
||||
|
||||
@@ -33,6 +33,15 @@ feature "Planting a crop", :js => true do
|
||||
expect(page).to have_content "New garden"
|
||||
end
|
||||
|
||||
scenario "Refuse to create new garden with negative area" do
|
||||
visit new_garden_path
|
||||
fill_in "Name", :with => "Negative Garden"
|
||||
fill_in "Area", :with => -5
|
||||
click_button "Save"
|
||||
expect(page).not_to have_content "Garden was successfully created"
|
||||
expect(page).to have_content "Area must be greater than or equal to 0"
|
||||
end
|
||||
|
||||
scenario "Edit garden" do
|
||||
visit new_garden_path
|
||||
fill_in "Name", :with => "New garden"
|
||||
|
||||
Reference in New Issue
Block a user