Skip to content

Commit

Permalink
Merge pull request #738 from nla/feat/blac-550-request-return-to-sear…
Browse files Browse the repository at this point in the history
…ch-button

feat: add button to return to search from request
  • Loading branch information
yetti authored Sep 17, 2023
2 parents 57e6f4d + 3c0e6f6 commit 55a318d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/views/request/success.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<div class="row mt-4">
<div class="col-12">
<ul class="list-unstyled">
<% if current_search_session %>
<li class="mb-2"><%= link_back_to_catalog class: 'btn btn-outline-secondary btn-sm back-to-results arrow-before' %></li>
<% end %>
<li class="mb-2"><%= link_to t("requesting.btn_back_to_item"), :back, class: "btn btn-outline-secondary btn-sm arrow-before" %></li>
</ul>
</div>
Expand Down
32 changes: 32 additions & 0 deletions spec/features/requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,38 @@
expect(page).to have_link(I18n.t("requesting.btn_back_to_item"), href: "javascript:history.back()")
end

context "when a catalogue search has been performed" do
let(:current_search) { Search.create(query_params: {q: ""}) }

before do
allow_any_instance_of(RequestController).to receive(:current_search_session).and_return(current_search)
end

it "renders the 'Back to search' button" do
visit solr_document_request_success_path(
solr_document_id: solr_document_id,
instance: instance_id,
holdings: holdings_id,
item: item_id
)

expect(page).to have_link(I18n.t("blacklight.back_to_search", href: "/catalog"))
end
end

context "when a catalogue search has not been performed" do
it "does not render the 'Back to search' button" do
visit solr_document_request_success_path(
solr_document_id: solr_document_id,
instance: instance_id,
holdings: holdings_id,
item: item_id
)

expect(page).not_to have_link(I18n.t("blacklight.back_to_search"))
end
end

context "when user has reached their request limit" do
it "renders the request limit error" do
WebMock.stub_request(:get, /catservices.test\/catalogue-services\/folio\/user\/(.*)\/requestLimitReached/)
Expand Down

0 comments on commit 55a318d

Please sign in to comment.