mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-30 03:36:23 -04:00
37 lines
893 B
Ruby
37 lines
893 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe PlantPart do
|
|
it 'stringifies' do
|
|
@pp = create(:plant_part)
|
|
@pp.to_s.should eq @pp.name
|
|
end
|
|
|
|
it 'has crops' do
|
|
@maize = create(:maize)
|
|
@tomato = create(:tomato)
|
|
@pp1 = create(:plant_part)
|
|
@h1 = create(:harvest,
|
|
crop: @tomato,
|
|
plant_part: @pp1)
|
|
@h2 = create(:harvest,
|
|
crop: @maize,
|
|
plant_part: @pp1)
|
|
@pp1.crops.should include @tomato
|
|
@pp1.crops.should include @maize
|
|
end
|
|
|
|
it "doesn't duplicate crops" do
|
|
@maize = create(:maize)
|
|
@pp1 = create(:plant_part)
|
|
@h1 = create(:harvest,
|
|
crop: @maize,
|
|
plant_part: @pp1)
|
|
@h2 = create(:harvest,
|
|
crop: @maize,
|
|
plant_part: @pp1)
|
|
@pp1.crops.should eq [@maize]
|
|
end
|
|
end
|