diff --git a/.gitignore b/.gitignore index 37db4f1..7aa4caa 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ node_modules/ public/browse.css .bash_history .cache/ +.solargraph.yml diff --git a/catalog-browse.rb b/catalog-browse.rb index 8568769..ae7cf8a 100644 --- a/catalog-browse.rb +++ b/catalog-browse.rb @@ -10,8 +10,8 @@ require_relative "lib/utilities/string_cleaner" require_relative "lib/models/browse_list" require_relative "lib/models/browse_list_presenter" -require_relative "lib/models/callnumber_list" -require_relative "lib/models/callnumber_item" +require_relative "lib/models/call_number_list" +require_relative "lib/models/call_number_item" require_relative "lib/models/author_list" require_relative "lib/models/author_item" require_relative "lib/models/subject_list" @@ -20,7 +20,7 @@ require_relative "lib/models/datastores" CatalogSolrClient.configure do |config| - config.solr_url = ENV.fetch("BIBLIO_SOLR") + config.solr_url = S.biblio_solr end get "/subject" do @@ -47,13 +47,13 @@ erb :authors, locals: {list: list} end get "/callnumber" do - callnumber = params[:query] - reference_id = params[:reference_id] || callnumber + call_number = params[:query] + reference_id = params[:reference_id] || call_number begin - list = CallnumberList.for(direction: params[:direction], reference_id: reference_id, num_rows_to_display: 20, original_reference: callnumber, banner_reference: params[:banner_reference]) + list = CallNumberList.for(direction: params[:direction], reference_id: reference_id, num_rows_to_display: 20, original_reference: call_number, banner_reference: params[:banner_reference]) rescue => e logger.error(e.message) - list = CallnumberList::Error.new(reference_id) + list = CallNumberList::Error.new(reference_id) end erb :call_number, locals: {list: list} end diff --git a/env.example b/env.example index 2910fcb..54fe5c9 100644 --- a/env.example +++ b/env.example @@ -1,8 +1,13 @@ BIBLIO_SOLR='http://biblio-server/solr' -AUTHOR_SOLR='http://catalog-solr-server/solr' -BROWSE_SOLR='http://catalog-solr-server/solr' -CALLNUMBER_CORE='callnumbers' -AUTHORITY_CORE='authors' +SOLRCLOUD_URL='http://solr-cloud-server/solr' +CALL_NUMBER_COLLECTION='call_number_browse' +AUTHORITY_COLLECTION='authority_collection' SOLR_USER='solr' SOLR_PASSWORD='SolrRocks' -SOLR_CLOUD_ON='false' + +SOLRCLOUD_ON='true' + +#Legacy env vars +BROWSE_SOLR='http://catalog-solr-server/solr' +CALLNUMBER_CORE='callnumber_browse' +AUTHORITY_CORE='authority_core' diff --git a/lib/models/author_item.rb b/lib/models/author_item.rb index 4c8d27e..a5147e0 100644 --- a/lib/models/author_item.rb +++ b/lib/models/author_item.rb @@ -85,7 +85,7 @@ def kind end def url - "#{ENV.fetch("BASE_URL")}/author?query=#{URI.encode_www_form_component(@author)}" + "#{S.base_url}/author?query=#{URI.encode_www_form_component(@author)}" end def heading_link? diff --git a/lib/models/author_list.rb b/lib/models/author_list.rb index bddb652..53f3149 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, - browse_solr_client: BrowseSolrClient.new(solr_url: S.author_solr, core: S.authority_core, match_field: "term", q: "browse_field:name", solr_cloud_on: S.solr_cloud_on?) + browse_solr_client: BrowseSolrClient.new(core: S.authority_collection, match_field: "term", q: "browse_field:name") ) new(browse_list: browse_list) diff --git a/lib/models/browse_list_presenter.rb b/lib/models/browse_list_presenter.rb index 172154f..ff7bd10 100644 --- a/lib/models/browse_list_presenter.rb +++ b/lib/models/browse_list_presenter.rb @@ -60,6 +60,6 @@ def feedback_url private def nav_url(params) - "#{ENV.fetch("BASE_URL")}/#{path}?#{URI.encode_www_form(params)}" + "#{S.base_url}/#{path}?#{URI.encode_www_form(params)}" end end diff --git a/lib/models/callnumber_item.rb b/lib/models/call_number_item.rb similarity index 92% rename from lib/models/callnumber_item.rb rename to lib/models/call_number_item.rb index 99e456b..f98c912 100644 --- a/lib/models/callnumber_item.rb +++ b/lib/models/call_number_item.rb @@ -1,4 +1,4 @@ -class CallnumberItem +class CallNumberItem def initialize(browse_doc:, catalog_doc:, exact_match:) @browse_doc = browse_doc @catalog_doc = catalog_doc || {} @@ -13,6 +13,11 @@ def exact_match? !!@exact_match end + # for the view + def call_number + @browse_doc["callnumber"]&.strip + end + # for the view def callnumber @browse_doc["callnumber"]&.strip diff --git a/lib/models/callnumber_list.rb b/lib/models/call_number_list.rb similarity index 93% rename from lib/models/callnumber_list.rb rename to lib/models/call_number_list.rb index 18b8f40..5cd7738 100644 --- a/lib/models/callnumber_list.rb +++ b/lib/models/call_number_list.rb @@ -1,4 +1,4 @@ -class CallnumberList < BrowseListPresenter +class CallNumberList < BrowseListPresenter def self.for(direction:, reference_id:, num_rows_to_display:, original_reference:, banner_reference:) browse_list = BrowseList.for( direction: direction, @@ -37,7 +37,7 @@ def items exact_match = exact_matches.any?(browse_doc["id"]) banner_match = (banner_reference == browse_doc["id"]) banner_index = index if (exact_match || banner_match) && banner_index.nil? - CallnumberItem.new(browse_doc: browse_doc, catalog_doc: catalog_doc(browse_doc["bib_id"]), exact_match: exact_match) + CallNumberItem.new(browse_doc: browse_doc, catalog_doc: catalog_doc(browse_doc["bib_id"]), exact_match: exact_match) end banner_index.nil? ? my_items : my_items.insert(banner_index, match_notice) end @@ -53,7 +53,7 @@ def catalog_doc(bib_id) end end -class CallnumberList::Error < CallnumberList +class CallNumberList::Error < CallNumberList attr_reader :original_reference def initialize(original_reference = "") @original_reference = original_reference diff --git a/lib/models/datastores.rb b/lib/models/datastores.rb index 8ed97c7..1adeb14 100644 --- a/lib/models/datastores.rb +++ b/lib/models/datastores.rb @@ -23,7 +23,7 @@ def label end def href - ENV.fetch("SEARCH_URL") + @datastore[:href] + S.search_url + @datastore[:href] end def current? diff --git a/lib/models/search_dropdown.rb b/lib/models/search_dropdown.rb index 7bcb2a0..5157273 100644 --- a/lib/models/search_dropdown.rb +++ b/lib/models/search_dropdown.rb @@ -17,15 +17,15 @@ class SearchDropdown::Browse < SearchDropdown def url case @type when "browse_by_callnumber" - "#{ENV.fetch("BASE_URL")}/callnumber?query=#{encoded_query}" + "#{S.base_url}/callnumber?query=#{encoded_query}" when "browse_by_author" - "#{ENV.fetch("BASE_URL")}/author?query=#{encoded_query}" + "#{S.base_url}/author?query=#{encoded_query}" when "browse_by_subject" - "#{ENV.fetch("BASE_URL")}/subject?query=#{encoded_query}" + "#{S.base_url}/subject?query=#{encoded_query}" else # Users shouldn't be able to do this; # Send them back to search without their query if it happens. - ENV.fetch("SEARCH_URL") + S.search_url end end @@ -38,7 +38,7 @@ def encoded_query class SearchDropdown::Search < SearchDropdown def url - "#{ENV.fetch("SEARCH_URL")}/catalog?query=#{encoded_query}" + "#{S.search_url}/catalog?query=#{encoded_query}" end private diff --git a/lib/models/subject_item.rb b/lib/models/subject_item.rb index 5126152..76d134c 100644 --- a/lib/models/subject_item.rb +++ b/lib/models/subject_item.rb @@ -163,7 +163,7 @@ def record_text end def url - "#{ENV.fetch("BASE_URL")}/subject?query=#{URI.encode_www_form_component(@subject)}" + "#{S.base_url}/subject?query=#{URI.encode_www_form_component(@subject)}" end def heading_link? diff --git a/lib/models/subject_list.rb b/lib/models/subject_list.rb index bbd21a5..10ed75c 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, - browse_solr_client: BrowseSolrClient.new(core: ENV.fetch("AUTHORITY_CORE"), match_field: "term", q: "browse_field:subject") + browse_solr_client: BrowseSolrClient.new(core: S.authority_collection, match_field: "term", q: "browse_field:subject") ) new(browse_list: browse_list) diff --git a/lib/services.rb b/lib/services.rb index 832f477..4dd6417 100644 --- a/lib/services.rb +++ b/lib/services.rb @@ -3,17 +3,24 @@ Services = Canister.new S = Services -S.register(:solr_cloud_on?) do - ENV["SOLR_CLOUD_ON"] == "true" +S.register(:solrcloud_on?) do + ENV["SOLRCLOUD_ON"] == "true" end -S.register(:author_solr) do - ENV["AUTHOR_SOLR"] || ENV["BROWSE_SOLR"] +S.register(:call_number_collection) do + S.solrcloud_on? ? ENV["CALL_NUMBER_COLLECTION"] : ENV["CALLNUMBER_CORE"] +end + +S.register(:authority_collection) do + S.solrcloud_on? ? ENV["AUTHORITY_COLLECTION"] : ENV["AUTHORITY_CORE"] +end + +S.register(:solr_url) do + S.solrcloud_on? ? ENV["SOLRCLOUD_URL"] : ENV["BROWSE_SOLR"] end [ - "BROWSE_SOLR", "BIBLIO_SOLR", "SOLR_USER", "SOLR_PASSWORD", - "CALLNUMBER_CORE", "AUTHORITY_CORE" + "BIBLIO_SOLR", "SOLR_USER", "SOLR_PASSWORD", "BASE_URL", "SEARCH_URL" ].each do |e| Services.register(e.downcase.to_sym) { ENV[e] } end diff --git a/lib/utilities/browse_solr_client.rb b/lib/utilities/browse_solr_client.rb index 9f9ae0a..8df99a3 100644 --- a/lib/utilities/browse_solr_client.rb +++ b/lib/utilities/browse_solr_client.rb @@ -1,12 +1,12 @@ require "faraday" class BrowseSolrClient - def initialize(solr_url: ENV.fetch("BROWSE_SOLR"), core: ENV.fetch("CALLNUMBER_CORE"), match_field: "callnumber", q: "*:*", solr_cloud_on: false) + def initialize(solr_url: S.solr_url, core: S.call_number_collection, match_field: "callnumber", q: "*:*") @conn = Faraday.new( url: solr_url ) do |f| f.request :json - f.request :authorization, :basic, ENV["SOLR_USER"], ENV["SOLR_PASSWORD"] if solr_cloud_on + f.request :authorization, :basic, S.solr_user, S.solr_password if S.solrcloud_on? # f.request :retry, {max: 1, retry_statuses: [500]} f.response :json end @@ -39,7 +39,7 @@ def browse(rows:, sort:, range:) @conn.public_send(:get, "#{@path_prefix}/select", query) end - def exact_matches(value: callnumber) + def exact_matches(value:) query = { q: @q, fq: %(#{@match_field}:"#{value}"), diff --git a/spec/models/author_list_spec.rb b/spec/models/author_list_spec.rb index 73f0b5b..685bdf3 100644 --- a/spec/models/author_list_spec.rb +++ b/spec/models/author_list_spec.rb @@ -36,13 +36,13 @@ context "#previous_url" do it "returns appropriate url" do allow(@browse_list).to receive(:previous_url_params).and_return({param_1: "value_1", param_2: "value_2"}) - expect(subject.previous_url).to eq("#{ENV.fetch("BASE_URL")}/author?param_1=value_1¶m_2=value_2") + expect(subject.previous_url).to eq("#{S.base_url}/author?param_1=value_1¶m_2=value_2") end end context "#next_url" do it "returns appropriate url" do allow(@browse_list).to receive(:next_url_params).and_return({param_1: "value_1", param_2: "value_2"}) - expect(subject.next_url).to eq("#{ENV.fetch("BASE_URL")}/author?param_1=value_1¶m_2=value_2") + expect(subject.next_url).to eq("#{S.base_url}/author?param_1=value_1¶m_2=value_2") end end end diff --git a/spec/models/callnumber_item_spec.rb b/spec/models/callnumber_item_spec.rb index 00470e2..3dbcc12 100644 --- a/spec/models/callnumber_item_spec.rb +++ b/spec/models/callnumber_item_spec.rb @@ -1,5 +1,5 @@ require_relative "../spec_helper" -describe CallnumberItem do +describe CallNumberItem do before(:each) do @catalog_doc = JSON.parse(fixture("zhizn_bib.json")) @index_doc = JSON.parse(fixture("zhizn_browse.json")) @@ -11,6 +11,9 @@ it "has false match_notice?" do expect(subject.match_notice?).to eq(false) end + it "shows call_number" do + expect(subject.call_number).to eq("PQ 1852 .B85 1992") + end it "shows callnumber" do expect(subject.callnumber).to eq("PQ 1852 .B85 1992") end diff --git a/spec/models/callnumber_list_spec.rb b/spec/models/callnumber_list_spec.rb index 69a58ca..f0f5579 100644 --- a/spec/models/callnumber_list_spec.rb +++ b/spec/models/callnumber_list_spec.rb @@ -1,4 +1,4 @@ -describe CallnumberList do +describe CallNumberList do before(:each) do @browse_list = instance_double(BrowseList, original_reference: "callnumber") end @@ -36,17 +36,17 @@ context "#previous_url" do it "returns appropriate url" do allow(@browse_list).to receive(:previous_url_params).and_return({param_1: "value_1", param_2: "value_2"}) - expect(subject.previous_url).to eq("#{ENV.fetch("BASE_URL")}/callnumber?param_1=value_1¶m_2=value_2") + expect(subject.previous_url).to eq("#{S.base_url}/callnumber?param_1=value_1¶m_2=value_2") end end context "#next_url" do it "returns appropriate url" do allow(@browse_list).to receive(:next_url_params).and_return({param_1: "value_1", param_2: "value_2"}) - expect(subject.next_url).to eq("#{ENV.fetch("BASE_URL")}/callnumber?param_1=value_1¶m_2=value_2") + expect(subject.next_url).to eq("#{S.base_url}/callnumber?param_1=value_1¶m_2=value_2") end end end -describe CallnumberList::Error do +describe CallNumberList::Error do before(:each) do @params = { original_reference: "OSU" diff --git a/spec/models/datastores_spec.rb b/spec/models/datastores_spec.rb index b6fb8d2..b9b6728 100644 --- a/spec/models/datastores_spec.rb +++ b/spec/models/datastores_spec.rb @@ -31,7 +31,7 @@ end context "#href" do it "has an href" do - expect(datastore.href).to eq("#{ENV.fetch("SEARCH_URL")}/datastore") + expect(datastore.href).to eq("#{S.search_url}/datastore") end end context "#current?" do diff --git a/spec/models/search_dropdown_spec.rb b/spec/models/search_dropdown_spec.rb index 7be15c2..789e28a 100644 --- a/spec/models/search_dropdown_spec.rb +++ b/spec/models/search_dropdown_spec.rb @@ -15,7 +15,7 @@ def encoded_query(query) end it "returns appropriate browse url" do @type = "browse_by_callnumber" - expect(subject).to eq("#{ENV.fetch("BASE_URL")}/callnumber?query=#{encoded_query("Things")}") + expect(subject).to eq("#{S.base_url}/callnumber?query=#{encoded_query("Things")}") end it "sends the user to search if they submit nonexistent browse_by type" do @type = "browse_by_something_that_does_not_exist" diff --git a/spec/models/subject_list_spec.rb b/spec/models/subject_list_spec.rb index e5f437e..e20a3c3 100644 --- a/spec/models/subject_list_spec.rb +++ b/spec/models/subject_list_spec.rb @@ -43,13 +43,13 @@ context "#previous_url" do it "returns appropriate url" do allow(@browse_list).to receive(:previous_url_params).and_return({param_1: "value_1", param_2: "value_2"}) - expect(subject.previous_url).to eq("#{ENV.fetch("BASE_URL")}/subject?param_1=value_1¶m_2=value_2") + expect(subject.previous_url).to eq("#{S.base_url}/subject?param_1=value_1¶m_2=value_2") end end context "#next_url" do it "returns appropriate url" do allow(@browse_list).to receive(:next_url_params).and_return({param_1: "value_1", param_2: "value_2"}) - expect(subject.next_url).to eq("#{ENV.fetch("BASE_URL")}/subject?param_1=value_1¶m_2=value_2") + expect(subject.next_url).to eq("#{S.base_url}/subject?param_1=value_1¶m_2=value_2") end end end diff --git a/spec/requests_spec.rb b/spec/requests_spec.rb index 94033c8..0549211 100644 --- a/spec/requests_spec.rb +++ b/spec/requests_spec.rb @@ -2,8 +2,8 @@ describe "requests" do include Rack::Test::Methods before(:each) do - @callnumbers_core = ENV.fetch("CALLNUMBER_CORE") - @authors_core = ENV.fetch("AUTHORITY_CORE") + @call_number_collection = S.call_number_collection + @authority_collection = S.authority_collection end context "get /" do it "has status OK" do @@ -13,46 +13,46 @@ end context "get /callnumber" do it "for a successful query, returns status OK" do - stub_solr_get_request(url: "#{@callnumbers_core}/select", query: hash_including({fq: 'callnumber:"Thing"'}), output: fixture("biblio_results.json")) - stub_solr_get_request(url: "#{@callnumbers_core}/select", query: hash_including({sort: "id desc"}), output: fixture("callnumbers_before.json")) - stub_solr_get_request(url: "#{@callnumbers_core}/select", query: hash_including({fq: 'id:["Thing" TO *]'}), output: fixture("callnumbers_results.json")) + stub_solr_get_request(url: "#{@call_number_collection}/select", query: hash_including({fq: 'callnumber:"Thing"'}), output: fixture("biblio_results.json")) + stub_solr_get_request(url: "#{@call_number_collection}/select", query: hash_including({sort: "id desc"}), output: fixture("callnumbers_before.json")) + stub_solr_get_request(url: "#{@call_number_collection}/select", query: hash_including({fq: 'id:["Thing" TO *]'}), output: fixture("callnumbers_results.json")) stub_biblio_get_request(url: "biblio/select", query: hash_including({}), output: fixture("biblio_results_middle.json")) get "/callnumber", {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: "#{@callnumbers_core}/select", query: hash_including({fq: 'callnumber:"Thing"'}), no_return: true).to_timeout - stub_solr_get_request(url: "#{@callnumbers_core}/select", query: hash_including({sort: "id desc"}), no_return: true).to_timeout + stub_solr_get_request(url: "#{@call_number_collection}/select", query: hash_including({fq: 'callnumber:"Thing"'}), no_return: true).to_timeout + stub_solr_get_request(url: "#{@call_number_collection}/select", query: hash_including({sort: "id desc"}), no_return: true).to_timeout get "/callnumber", {query: "Thing"} expect(last_response.status).to eq(200) end end context "get /author" do it "returns status OK" do - stub_solr_get_request(url: "#{@authors_core}/select", query: hash_including({fq: 'term:"Thing"'}), output: fixture("author_exact_matches.json")) - stub_solr_get_request(url: "#{@authors_core}/select", query: hash_including({sort: "id desc"}), output: fixture("author_results.json")) - stub_solr_get_request(url: "#{@authors_core}/select", query: hash_including({fq: 'id:["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: "id desc"}), output: fixture("author_results.json")) + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: 'id:["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: "#{@authors_core}/select", query: hash_including({fq: 'term:"Thing"'}), no_return: true).to_timeout - stub_solr_get_request(url: "#{@authors_core}/select", query: hash_including({sort: "id 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: "id 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: "#{@authors_core}/select", query: hash_including({fq: 'term:"Thing"'}), output: fixture("author_exact_matches.json")) - stub_solr_get_request(url: "#{@authors_core}/select", query: hash_including({sort: "id desc"}), output: fixture("subject_results.json")) - stub_solr_get_request(url: "#{@authors_core}/select", query: hash_including({fq: 'id:["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: "id desc"}), output: fixture("subject_results.json")) + stub_solr_get_request(url: "#{@authority_collection}/select", query: hash_including({fq: 'id:["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: "#{@authors_core}/select", query: hash_including({fq: 'term:"Thing"'}), no_return: true).to_timeout - stub_solr_get_request(url: "#{@authors_core}/select", query: hash_including({sort: "id 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: "id desc"}), no_return: true).to_timeout get "/subject", {query: "Thing"} expect(last_response.status).to eq(200) end @@ -61,7 +61,7 @@ it "redirects to appropriate url for given parameters" do post "/search", {type: "browse_by_author", query: "Thing"} expect(last_response.status).to eq(302) - expect(last_response.headers["Location"]).to eq("#{ENV.fetch("BASE_URL")}/author?query=Thing") + expect(last_response.headers["Location"]).to eq("#{S.base_url}/author?query=Thing") end end context "get /-/live" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 98f72ef..4931452 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,8 +28,7 @@ def app = Sinatra::Application end # set up dependencies -S.register(:author_solr) { S.browse_solr } -S.register(:solr_cloud_on?) { false } +S.register(:solrcloud_on?) { true } RSpec.configure do |config| config.include RSpecMixin @@ -125,9 +124,10 @@ def stub_solr_get_request(url:, output: "{}", status: 200, query: nil, no_return :accept => "*/*", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" } + req_attributes[:basic_auth] = [S.solr_user, S.solr_password] req_attributes[:query] = query unless query.nil? resp = {headers: {content_type: "application/json"}, status: status, body: output} - req = stub_request(:get, "#{ENV["BROWSE_SOLR"]}/#{url}").with(**req_attributes) + req = stub_request(:get, "#{S.solr_url}/#{url}").with(**req_attributes) if no_return.nil? req.to_return(**resp) @@ -144,7 +144,7 @@ def stub_biblio_get_request(url:, output: "{}", status: 200, query: nil, no_retu } req_attributes[:query] = query unless query.nil? resp = {headers: {content_type: "application/json"}, status: status, body: output} - req = stub_request(:get, "#{ENV["BIBLIO_SOLR"]}/#{url}").with(**req_attributes) + req = stub_request(:get, "#{S.biblio_solr}/#{url}").with(**req_attributes) if no_return.nil? req.to_return(**resp) else diff --git a/spec/utilities/browse_solr_client_spec.rb b/spec/utilities/browse_solr_client_spec.rb index 504646a..8d0df28 100644 --- a/spec/utilities/browse_solr_client_spec.rb +++ b/spec/utilities/browse_solr_client_spec.rb @@ -4,11 +4,11 @@ end context "#exact_matches" do it "returns an array of ids for an exact match" do - stub_solr_get_request(url: "#{ENV.fetch("CALLNUMBER_CORE")}/select", query: hash_including({fq: 'callnumber:"Thing"'}), output: fixture("biblio_results.json")) + stub_solr_get_request(url: "#{S.call_number_collection}/select", query: hash_including({fq: 'callnumber:"Thing"'}), output: fixture("biblio_results.json")) expect(subject.exact_matches(value: "Thing")).to eq(["990059013360106381", "990011613060106381", "990085202960106381", "990155473530106381", "990017586110106381"]) end it "returns an empty errary if the solr request fails" do - stub_solr_get_request(url: "#{ENV.fetch("CALLNUMBER_CORE")}/select", query: hash_including({fq: 'callnumber:"Thing"'}), no_return: true).to_timeout + stub_solr_get_request(url: "#{S.call_number_collection}/select", query: hash_including({fq: 'callnumber:"Thing"'}), no_return: true).to_timeout expect(subject.exact_matches(value: "Thing")).to eq([]) end end diff --git a/views/call_number.erb b/views/call_number.erb index abf8fa1..bea01da 100644 --- a/views/call_number.erb +++ b/views/call_number.erb @@ -18,7 +18,7 @@