qa 5.11.0 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b356b770cbc77b1d67024f2a73be01b579943e75d9bda64e7f7dad04f66342b
4
- data.tar.gz: a3f6a66764724811209c8616e00f260cab0d371f340117f335d384c1f84d1bd6
3
+ metadata.gz: 240eaf6a35e71e0663c25ad33ccc37515f60a72787f7073dd6b158505896e5e8
4
+ data.tar.gz: a00c4b833fd76ccc548e742fd0338ecf1492f9d18349d3cfa1cfee58015dbb75
5
5
  SHA512:
6
- metadata.gz: 798c03132eac1750d15b0db93e2c6009925b1ebd3773619df77cd11f3f0cd661b6645d5e54122842efdc3e86d221356fb38aca6705943c35a5dc03d0a7010d2d
7
- data.tar.gz: f1a3e23f4f3eb3197c3f8e39e2a9663ae7329a7e1e46e100f60d91f3b01b55e46a19ded39ac4b88520ec29189adc1e3d948bbfca7422044a92dc2c26d6eb3367
6
+ metadata.gz: 87ef10f83a3e903da5e602737083f138ca95848adce671b041b75a44b2b254e8377d260b603a0687177d90044a6bb127fd102f8b596724afec09a718a6a2ae30
7
+ data.tar.gz: 49ec9dd06d050f71d9dc7b4f077611cdbb5532832f83771510ab5e56a817c0a5c3852bdcddde56eba6d09b6bc25dbe3e33f99453fb15ba2e87cf6dd172b7637d
@@ -46,7 +46,10 @@ module Qa::Authorities
46
46
  index = AssignFast.index_for_authority(subauthority)
47
47
  return_data = "#{index}%2Cidroot%2Cauth%2Ctype"
48
48
  num_rows = 20 # max allowed by the API
49
- "http://fast.oclc.org/searchfast/fastsuggest?&query=#{escaped_query}&queryIndex=#{index}&queryReturn=#{return_data}&suggest=autoSubject&rows=#{num_rows}"
49
+
50
+ # sort=usage+desc is not documented by OCLC but seems necessary to get the sort
51
+ # we formerly got without specifying, that is most useful in our use case.
52
+ "http://fast.oclc.org/searchfast/fastsuggest?&query=#{escaped_query}&queryIndex=#{index}&queryReturn=#{return_data}&suggest=autoSubject&rows=#{num_rows}&sort=usage+desc"
50
53
  end
51
54
 
52
55
  private
@@ -54,7 +54,7 @@ module Qa::Authorities
54
54
  end
55
55
  rescue StandardError => e
56
56
  cause = response.fetch('error', {}).fetch('cause', 'UNKNOWN')
57
- cause = cause.present? ? cause : 'UNKNOWN'
57
+ cause = cause.presence || 'UNKNOWN'
58
58
  Rails.logger.warn " ERROR fetching Getty response: #{e.message}; cause: #{cause}"
59
59
  {}
60
60
  end
@@ -54,7 +54,7 @@ module Qa::Authorities
54
54
  end
55
55
  rescue StandardError => e
56
56
  cause = response.fetch('error', {}).fetch('cause', 'UNKNOWN')
57
- cause = cause.present? ? cause : 'UNKNOWN'
57
+ cause = cause.presence || 'UNKNOWN'
58
58
  Rails.logger.warn " ERROR fetching Getty response: #{e.message}; cause: #{cause}"
59
59
  {}
60
60
  end
data/lib/qa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qa
2
- VERSION = "5.11.0".freeze
2
+ VERSION = "5.12.0".freeze
3
3
  end
@@ -199,7 +199,7 @@ describe Qa::TermsController, type: :controller do
199
199
 
200
200
  context "assign_fast" do
201
201
  before do
