Fall back on planting icon when plant part icon does not exist

This commit is contained in:
Brenda Wallace
2020-02-29 12:34:28 +13:00
parent cbec6b2743
commit d0154a8b60
2 changed files with 4 additions and 3 deletions

View File

@@ -92,7 +92,8 @@ module IconsHelper
end
def plant_part_icon(name)
image_icon "plant_parts/#{name}"
image_icon "plant_parts/#{name}" if Files.exists? Rails.root.join('app', 'assets', 'images', 'icons', "{name}.svg")
planting_icon
end
def crop_icon(crop)

View File

@@ -54,7 +54,7 @@ describe "Harvesting a crop", :js, :search do
describe "Harvesting from crop page" do
before do
visit crop_path(maize)
click_link 'Record harvest'
click_link id: 'modalHarvestButton'
click_link plant_part.name
end
@@ -66,7 +66,7 @@ describe "Harvesting a crop", :js, :search do
let!(:planting) { create :planting, crop: maize, owner: member, garden: member.gardens.first }
before do
visit planting_path(planting)
click_link "Record harvest"
click_link id: 'modalHarvestButton'
click_link plant_part.name
end