diff --git a/app/presenters/specialist_document_presenter.rb b/app/presenters/specialist_document_presenter.rb index 66daf08da..09d43425c 100644 --- a/app/presenters/specialist_document_presenter.rb +++ b/app/presenters/specialist_document_presenter.rb @@ -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 @@ -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 diff --git a/app/views/content_items/specialist_document.html.erb b/app/views/content_items/specialist_document.html.erb index 730f5b894..63068b01b 100644 --- a/app/views/content_items/specialist_document.html.erb +++ b/app/views/content_items/specialist_document.html.erb @@ -44,6 +44,13 @@ history: @content_item.history } %> + + <% if @content_item.finder_link %> +
+ <%= @content_item.finder_link %> +
+ <% end %> + <% end %> <%= render 'shared/sidebar_navigation' %> diff --git a/test/integration/specialist_document_test.rb b/test/integration/specialist_document_test.rb index a5ff72f62..8dbfb9a3f 100644 --- a/test/integration/specialist_document_test.rb +++ b/test/integration/specialist_document_test.rb @@ -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') @@ -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