From d0154a8b60f00f08de425e627a855a6c4e0f8375 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 29 Feb 2020 12:34:28 +1300 Subject: [PATCH] Fall back on planting icon when plant part icon does not exist --- app/helpers/icons_helper.rb | 3 ++- spec/features/harvests/harvesting_a_crop_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index fda3a9c80..753a42171 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -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) diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 9d4daa5c5..1e83c1a48 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -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