mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-01 05:01:04 -05:00
read photo from a harvest's planting
This commit is contained in:
committed by
always-be-closing[bot]
parent
99c119c07f
commit
efe14d43cb
@@ -74,6 +74,10 @@ class Harvest < ApplicationRecord
|
||||
harvested_at - planting.planted_at
|
||||
end
|
||||
|
||||
def default_photo
|
||||
most_liked_photo || planting&.default_photo
|
||||
end
|
||||
|
||||
# we're storing the harvest weight in kilograms in the db too
|
||||
# to make data manipulation easier
|
||||
def set_si_weight
|
||||
|
||||
@@ -237,6 +237,7 @@ describe Harvest do
|
||||
@planting = FactoryBot.create(:planting, crop: @harvest.crop)
|
||||
@photo = FactoryBot.create(:photo, owner: @planting.owner)
|
||||
@planting.photos << @photo
|
||||
@harvest.update(planting: @planting)
|
||||
end
|
||||
|
||||
it 'has a default photo' do
|
||||
|
||||
Reference in New Issue
Block a user