202
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word&queryIndex=suggest50&queryReturn=suggest50,idroot,auth,type&rows=20&suggest=autoSubject")
202
+ stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word&queryIndex=suggest50&queryReturn=suggest50,idroot,auth,type&rows=20&suggest=autoSubject&sort=usage+desc")
203
203
  .with(headers: { 'Accept' => 'application/json' })
204
204
  .to_return(body: webmock_fixture("assign-fast-topical-result.json"), status: 200, headers: {})
205
205
  end
@@ -1,6 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::AssignFast do
4
+ let(:query) { "word (ling" }
5
+ let(:expected_url) { "http://fast.oclc.org/searchfast/fastsuggest?&query=word%20ling&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20&sort=usage+desc" }
6
+
4
7
  # subauthority infrastructure
5
8
  describe "#new" do
6
9
  context "without a sub-authority" do
@@ -30,8 +33,7 @@ describe Qa::Authorities::AssignFast do
30
33
  end
31
34
 
32
35
  it "is correctly formed" do
33
- url = 'http://fast.oclc.org/searchfast/fastsuggest?&query=word%20ling&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20'
34
- expect(authority.build_query_url("word (ling")).to eq(url)
36
+ expect(authority.build_query_url(query)).to eq(expected_url)
35
37
  end
36
38
  end
37
39
 
@@ -43,27 +45,29 @@ describe Qa::Authorities::AssignFast do
43
45
  context "when we sent a bad character" do
44
46
  # server returns 200 with empty response; JSON throws a ParserError
45
47
  before do
46
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word%20ling&queryIndex=suggestall&queryReturn=suggestall,idroot,auth,type&rows=20&suggest=autoSubject")
48
+ stub_request(:get, expected_url)
47
49
  .with(headers: { 'Accept' => 'application/json' })
48
50
  .to_return(status: 200, body: "", headers: {})
49
51
  end
50
52
  it "logs an info and returns an empty array" do
51
- expect(Rails.logger).to receive(:info).with('Retrieving json for url: http://fast.oclc.org/searchfast/fastsuggest?&query=word%20ling&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20')
52
- msg = "Could not parse response as JSON. Request url: " \
53
- "http://fast.oclc.org/searchfast/fastsuggest?&query=word%20ling&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20"
53
+ expect(Rails.logger).to receive(:info).with("Retrieving json for url: #{expected_url}")
54
+ msg = "Could not parse response as JSON. Request url: #{expected_url}"
54
55
  expect(Rails.logger).to receive(:info).with(msg)
55
- results = authority.search("word (ling")
56
+ results = authority.search(query)
56
57
  expect(results).to eq([])
57
58
  end
58
59
  end
59
60
 
60
61
  context "when query is blank" do
62
+ let(:query) { "" }
63
+ let(:expected_url) { "http://fast.oclc.org/searchfast/fastsuggest?&query=&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20&sort=usage+desc" }
64
+
61
65
  # server returns results but no results header
62
66
  let :results do
63
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?&query=&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20")
67
+ stub_request(:get, expected_url)
64
68
  .with(headers: { 'Accept' => 'application/json' })
65
69
  .to_return(body: webmock_fixture("assign-fast-noheader.json"), status: 200, headers: {})
66
- authority.search("")
70
+ authority.search(query)
67
71
  end
68
72
  it "returns an empty array" do
69
73
  expect(results).to eq([])
@@ -72,10 +76,10 @@ describe Qa::Authorities::AssignFast do
72
76
 
73
77
  context "with no results" do
74
78
  let :results do
75
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word%20ling&queryIndex=suggestall&queryReturn=suggestall,idroot,auth,type&rows=20&suggest=autoSubject")
79
+ stub_request(:get, expected_url)
76
80
  .with(headers: { 'Accept' => 'application/json' })
77
81
  .to_return(body: webmock_fixture("assign-fast-noresults.json"), status: 200, headers: {})
78
- authority.search("word (ling")
82
+ authority.search(query)
79
83
  end
80
84
  it "returns an empty array" do
81
85
  expect(results).to eq([])
