Skip to content

Commit

Permalink
Merge pull request #323 from samvera/use-https
Browse files Browse the repository at this point in the history
Fixes issue limiting LoC results to an authority
  • Loading branch information
elrayle authored Aug 14, 2020
2 parents a9244dc + f6e0021 commit 8b76bdc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions lib/qa/authorities/loc_subauthority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ def preservation # rubocop:disable Metrics/MethodLength
private

def vocab_base_url
"cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fvocabulary%2F"
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2F"
end

def authority_base_url
"cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2F"
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2F"
end

def datatype_base_url
"cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fdatatypes%2F"
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fdatatypes%2F"
end

def vocab_preservation_base_url
"cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F"
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F"
end
end
2 changes: 1 addition & 1 deletion spec/controllers/terms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def search(_arg1, _arg2)

context "loc" do
before do
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:https://id.loc.gov/authorities/names")
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
.with(headers: { 'Accept' => 'application/json' })
.to_return(body: webmock_fixture("loc-names-response.txt"), status: 200)
end
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/authorities/loc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
end

context "for searching" do
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
it "returns a url" do
expect(authority.build_query_url("foo")).to eq(url)
end
Expand All @@ -49,15 +49,15 @@
end

before do
stub_request(:get, "https://id.loc.gov/search/?format=json&q=cs:https://id.loc.gov/authorities/subjects")
stub_request(:get, "https://id.loc.gov/search/?format=json&q=cs:http://id.loc.gov/authorities/subjects")
.with(headers: { 'Accept' => 'application/json' })
.to_return(status: 200, body: "")
end

context "with flat params encoded" do
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
it "returns a response" do
flat_params_url = "https://id.loc.gov/search/?format=json&q=foo&q=cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects"
flat_params_url = "https://id.loc.gov/search/?format=json&q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects"
expect(subject.env.url.to_s).to eq(flat_params_url)
end
end
Expand All @@ -66,7 +66,7 @@
describe "#search" do
context "any LOC authorities" do
let :authority do
stub_request(:get, "https://id.loc.gov/search/?format=json&q=s&q=cs:https://id.loc.gov/vocabulary/geographicAreas")
stub_request(:get, "https://id.loc.gov/search/?format=json&q=s&q=cs:http://id.loc.gov/vocabulary/geographicAreas")
.with(headers: { 'Accept' => 'application/json' })
.to_return(body: webmock_fixture("loc-response.txt"), status: 200)
described_class.subauthority_for("geographicAreas")
Expand Down Expand Up @@ -95,7 +95,7 @@

context "subject terms" do
let :results do
stub_request(:get, "https://id.loc.gov/search/?format=json&q=History--&q=cs:https://id.loc.gov/authorities/subjects")
stub_request(:get, "https://id.loc.gov/search/?format=json&q=History--&q=cs:http://id.loc.gov/authorities/subjects")
.with(headers: { 'Accept' => 'application/json' })
.to_return(body: webmock_fixture("loc-subjects-response.txt"), status: 200)
described_class.subauthority_for("subjects").search("History--")
Expand All @@ -111,7 +111,7 @@

context "name terms" do
let :results do
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:https://id.loc.gov/authorities/names")
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
.with(headers: { 'Accept' => 'application/json' })
.to_return(body: webmock_fixture("loc-names-response.txt"), status: 200)
described_class.subauthority_for("names").search("Berry")
Expand Down

0 comments on commit 8b76bdc

Please sign in to comment.