diff --git a/app/controllers/guide_cards_controller.rb b/app/controllers/guide_cards_controller.rb index 65bd5b0e..e216ae68 100644 --- a/app/controllers/guide_cards_controller.rb +++ b/app/controllers/guide_cards_controller.rb @@ -8,5 +8,6 @@ def index def show @guide_card = GuideCard.find(params[:id]) + @sub_guide_cards = @guide_card.children end end diff --git a/app/views/guide_cards/index.html.erb b/app/views/guide_cards/index.html.erb index f95b9b15..21d8119d 100644 --- a/app/views/guide_cards/index.html.erb +++ b/app/views/guide_cards/index.html.erb @@ -1,7 +1,7 @@

GuideCard Index

<% @guide_cards.each do |card| %> -

<%= link_to card.heading, guide_card_path(card.id) %>

+

<%= link_to card.heading, guide_card_path(card.id) %>

<% end %> <%= paginate @guide_cards %> \ No newline at end of file diff --git a/app/views/guide_cards/show.html.erb b/app/views/guide_cards/show.html.erb index 0645b2e3..c272788d 100644 --- a/app/views/guide_cards/show.html.erb +++ b/app/views/guide_cards/show.html.erb @@ -1,5 +1,11 @@ -

<%= @guide_card.heading %>

-

<%= @guide_card.sortid %>

-

<%= @guide_card.path %>

+

<%= @guide_card.heading %>

+

<%= @guide_card.sortid %>

+

<%= @guide_card.path %>

+

List of SubGuide cards

+ diff --git a/spec/system/guide_cards_spec.rb b/spec/system/guide_cards_spec.rb index 104c146d..d471f01e 100644 --- a/spec/system/guide_cards_spec.rb +++ b/spec/system/guide_cards_spec.rb @@ -3,11 +3,12 @@ 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') @@ -15,4 +16,12 @@ 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