mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-13 02:35:22 -04:00
Merge pull request #1607 from Br3nda/fix/plants-parts-dupe
Don't allow duplicate plant parts names
This commit is contained in:
@@ -5,6 +5,8 @@ class PlantPart < ActiveRecord::Base
|
||||
has_many :harvests
|
||||
has_many :crops, -> { uniq }, through: :harvests
|
||||
|
||||
validates :name, presence: true, uniqueness: true
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
FactoryBot.define do
|
||||
factory :harvest do
|
||||
crop { planting.present? ? planting.crop : FactoryBot.create(:crop) }
|
||||
plant_part
|
||||
plant_part { FactoryBot.create :plant_part }
|
||||
planting nil
|
||||
owner { planting.present? ? planting.owner : FactoryBot.create(:member) }
|
||||
harvested_at { Time.zone.local(2015, 9, 17) }
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
FactoryBot.define do
|
||||
factory :plant_part do
|
||||
name "pollen"
|
||||
name { "#{Faker::Book.title}_#{rand(100..999)}" }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user