mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-05 07:01:03 -05:00
Update garden_type model spec
This commit is contained in:
@@ -3,35 +3,35 @@ require 'rails_helper'
|
||||
describe GardenType do
|
||||
let(:owner) { FactoryBot.create(:member) }
|
||||
let(:garden) { FactoryBot.create(:garden, owner: owner, name: 'Free Carrots') }
|
||||
let(:container) { FactoryBot.create(:container, name: "fake hole in the ground") }
|
||||
let(:garden_type) { FactoryBot.create(:garden_type, name: "fake hole in the ground") }
|
||||
|
||||
it "should have a name" do
|
||||
container = FactoryBot.build(:container, name: "organic")
|
||||
container.should be_valid
|
||||
garden_type = FactoryBot.build(:garden_type, name: "organic")
|
||||
garden_type.should be_valid
|
||||
end
|
||||
|
||||
it "doesn't allow a nil name" do
|
||||
container = FactoryBot.build(:container, name: nil)
|
||||
container.should_not be_valid
|
||||
garden_type = FactoryBot.build(:garden_type, name: nil)
|
||||
garden_type.should_not be_valid
|
||||
end
|
||||
|
||||
it "doesn't allow a blank name" do
|
||||
container = FactoryBot.build(:container, name: "")
|
||||
container.should_not be_valid
|
||||
garden_type = FactoryBot.build(:garden_type, name: "")
|
||||
garden_type.should_not be_valid
|
||||
end
|
||||
|
||||
it "doesn't allow a name with only spaces" do
|
||||
container = FactoryBot.build(:container, name: " ")
|
||||
container.should_not be_valid
|
||||
garden_type = FactoryBot.build(:garden_type, name: " ")
|
||||
garden_type.should_not be_valid
|
||||
end
|
||||
|
||||
it "destroys plots when deleted" do
|
||||
container = FactoryBot.create(:container, name: "Massive Flower Pot")
|
||||
@plot1 = FactoryBot.create(:plot, garden: garden, container: container)
|
||||
@plot2 = FactoryBot.create(:plot, garden: garden, container: container)
|
||||
container.plots.size.should eq(2)
|
||||
garden_type = FactoryBot.create(:garden_type, name: "Massive Flower Pot")
|
||||
@plot1 = FactoryBot.create(:plot, garden: garden, garden_type: garden_type)
|
||||
@plot2 = FactoryBot.create(:plot, garden: garden, garden_type: garden_type)
|
||||
garden_type.plots.size.should eq(2)
|
||||
all = Plot.count
|
||||
container.destroy
|
||||
garden_type.destroy
|
||||
Plot.count.should eq(all - 2)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user