From b402ad8b47e710685554d9f19943c4d7dd45ddba Mon Sep 17 00:00:00 2001 From: leefaisonr Date: Thu, 28 Sep 2023 17:00:42 -0400 Subject: [PATCH] Added a test for GuideCard card images Co-authored-by: Jane Sandberg --- app/controllers/guide_cards_controller.rb | 1 + app/views/guide_cards/show.html.erb | 6 ++++++ spec/system/guide_cards_spec.rb | 12 ++++++++++++ 3 files changed, 19 insertions(+) diff --git a/app/controllers/guide_cards_controller.rb b/app/controllers/guide_cards_controller.rb index 8cabe8a..cbd44f5 100644 --- a/app/controllers/guide_cards_controller.rb +++ b/app/controllers/guide_cards_controller.rb @@ -23,5 +23,6 @@ def search def show @guide_card = GuideCard.find(params[:id]) @sub_guide_cards = @guide_card.children + @card_images = CardImage.where(path: @guide_card.path) end end diff --git a/app/views/guide_cards/show.html.erb b/app/views/guide_cards/show.html.erb index 2efa63b..8209413 100644 --- a/app/views/guide_cards/show.html.erb +++ b/app/views/guide_cards/show.html.erb @@ -7,3 +7,9 @@
  • <%= link_to sub_guide.heading, sub_guide_card_path(sub_guide.id) %>
  • <% end %> + + <% @card_images.each do |image| %> + + <% end %> \ No newline at end of file diff --git a/spec/system/guide_cards_spec.rb b/spec/system/guide_cards_spec.rb index ccccae8..a2c6a53 100644 --- a/spec/system/guide_cards_spec.rb +++ b/spec/system/guide_cards_spec.rb @@ -29,4 +29,16 @@ expect(page).to have_text 'Manuscripts' end end + + describe 'show page' do + it 'displays card images' do + ci = CardImage.new + ci.path = GuideCard.find(2).path + ci.image_name = 'imagecat-disk1-0675-B1764-0000.0219.tif' + ci.save + visit '/guide_cards/2' + expect(page).to have_selector('img') + expect(page).to have_selector('img[alt]') + end + end end