Skip to content

Commit

Permalink
Merge pull request #90 from pulibrary/i20-GuideCard-show-page
Browse files Browse the repository at this point in the history
Add SubGuideCard records to GuideCard show page
  • Loading branch information
hackartisan authored Aug 2, 2023
2 parents 5b57f6e + 0d0dcde commit 5349812
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 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 @@ -8,5 +8,6 @@ def index

def show
@guide_card = GuideCard.find(params[:id])
@sub_guide_cards = @guide_card.children
end
end
2 changes: 1 addition & 1 deletion app/views/guide_cards/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 id="list_header"> GuideCard Index </h1>

<% @guide_cards.each do |card| %>
<h2> <%= link_to card.heading, guide_card_path(card.id) %> </h2>
<h2><%= link_to card.heading, guide_card_path(card.id) %></h2>
<% end %>

<%= paginate @guide_cards %>
12 changes: 9 additions & 3 deletions app/views/guide_cards/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<h1><%= @guide_card.heading %> </h1>
<h2><%= @guide_card.sortid %> </h2>
<h2><%= @guide_card.path %> </h2>
<h1><%= @guide_card.heading %></h1>
<h2><%= @guide_card.sortid %></h2>
<h2><%= @guide_card.path %></h2>


<h2>List of SubGuide cards</h2>
<ul>
<% @sub_guide_cards.each do |sub_guide| %>
<li><%= sub_guide.heading %></li>
<% end %>
</ul>
17 changes: 13 additions & 4 deletions spec/system/guide_cards_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@
require 'rails_helper'

RSpec.describe 'GuideCards', type: :system, js: true do
let(:guide_card_fixture) { Rails.root.join('spec', 'fixtures', 'guide_card_fixture.csv') }
before do
GuideCardLoadingService.new(csv_location: guide_card_fixture).import
end

describe 'GuideCards index page' do
let(:guide_card_fixture) { Rails.root.join('spec', 'fixtures', 'guide_card_fixture.csv') }
before do
GuideCardLoadingService.new(csv_location: guide_card_fixture).import
end
it 'displays pagination controls' do
visit '/guide_cards'
expect(page).to have_link('Next', href: '/guide_cards?page=2')
click_link('Next')
expect(page).to have_link('A.M.')
end
end

describe 'GuideCards show page' do
it 'displays children SubGuide cards' do
SubGuideCard.create(parentid: GuideCard.find(3).sortid, heading: 'Institut fizicheskoi >')
visit '/guide_cards/3'
expect(page).to have_text 'Institut fizicheskoi >'
end
end
end

0 comments on commit 5349812

Please sign in to comment.