diff --git a/lib/models/author_list.rb b/lib/models/author_list.rb index 3ecc648..36cc050 100644 --- a/lib/models/author_list.rb +++ b/lib/models/author_list.rb @@ -6,7 +6,7 @@ def self.for(direction:, reference_id:, num_rows_to_display:, original_reference num_rows_to_display: num_rows_to_display, original_reference: original_reference, banner_reference: banner_reference, - match_field: "term", + match_field: "id", browse_solr_client: BrowseSolrClient.new(core: S.authority_collection, match_field: "term", q: "browse_field:name") ) diff --git a/lib/models/browse_list.rb b/lib/models/browse_list.rb index d268ea2..4a35490 100644 --- a/lib/models/browse_list.rb +++ b/lib/models/browse_list.rb @@ -16,7 +16,6 @@ def self.for( case direction when "next" # includes reference in results - # require "byebug"; byebug index_response = browse_solr_client.browse_reference_on_top(reference_id: reference_id, rows: num_rows_to_display + 2) BrowseList::ReferenceOnTop.new( index_response: index_response&.body, diff --git a/lib/models/subject_list.rb b/lib/models/subject_list.rb index 58a7076..c68d0d7 100644 --- a/lib/models/subject_list.rb +++ b/lib/models/subject_list.rb @@ -6,7 +6,7 @@ def self.for(direction:, reference_id:, num_rows_to_display:, original_reference num_rows_to_display: num_rows_to_display, original_reference: original_reference, banner_reference: banner_reference, - match_field: "term", + match_field: "id", browse_solr_client: BrowseSolrClient.new(core: S.authority_collection, match_field: "term", q: "browse_field:subject") ) diff --git a/spec/requests_spec.rb b/spec/requests_spec.rb index e0c4f7a..36af24c 100644 --- a/spec/requests_spec.rb +++ b/spec/requests_spec.rb @@ -4,6 +4,7 @@ before(:each) do @call_number_collection = S.call_number_collection @authority_collection = S.authority_collection + @authority_match_field = "id" end context "get /" do it "has status OK" do @@ -29,30 +30,30 @@ end context "get /author" do it "returns status OK" do - stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: 'term:"Thing"'}), output: fixture("author_exact_matches.json")) - stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({sort: "term desc"}), output: fixture("author_results.json")) - stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: 'term:["Thing" TO *]'}), output: fixture("author_results.json")) + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: "term:\"Thing\""}), output: fixture("author_exact_matches.json")) + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({sort: "#{@authority_match_field} desc"}), output: fixture("author_results.json")) + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: "#{@authority_match_field}:[\"Thing\" TO *]"}), output: fixture("author_results.json")) get "/author", {query: "Thing"} expect(last_response.status).to eq(200) end it "for a network error, it still returns a successful response, but with an error message" do - stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: 'term:"Thing"'}), no_return: true).to_timeout - stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({sort: "term desc"}), no_return: true).to_timeout + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: "term:\"Thing\""}), no_return: true).to_timeout + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({sort: "#{@authority_match_field} desc"}), no_return: true).to_timeout get "/author", {query: "Thing"} expect(last_response.status).to eq(200) end end context "get /subject" do it "returns status OK" do - stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: 'term:"Thing"'}), output: fixture("author_exact_matches.json")) - stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({sort: "term desc"}), output: fixture("subject_results.json")) - stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: 'term:["Thing" TO *]'}), output: fixture("subject_results.json")) + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: "term:\"Thing\""}), output: fixture("author_exact_matches.json")) + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({sort: "#{@authority_match_field} desc"}), output: fixture("subject_results.json")) + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: "#{@authority_match_field}:[\"Thing\" TO *]"}), output: fixture("subject_results.json")) get "/subject", {query: "Thing"} expect(last_response.status).to eq(200) end it "for a network error, it still returns a successful response, but with an error message" do - stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: 'term:"Thing"'}), no_return: true).to_timeout - stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({sort: "term desc"}), no_return: true).to_timeout + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: "term:\"Thing\""}), no_return: true).to_timeout + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({sort: "#{@authority_match_field} desc"}), no_return: true).to_timeout get "/subject", {query: "Thing"} expect(last_response.status).to eq(200) end