Skip to content

Commit

Permalink
reverted to using id for authority browse
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Jun 4, 2024
1 parent d392fe3 commit 4676eac
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/models/author_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

Expand Down
1 change: 0 additions & 1 deletion lib/models/browse_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/models/subject_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

Expand Down
21 changes: 11 additions & 10 deletions spec/requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4676eac

Please sign in to comment.