Skip to content

Commit

Permalink
Add a link to Statutory Instruments finder at foot of content.
Browse files Browse the repository at this point in the history
  • Loading branch information
steventux authored and Steve Laing committed Jun 29, 2018
1 parent 2396f35 commit add23db
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/presenters/specialist_document_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def will_continue_on
.try(:html_safe)
end

def finder_link
if finder && statutory_instrument?
link_to "See all #{finder['title']}", finder['base_path']
end
end

private

def nested_headers
Expand Down Expand Up @@ -206,4 +212,8 @@ def any_updates?
def bulk_published?
!!facet_values["bulk_published"]
end

def statutory_instrument?
content_item["document_type"] == "statutory_instrument"
end
end
7 changes: 7 additions & 0 deletions app/views/content_items/specialist_document.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
history: @content_item.history
} %>
</div>

<% if @content_item.finder_link %>
<div class="responsive-bottom-margin">
<%= @content_item.finder_link %>
</div>
<% end %>

<% end %>
</div>
<%= render 'shared/sidebar_navigation' %>
Expand Down
11 changes: 11 additions & 0 deletions test/integration/specialist_document_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SpecialistDocumentTest < ActionDispatch::IntegrationTest
setup_and_visit_content_item('employment-appeal-tribunal-decision')
setup_and_visit_content_item('employment-tribunal-decision')
setup_and_visit_content_item('european-structural-investment-funds')
setup_and_visit_content_item('eu-withdrawal-act-2018-statutory-instruments')
setup_and_visit_content_item('international-development-funding')
setup_and_visit_content_item('maib-reports')
setup_and_visit_content_item('raib-reports')
Expand Down Expand Up @@ -168,4 +169,14 @@ def assert_nested_content_item(heading)

refute page.has_css?('#contents .gem-c-contents-list')
end

test 'renders a link to statutory instruments finder' do
# Statutory instruments are tagged to taxonomy so stub rummager request for similar content
# which is triggered by the sidebar component.
stub_request(:get, /\/search.json/).to_return(status: 200, body: "{}", headers: {})
setup_and_visit_content_item('eu-withdrawal-act-2018-statutory-instruments')

assert page.has_css?("a[href='/eu-withdrawal-act-2018-statutory-instruments']",
text: 'See all EU Withdrawal Act 2018 statutory instruments')
end
end

0 comments on commit add23db

Please sign in to comment.