@@ -84,10 +88,10 @@ describe Qa::Authorities::AssignFast do
84
88
 
85
89
  context "with suggestall results" do
86
90
  let :results do
87
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word%20ling&queryIndex=suggestall&queryReturn=suggestall,idroot,auth,type&rows=20&suggest=autoSubject")
91
+ stub_request(:get, expected_url)
88
92
  .with(headers: { 'Accept' => 'application/json' })
89
93
  .to_return(body: webmock_fixture("assign-fast-oneresult.json"), status: 200, headers: {})
90
- authority.search("word (ling")
94
+ authority.search(query)
91
95
  end
92
96
  it "is correctly parsed" do
93
97
  expect(results.count).to eq(1)
@@ -99,11 +103,14 @@ describe Qa::Authorities::AssignFast do
99
103
  end
100
104
 
101
105
  context "with topical results" do
106
+ let(:query) { "word" }
107
+ let(:expected_url) { "http://fast.oclc.org/searchfast/fastsuggest?query=word&queryIndex=suggest50&queryReturn=suggest50,idroot,auth,type&rows=20&suggest=autoSubject&sort=usage+desc" }
108
+
102
109
  let :results do
103
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word&queryIndex=suggest50&queryReturn=suggest50,idroot,auth,type&rows=20&suggest=autoSubject")
110
+ stub_request(:get, expected_url)
104
111
  .with(headers: { 'Accept' => 'application/json' })
105
112
  .to_return(body: webmock_fixture("assign-fast-topical-result.json"), status: 200, headers: {})
106
- described_class.subauthority_for("topical").search("word")
113
+ described_class.subauthority_for("topical").search(query)
107
114
  end
108
115
  it "is correctly parsed" do
109
116
  expect(results.count).to eq(20)
@@ -38,7 +38,7 @@ describe Qa::Authorities::Getty::AAT do
38
38
  # Rails 3.1 actually quotes the failing code in the error message,
39
39
  # so let's match this error message with a multiline regex instead of
40
40
  # a string.
41
- expect(Rails.logger).to receive(:warn).with(/ERROR fetching Getty response: .*undefined method.*for nil:NilClass.*; cause: UNKNOWN/m)
41
+ expect(Rails.logger).to receive(:warn).with(/ERROR fetching Getty response: .*undefined method.*for nil.*; cause: UNKNOWN/m)
42
42
  expect(subject).to be {}
43
43
  end
44
44
  end
@@ -38,7 +38,7 @@ describe Qa::Authorities::Getty::TGN do
38
38
  # Rails 3.1 actually quotes the failing code in the error message,
39
39
  # so let's match this error message with a multiline regex instead of
40
40
  # a string.
41
- expect(Rails.logger).to receive(:warn).with(/ERROR fetching Getty response: .*undefined method.*for nil:NilClass.*; cause: UNKNOWN/m)
41
+ expect(Rails.logger).to receive(:warn).with(/ERROR fetching Getty response: .*undefined method.*for nil.*; cause: UNKNOWN/m)
42
42
  expect(subject).to be {}
43
43
  end
44
44
  end
@@ -38,7 +38,7 @@ describe Qa::Authorities::Getty::Ulan do
38
38
  # Rails 3.1 actually quotes the failing code in the error message,
39
39
  # so let's match this error message with a multiline regex instead of
40
40
  # a string.
41
- expect(Rails.logger).to receive(:warn).with(/ERROR fetching Getty response: .*undefined method.*for nil:NilClass.*; cause: UNKNOWN/m)
41
+ expect(Rails.logger).to receive(:warn).with(/ERROR fetching Getty response: .*undefined method.*for nil.*; cause: UNKNOWN/m)
42
42
  expect(subject).to be {}
43
43
  end
44
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qa
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.11.0
4
+ version: 5.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Anderson
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2023-11-09 00:00:00.000000000 Z
19
+ date: 2024-08-06 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activerecord-import