Skip to content

Commit

Permalink
Display info html on GuideCard show page
Browse files Browse the repository at this point in the history
Co-authored-by: Anna Headley <hackartisan@users.noreply.github.com>
  • Loading branch information
leefaisonr and hackartisan committed Oct 20, 2023
1 parent 043a5a1 commit 78ae228
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/controllers/guide_cards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ def show
@sub_guide_cards = @guide_card.children
@card_images = CardImage.where(path: @guide_card.path).page(params[:page])
@total_cards = CardImage.where(path: @guide_card.path).count
@info_cards = InfoCard.where(path: @guide_card.path)
end
end
4 changes: 4 additions & 0 deletions app/views/guide_cards/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
<% end %>
<%= render "shared/card_image_list" %>
<% @info_cards.each do |info| %>
<%= info.html.html_safe %>
<% end %>
2 changes: 1 addition & 1 deletion lib/tasks/import.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ namespace :import do
desc 'Import InfoCard data'
task import_info_cards: :environment do
InfoCardLoadingService.new.import
end
end
end
3 changes: 2 additions & 1 deletion spec/fixtures/guide_card_fixture.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ ID,heading,sortid,path,ID,heading,sortid,path
9,AILA,9.5,14/0002/A1008,9,AILA,9.5,14/0002/A1008
10,A.L.,10.5,14/0002/A1009,10,A.L.,10.5,14/0002/A1009
11,A.M.,11.5,14/0002/A1010,11,A.M.,11.5,14/0002/A1010
2869,Bible,2870.5,sub,2869,Bible,2870.5,sub
2869,Bible,2870.5,sub,2869,Bible,2870.5,sub
29378,United States (info),29382.5,info/U,29378,United States (info),29382.5,info/U
2 changes: 1 addition & 1 deletion spec/fixtures/guide_card_fixture_non_matching_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ID,heading,sortid,path,ID,heading,sortid,path
8,AID,8.5,14/0001/A1007,8,AID,8.5,14/0001/A1007
9,AILA,9.5,14/0002/A1008,9,AILA,9.5,14/0002/A1008
10,A.L.,10.5,14/0002/A1009,10,A.L.,10.5,14/0002/A1009
11,A.M.,11.5,14/0002/A1010,11,A.M.,11.5,14/0002/A1010
11,A.M.,11.5,14/0002/A1010,11,A.M.,11.5,14/0002/A1010
2 changes: 1 addition & 1 deletion spec/services/guide_card_loading_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
it 'imports all data from the CSV file' do
expect(GuideCard.count).to eq 0
gcls.import
expect(GuideCard.count).to eq 12
expect(GuideCard.count).to eq 13
end

it 'displays ruby-progress bar during import' do
Expand Down
8 changes: 8 additions & 0 deletions spec/system/guide_cards_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
expect(page).not_to have_text 'No cards found'
end
end
context 'when it is an InfoCard' do
it 'displays the .html snippet' do
InfoCardLoadingService.new.import
visit '/guide_cards/29378'
expect(page).to have_content 'Because the United States file is so long'
expect(page).not_to have_content '<p>'
end
end
end

context 'when a GuideCard has no SubGuide cards' do
Expand Down

0 comments on commit 78ae228

Please sign in to comment.