read photo from a harvest's planting

This commit is contained in:
Brenda Wallace
2019-07-12 16:36:54 +12:00
committed by always-be-closing[bot]
parent 99c119c07f
commit efe14d43cb
2 changed files with 5 additions and 0 deletions

View File

@@ -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

View File

@@ -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