qa 5.2.0 → 5.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 69b198054c52dafc00d9cf83f2f61b5fdc3e55cb
4
- data.tar.gz: 00aa3d111681efe0a1c068846190e41531155e21
2
+ SHA256:
3
+ metadata.gz: 7205f6d228b7548f6dc39ce9781dd4b591d2f4c5e56d5b2bcc4189b3c9005f7e
4
+ data.tar.gz: 5cdce31ba635c298e5da88cfc01cc86237426a45a1b8ccf3095c316c1eb7b8f4
5
5
  SHA512:
6
- metadata.gz: c75338fdecba820602eb3c669065679a87387e80bf65e350fdc42d6224dc5eb152439198257b6da3eb38812a9e44e6764472fa3a8fff3f554e782b13da0e4c38
7
- data.tar.gz: bcf795d36f8fc600dbc672d9884b4b37efd084ad9e12a7e53583b491cf122b1247f8335fdcfe216cfda6b2c3c326628ac27f2b6a375aa44feb783daf8ce0f2b5
6
+ metadata.gz: 39259b1eb80bcaab90653152302e38b853d24ecf1ff9bb46ca16afe637a35fe53b7d4abcf85ee2cc7ee7550b57bb6e7505f558adb10792056ea5573d7607b025
7
+ data.tar.gz: 3a748c62a1aa1b05d0f0b768af0a03ea2d2c6918c892c40cfc7ab1fdb619866053fb272d16b20a3241b9024c5d1dde8521fde108c36e33b59d55037d5d618e96
data/README.md CHANGED
@@ -1,77 +1,83 @@
1
1
  # Questioning Authority
2
2
 
3
- Code:
4
- [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa)
5
- [![Build Status](https://circleci.com/gh/samvera/questioning_authority.svg?style=svg)](https://circleci.com/gh/samvera/questioning_authority)
6
- [![Coverage Status](https://coveralls.io/repos/github/samvera/questioning_authority/badge.svg?branch=master)](https://coveralls.io/github/samvera/questioning_authority?branch=master)
3
+ Code: [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa) [![Build Status](https://circleci.com/gh/samvera/questioning_authority.svg?style=svg)](https://circleci.com/gh/samvera/questioning_authority) [![Coverage Status](https://coveralls.io/repos/github/samvera/questioning_authority/badge.svg?branch=master)](https://coveralls.io/github/samvera/questioning_authority?branch=master)
7
4
 
8
- Docs:
9
- [![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md)
10
- [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)
5
+ Docs: [![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md) [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)
11
6
 
12
7
  Jump In: [![Slack Status](http://slack.samvera.org/badge.svg)](http://slack.samvera.org/)
13
8
 
14
9
  You should question your authorities.
15
10
 
16
- ----
11
+ --------------------------------------------------------------------------------
12
+
17
13
  ## Table of Contents
18
14
 
19
- * [What does this do?](#what-does-this-do)
20
- * [How does it work?](#how-does-it-work)
21
- * [Sub-Authorities](#sub-authorities)
22
- * [How do I use this?](#how-do-i-use-this)
23
- * [Basic QA Requests](#basic-qa-requests)
24
- * [Typical JSON Results](#typical-json-results)
25
- * [Authority Sources information](#authority-sources-information)
26
- * [Developer Notes](#developer-notes)
27
- * [Compatibility](#compatibility)
28
- * [Product Owner & Maintenance](#product-owner--maintenance)
29
- * [Product Owner](#product-owner)
30
- * [Help](#help)
31
- * [Acknowledgments](#acknowledgments)
32
-
33
- ## Not seeing documentation you used to find in the README?
34
-
35
- Much of the documentation has moved to the [Questioning Authority wiki](https://github.com/samvera/questioning_authority/wiki) to allow for better organization. We hope that you will find this easier to use.
36
-
37
- ----
15
+ - [What does this do?](#what-does-this-do)
16
+ - [How does it work?](#how-does-it-work)
17
+
18
+ - [Sub-Authorities](#sub-authorities)
19
+
20
+ - [How do I use this?](#how-do-i-use-this)
21
+
22
+ - [Basic QA Requests](#basic-qa-requests)
23
+ - [Typical JSON Results](#typical-json-results)
24
+
25
+ - [Authority Sources information](#authority-sources-information)
26
+
27
+ - [Developer Notes](#developer-notes)
28
+
29
+ - [Compatibility](#compatibility)
30
+ - [Product Owner & Maintenance](#product-owner--maintenance)
31
+
32
+ - [Product Owner](#product-owner)
33
+
34
+ - [Help](#help)
35
+
36
+ - [Acknowledgments](#acknowledgments)
37
+
38
+ ## Not seeing documentation you used to find in the README?
39
+
40
+ Much of the documentation has moved to the [Questioning Authority wiki](https://github.com/samvera/questioning_authority/wiki) to allow for better organization. We hope that you will find this easier to use.
41
+
42
+ --------------------------------------------------------------------------------
43
+
38
44
  ## What does this do?
39
45
 
40
- Provides a set of uniform RESTful routes to query any controlled vocabulary or set of authority terms.
41
- Results are returned in JSON and can be used within the context of a Rails application or any other
42
- Ruby environment. Primary examples would include providing auto-complete functionality via Javascript
43
- or populating a dropdown menu with a set of terms.
46
+ Provides a set of uniform RESTful routes to query any controlled vocabulary or set of authority terms. Results are returned in JSON and can be used within the context of a Rails application or any other Ruby environment. Primary examples would include providing auto-complete functionality via Javascript or populating a dropdown menu with a set of terms.
44
47
 
45
48
  ## How does it work?
46
49
 
47
- Authorities are defined as classes, each implementing a set of methods allowing a controller to return
48
- results from a given vocabulary in the JSON format. The controller does three things:
50
+ Authorities are defined as classes, each implementing a set of methods allowing a controller to return results from a given vocabulary in the JSON format. The controller does three things:
49
51
 
50
- * provide a list of all terms (if allowed by the class)
51
- * return a set of terms matching a given query
52
- * return the complete information for a specific term given its identifier
52
+ - provide a list of all terms (if allowed by the class)
53
+ - return a set of terms matching a given query
54
+ - return the complete information for a specific term given its identifier
53
55
 
54
- Depending on the kind of authority or its API, the controller may not do all of these things such
55
- as return a complete list of terms.
56
+ Depending on the kind of authority or its API, the controller may not do all of these things such as return a complete list of terms.
56
57
 
57
58
  ### Sub-Authorities
58
59
 
59
- Some authorities, such as Library of Congress, allow sub-authorities which is an additional parameter that
60
- further defines the kind of authority to use with the context of a larger one.
60
+ Some authorities, such as Library of Congress, allow sub-authorities which is an additional parameter that further defines the kind of authority to use with the context of a larger one.
61
61
 
62
62
  ## How do I use this?
63
63
 
64
64
  Add the gem to your Gemfile
65
65
 
66
- gem 'qa'
66
+ ```
67
+ gem 'qa'
68
+ ```
67
69
 
68
70
  Run bundler
69
71
 
70
- bundle install
72
+ ```
73
+ bundle install
74
+ ```
71
75
 
72
76
  Install the gem to your application
73
77
 
74
- rails generate qa:install
78
+ ```
79
+ rails generate qa:install
80
+ ```
75
81
 
76
82
  This will copy over some additional config files and add the engine's routes to your `config/route.rb`.
77
83
 
@@ -79,84 +85,104 @@ Start questioning your authorities!
79
85
 
80
86
  ### Basic QA Requests
81
87
 
82
- These show the basic routing patterns for connecting to authorities. See the [Questioning Authority wiki](https://github.com/samvera/questioning_authority/wiki) documentation for detailed documentation and examples for each authority and local authorities.
88
+ These show the basic routing patterns for connecting to authorities. See the [Questioning Authority wiki](https://github.com/samvera/questioning_authority/wiki) documentation for detailed documentation and examples for each authority and local authorities.
83
89
 
84
90
  Return a complete list of terms:
85
91
 
86
- /qa/terms/:vocab
87
- /qa/terms/:vocab/:subauthority
92
+ ```
93
+ /qa/terms/:vocab
94
+ /qa/terms/:vocab/:subauthority
95
+ ```
88
96
 
89
97
  Return a set of terms matching a given query
90
98
 
91
- /qa/search/:vocab?q=search_term
92
- /qa/search/:vocab/:subauthority?q=search_term
99
+ ```
100
+ /qa/search/:vocab?q=search_term
101
+ /qa/search/:vocab/:subauthority?q=search_term
102
+ ```
93
103
 
94
104
  Return the complete information for a specific term given its identifier
95
105
 
96
- /qa/show/:vocab/:id
97
- /qa/show/:vocab/:subauthority/:id
98
-
99
-
106
+ ```
107
+ /qa/show/:vocab/:id
108
+ /qa/show/:vocab/:subauthority/:id
109
+ ```
100
110
 
101
111
  ### Typical JSON Results
102
112
 
103
113
  Results are returned in JSON in this format:
104
114
 
105
- [
106
- {"id" : "subject_id_1", "label" : "First labels"},
107
- {"id" : "subject_id_2", "label" : "Printing labels"},
108
- {"id" : "", "label" : "This term has no id number"},
109
- {"id" : "", "label" : "Neither does this"}
110
- ]
111
-
115
+ ```
116
+ [
117
+ {"id" : "subject_id_1", "label" : "First labels"},
118
+ {"id" : "subject_id_2", "label" : "Printing labels"},
119
+ {"id" : "", "label" : "This term has no id number"},
120
+ {"id" : "", "label" : "Neither does this"}
121
+ ]
122
+ ```
112
123
 
113
124
  # Authority Sources information
114
125
 
115
126
  See the [Questioning Authority wiki](https://github.com/samvera/questioning_authority/wiki) for documentation on how to connect to the supported authorities, documentation on how to create new authorities, and other useful tips.
116
127
 
117
-
118
128
  # Developer Notes
119
129
 
120
130
  [How to Contribute](./CONTRIBUTING.md)
121
131
 
122
132
  To develop this gem, clone the repository, then run:
123
133
 
124
- bundle install
125
- rake ci
134
+ ```
135
+ bundle install
136
+ rake ci
137
+ ```
126
138
 
127
- This will install the gems, create a dummy application under spec/internal and run the tests. After you've made changes,
128
- make sure you've included tests and run the test suite with a new sample application:
139
+ This will install the gems, create a dummy application under spec/internal and run the tests. After you've made changes, make sure you've included tests and run the test suite with a new sample application:
129
140
 
130
- rake engine_cart:clean
131
- rake ci
141
+ ```
142
+ rake engine_cart:clean
143
+ rake ci
144
+ ```
132
145
 
133
146
  Commit your features into a new branch and submit a pull request.
134
147
 
135
148
  ## Compatibility
136
149
 
137
- * Ruby 2.5 or the latest 2.4 version is recommended. Later versions may also work.
138
- * Rails 5 is required. We recommend the latest Rails 5.2 release.
150
+ - Ruby 2.5 or the latest 2.4 version is recommended. Later versions may also work.
151
+ - Rails 5 is required. We recommend the latest Rails 5.2 release.
139
152
 
140
153
  ## Product Owner & Maintenance
141
154
 
142
- Questioning Authority is a Core Component of the Samvera community. The documentation for
143
- what this means can be found [here](http://samvera.github.io/core_components.html#requirements-for-a-core-component).
155
+ Questioning Authority is a Core Component of the Samvera community. The documentation for what this means can be found [here](http://samvera.github.io/core_components.html#requirements-for-a-core-component).
144
156
 
145
157
  ### Product Owner
146
158
 
147
159
  [elrayle](https://github.com/elrayle)
148
160
 
161
+ ## Releasing
162
+
163
+ 1. `bundle install`
164
+ 2. Increase the version number in `lib/qa/version.rb`
165
+ 3. Increase the same version number in `.github_changelog_generator`
166
+ 4. Update `CHANGELOG.md` by running this command:
167
+
168
+ ```
169
+ github_changelog_generator --user samvera --project questioning_authority --token YOUR_GITHUB_TOKEN_HERE
170
+ ```
171
+
172
+ 5. Commit these changes to the master branch
173
+
174
+ 6. Run `rake release`
175
+
149
176
  # Help
150
177
 
151
178
  The Samvera community is here to help. Please see our [support guide](./SUPPORT.md).
152
179
 
153
180
  # Acknowledgments
154
181
 
155
- This software has been developed by and is brought to you by the Samvera community. Learn more at the
156
- [Samvera website](http://samvera.org/).
182
+ This software has been developed by and is brought to you by the Samvera community. Learn more at the [Samvera website](http://samvera.org/).
157
183
 
158
184
  ![Samvera Logo](https://wiki.duraspace.org/download/thumbnails/87459292/samvera-fall-font2-200w.png?version=1&modificationDate=1498550535816&api=v2)
159
185
 
160
- ### Special thanks to...
186
+ ## Special thanks to...
161
187
 
162
188
  [Jeremy Friesen](https://github.com/jeremyf) who gave us the name for our gem.
@@ -91,6 +91,7 @@ module Qa
91
91
  end
92
92
 
93
93
  def process_error(e, url)
94
+ Rails.logger.warn("******** RDF::Graph#load failure: exception=#{e.inspect}, url=#{url}")
94
95
  uri = URI(url)
95
96
  raise RDF::FormatError, "Unknown RDF format of results returned by #{uri}. (RDF::FormatError) You may need to include gem 'linkeddata'." if e.is_a? RDF::FormatError
96
97
  response_code = ioerror_code(e)
@@ -1,8 +1,9 @@
1
1
  # Service to construct a request header that includes optional attributes for search and fetch requests.
2
+ require 'geocoder'
2
3
  module Qa
3
4
  module LinkedData
4
5
  class RequestHeaderService
5
- attr_reader :request, :params
6
+ attr_reader :request, :params, :request_id
6
7
 
7
8
  # @param request [HttpRequest] request from controller
8
9
  # @param params [Hash] attribute-value pairs holding the request parameters
@@ -16,6 +17,8 @@ module Qa
16
17
  def initialize(request:, params:)
17
18
  @request = request
18
19
  @params = params
20
+ @request_id = request.request_id
21
+ log_request
19
22
  end
20
23
 
21
24
  # Construct request parameters to pass to search_query (linked data module).
@@ -23,6 +26,8 @@ module Qa
23
26
  # @see Qa::Authorities::LinkedData::SearchQuery
24
27
  def search_header
25
28
  header = {}
29
+ header[:request] = request
30
+ header[:request_id] = request_id
26
31
  header[:subauthority] = params.fetch(:subauthority, nil)
27
32
  header[:user_language] = user_language
28
33
  header[:performance_data] = performance_data?
@@ -37,6 +42,8 @@ module Qa
37
42
  # @see Qa::Authorities::LinkedData::FindTerm
38
43
  def fetch_header
39
44
  header = {}
45
+ header[:request] = request
46
+ header[:request_id] = request_id
40
47
  header[:subauthority] = params.fetch(:subauthority, nil)
41
48
  header[:user_language] = user_language
42
49
  header[:performance_data] = performance_data?
@@ -62,6 +69,18 @@ module Qa
62
69
 
63
70
  private
64
71
 
72
+ def log_request
73
+ msg = "******** #{request.path_parameters[:action].upcase}"
74
+ unless Qa.config.suppress_ip_data_from_log
75
+ gc = request.respond_to?(:location) ? request.location : nil
76
+ city = gc.nil? ? "UNKNOWN" : gc.city
77
+ state = gc.nil? ? "UNKNOWN" : gc.state
78
+ country = gc.nil? ? "UNKNOWN" : gc.country
79
+ msg += " from IP #{request.ip} in {city: #{city}, state: #{state}, country: #{country}}"
80
+ end
81
+ Rails.logger.info(msg)
82
+ end
83
+
65
84
  # filter literals in results to this language
66
85
  def user_language
67
86
  request_language = request.env['HTTP_ACCEPT_LANGUAGE']
@@ -23,4 +23,9 @@ Qa.config do |config|
23
23
  # When false, properties that do not override default optional behavior will be shown whether or not the property has a value in the graph.
24
24
  # When true, properties that do not override default optional behavior will not be shown whn the property does not have a value in the graph.
25
25
  # config.property_map_default_for_optional = false
26
+
27
+ # IP data including IP address, city, state, and country will be logged with each request.
28
+ # When false, IP data is logged
29
+ # When true, IP data will not be logged (default for backward compatibility)
30
+ # config.suppress_ip_data_from_log = true
26
31
  end
@@ -2,7 +2,33 @@ module Qa::Authorities
2
2
  class Geonames < Base
3
3
  include WebServiceBase
4
4
 
5
- class_attribute :username, :label
5
+ class_attribute :username, :label, :query_url_host, :find_url_host
6
+
7
+ # You may need to change your query_url_host in your implementation. To do
8
+ # so, in the installed application's config/initializers/qa.rb add the
9
+ # following:
10
+ #
11
+ # @example
12
+ # Qa::Authorities::Geonames.query_url_host = "http://ws.geonames.net"
13
+ #
14
+ # @note This is not exposed as part of the configuration block, but is
15
+ # something you can add after the configuration block.
16
+ # @todo Expose this magic value as a configuration option; Which likely
17
+ # requires consideration about how to do this for the general case
18
+ self.query_url_host = "http://api.geonames.org"
19
+
20
+ # You may need to change your query_url_host in your implementation. To do
21
+ # so, in the installed application's config/initializers/qa.rb add the
22
+ # following:
23
+ #
24
+ # @example
25
+ # Qa::Authorities::Geonames.find_url_host = "http://ws.geonames.net"
26
+ #
27
+ # @note This is not exposed as part of the configuration block, but is
28
+ # something you can add after the configuration block.
29
+ # @todo Expose this magic value as a configuration option; Which likely
30
+ # requires consideration about how to do this for the general case
31
+ self.find_url_host = "http://www.geonames.org"
6
32
 
7
33
  self.label = lambda do |item|
8
34
  [item['name'], item['adminName1'], item['countryName']].compact.join(', ')
@@ -18,7 +44,7 @@ module Qa::Authorities
18
44
 
19
45
  def build_query_url(q)
20
46
  query = ERB::Util.url_encode(untaint(q))
21
- "http://api.geonames.org/searchJSON?q=#{query}&username=#{username}&maxRows=10"
47
+ File.join(query_url_host, "searchJSON?q=#{query}&username=#{username}&maxRows=10")
22
48
  end
23
49
 
24
50
  def untaint(q)
@@ -30,7 +56,7 @@ module Qa::Authorities
30
56
  end
31
57
 
32
58
  def find_url(id)
33
- "http://www.geonames.org/getJSON?geonameId=#{id}&username=#{username}"
59
+ File.join(find_url_host, "getJSON?geonameId=#{id}&username=#{username}")
34
60
  end
35
61
 
36
62
  private
@@ -39,7 +65,7 @@ module Qa::Authorities
39
65
  def parse_authority_response(response)
40
66
  response['geonames'].map do |result|
41
67
  # Note: the trailing slash is meaningful.
42
- { 'id' => "http://sws.geonames.org/#{result['geonameId']}/",
68
+ { 'id' => "https://sws.geonames.org/#{result['geonameId']}/",
43
69
  'label' => label.call(result) }
44
70
  end
45
71
  end
@@ -15,8 +15,8 @@ module Qa::Authorities
15
15
  @term_config = term_config
16
16
  end
17
17
 
18
- attr_reader :term_config, :full_graph, :filtered_graph, :language, :id, :uri, :access_time_s, :normalize_time_s, :subauthority, :request_header
19
- private :full_graph, :filtered_graph, :language, :id, :uri, :access_time_s, :normalize_time_s, :subauthority, :request_header
18
+ attr_reader :term_config, :full_graph, :filtered_graph, :language, :id, :uri, :access_time_s, :normalize_time_s, :subauthority, :request_header, :request_id, :request
19
+ private :full_graph, :filtered_graph, :language, :id, :uri, :access_time_s, :normalize_time_s, :subauthority, :request_header, :request_id, :request
20
20
 
21
21
  delegate :term_subauthority?, :prefixes, :authority_name, to: :term_config
22
22
 
@@ -92,6 +92,8 @@ module Qa::Authorities
92
92
 
93
93
  def unpack_request_header(request_header)
94
94
  @request_header = request_header
95
+ @request = request_header.fetch(:request, nil)
96
+ @request_id = request_header.fetch(:request_id, 'UNASSIGNED')
95
97
  @subauthority = request_header.fetch(:subauthority, nil)
96
98
  @format = request_header.fetch(:format, 'json')
97
99
  @performance_data = request_header.fetch(:performance_data, false)
@@ -110,8 +112,8 @@ module Qa::Authorities
110
112
  predicate_map = preds_for_term
111
113
  ldpath_map = ldpaths_for_term
112
114
 
113
- raise Qa::InvalidConfiguration, "do not specify results using both predicates and ldpath in term configuration for linked data authority #{authority_name} (ldpath is preferred)" if predicate_map.present? && ldpath_map.present? # rubocop:disable Metrics/LineLength
114
- raise Qa::InvalidConfiguration, "must specify label_ldpath or label_predicate in term configuration for linked data authority #{authority_name} (label_ldpath is preferred)" unless ldpath_map.key?(:label) || predicate_map.key?(:label) # rubocop:disable Metrics/LineLength
115
+ raise Qa::InvalidConfiguration, "do not specify results using both predicates and ldpath in term configuration for linked data authority #{authority_name} (ldpath is preferred)" if predicate_map.present? && ldpath_map.present? # rubocop:disable Layout/LineLength
116
+ raise Qa::InvalidConfiguration, "must specify label_ldpath or label_predicate in term configuration for linked data authority #{authority_name} (label_ldpath is preferred)" unless ldpath_map.key?(:label) || predicate_map.key?(:label) # rubocop:disable Layout/LineLength
115
117
 
116
118
  if predicate_map.present?
117
119
  Qa.deprecation_warning(
@@ -15,8 +15,8 @@ module Qa::Authorities
15
15
  @search_config = search_config
16
16
  end
17
17
 
18
- attr_reader :search_config, :full_graph, :filtered_graph, :language, :access_time_s, :normalize_time_s, :subauthority, :request_header
19
- private :full_graph, :filtered_graph, :language, :access_time_s, :normalize_time_s, :subauthority, :request_header
18
+ attr_reader :search_config, :full_graph, :filtered_graph, :language, :access_time_s, :normalize_time_s, :subauthority, :request_header, :request_id, :request
19
+ private :full_graph, :filtered_graph, :language, :access_time_s, :normalize_time_s, :subauthority, :request_header, :request_id, :request
20
20
 
21
21
  delegate :subauthority?, :supports_sort?, :prefixes, :authority_name, to: :search_config
22
22
 
@@ -74,8 +74,8 @@ module Qa::Authorities
74
74
  predicate_map = preds_for_search
75
75
  ldpath_map = ldpaths_for_search
76
76
 
77
- raise Qa::InvalidConfiguration, "do not specify results using both predicates and ldpath in search configuration for linked data authority #{authority_name} (ldpath is preferred)" if predicate_map.present? && ldpath_map.present? # rubocop:disable Metrics/LineLength
78
- raise Qa::InvalidConfiguration, "must specify label_ldpath or label_predicate in search configuration for linked data authority #{authority_name} (label_ldpath is preferred)" unless ldpath_map.key?(:label) || predicate_map.key?(:label) # rubocop:disable Metrics/LineLength
77
+ raise Qa::InvalidConfiguration, "do not specify results using both predicates and ldpath in search configuration for linked data authority #{authority_name} (ldpath is preferred)" if predicate_map.present? && ldpath_map.present? # rubocop:disable Layout/LineLength
78
+ raise Qa::InvalidConfiguration, "must specify label_ldpath or label_predicate in search configuration for linked data authority #{authority_name} (label_ldpath is preferred)" unless ldpath_map.key?(:label) || predicate_map.key?(:label) # rubocop:disable Layout/LineLength
79
79
 
80
80
  if predicate_map.present?
81
81
  Qa.deprecation_warning(
@@ -91,6 +91,8 @@ module Qa::Authorities
91
91
 
92
92
  def unpack_request_header(request_header)
93
93
  @request_header = request_header
94
+ @request = request_header.fetch(:request, nil)
95
+ @request_id = request_header.fetch(:request_id, 'UNASSIGNED')
94
96
  @subauthority = request_header.fetch(:subauthority, nil)
95
97
  @context = request_header.fetch(:context, false)
96
98
  @performance_data = request_header.fetch(:performance_data, false)
@@ -26,7 +26,7 @@ module Qa::Authorities
26
26
  def build_query_url(q)
27
27
  escaped_query = ERB::Util.url_encode(q)
28
28
  authority_fragment = Loc.get_url_for_authority(subauthority) + ERB::Util.url_encode(subauthority)
29
- "http://id.loc.gov/search/?q=#{escaped_query}&q=#{authority_fragment}&format=json"
29
+ "https://id.loc.gov/search/?q=#{escaped_query}&q=#{authority_fragment}&format=json"
30
30
  end
31
31
 
32
32
  def find(id)
@@ -34,7 +34,7 @@ module Qa::Authorities
34
34
  end
35
35
 
36
36
  def find_url(id)
37
- "http://id.loc.gov/authorities/#{@subauthority}/#{id}.json"
37
+ "https://id.loc.gov/authorities/#{@subauthority}/#{id}.json"
38
38
  end
39
39
 
40
40
  private
@@ -54,5 +54,14 @@ module Qa
54
54
  @property_map_default_for_optional = false if @property_map_default_for_optional.nil?
55
55
  @property_map_default_for_optional
56
56
  end
57
+
58
+ # IP data including IP address, city, state, and country will be logged with each request.
59
+ # When false, IP data is logged
60
+ # When true, IP data will not be logged (default for backward compatibility)
61
+ attr_writer :suppress_ip_data_from_log
62
+ def suppress_ip_data_from_log
63
+ @suppress_ip_data_from_log = true if @suppress_ip_data_from_log.nil?
64
+ @suppress_ip_data_from_log
65
+ end
57
66
  end
58
67
  end
@@ -1,3 +1,3 @@
1
1
  module Qa
2
- VERSION = "5.2.0".freeze
2
+ VERSION = "5.5.1".freeze
3
3
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
  require 'json'
3
3
 
4
4
  describe Qa::LinkedDataTermsController, type: :controller do
5
+ let(:graph_load_failure) { /^\*\*\*\*\*\*\*\* RDF\:\:Graph\#load failure/ }
5
6
  before do
6
7
  @routes = Qa::Engine.routes
7
8
  end
@@ -140,6 +141,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
140
141
  .to_return(status: 500)
141
142
  end
142
143
  it 'returns 500' do
144
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
143
145
  expect(Rails.logger).to receive(:warn).with("Internal Server Error - Search query my_query unsuccessful for authority OCLC_FAST")
144
146
  get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
145
147
  expect(response.code).to eq('500')
@@ -154,6 +156,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
154
156
  end
155
157
  it 'returns 500' do
156
158
  msg = "RDF Format Error - Results from search query my_query for authority OCLC_FAST was not identified as a valid RDF format. You may need to include the linkeddata gem."
159
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
157
160
  expect(Rails.logger).to receive(:warn).with(msg)
158
161
  get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
159
162
  expect(response.code).to eq('500')
@@ -166,6 +169,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
166
169
  .to_return(status: 501)
167
170
  end
168
171
  it 'returns 500' do
172
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
169
173
  expect(Rails.logger).to receive(:warn).with("Internal Server Error - Search query my_query unsuccessful for authority OCLC_FAST")
170
174
  get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
171
175
  expect(response.code).to eq('500')
@@ -179,6 +183,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
179
183
  .to_return(status: 503)
180
184
  end
181
185
  it 'returns 503' do
186
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
182
187
  expect(Rails.logger).to receive(:warn).with("Service Unavailable - Search query my_query unsuccessful for authority OCLC_FAST")
183
188
  get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
184
189
  expect(response.code).to eq('503')
@@ -355,6 +360,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
355
360
  stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 500)
356
361
  end
357
362
  it 'returns 500' do
363
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
358
364
  expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term 530369 unsuccessful for authority OCLC_FAST")
359
365
  get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
360
366
  expect(response.code).to eq('500')
@@ -380,6 +386,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
380
386
  end
381
387
  it 'returns 500' do
382
388
  msg = "RDF Format Error - Results from fetch term 530369 for authority OCLC_FAST was not identified as a valid RDF format. You may need to include the linkeddata gem."
389
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
383
390
  expect(Rails.logger).to receive(:warn).with(msg)
384
391
  get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
385
392
  expect(response.code).to eq('500')
@@ -391,6 +398,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
391
398
  stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 501)
392
399
  end
393
400
  it 'returns 500' do
401
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
394
402
  expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term 530369 unsuccessful for authority OCLC_FAST")
395
403
  get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
396
404
  expect(response.code).to eq('500')
@@ -403,6 +411,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
403
411
  stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 503)
404
412
  end
405
413
  it 'returns 503' do
414
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
406
415
  expect(Rails.logger).to receive(:warn).with("Service Unavailable - Fetch term 530369 unsuccessful for authority OCLC_FAST")
407
416
  get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
408
417
  expect(response.code).to eq('503')
@@ -414,6 +423,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
414
423
  stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID').to_return(status: 404, body: '', headers: {})
415
424
  end
416
425
  it 'returns 404' do
426
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
417
427
  expect(Rails.logger).to receive(:warn).with('Term Not Found - Fetch term FAKE_ID unsuccessful for authority OCLC_FAST')
418
428
  get :show, params: { id: 'FAKE_ID', vocab: 'OCLC_FAST' }
419
429
  expect(response.code).to eq('404')
@@ -566,6 +576,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
566
576
  stub_request(:get, 'http://localhost/test_default/term?uri=http://id.worldcat.org/fast/530369').to_return(status: 500)
567
577
  end
568
578
  it 'returns 500' do
579
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
569
580
  expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term http://id.worldcat.org/fast/530369 unsuccessful for authority LOD_TERM_URI_PARAM_CONFIG")
570
581
  get :fetch, params: { vocab: 'LOD_TERM_URI_PARAM_CONFIG', uri: 'http://id.worldcat.org/fast/530369' }
571
582
  expect(response.code).to eq('500')
@@ -580,6 +591,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
580
591
  it 'returns 500' do
581
592
  msg = "RDF Format Error - Results from fetch term http://id.worldcat.org/fast/530369 for authority LOD_TERM_URI_PARAM_CONFIG was not identified as a valid RDF format. " \
582
593
  "You may need to include the linkeddata gem."
594
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
583
595
  expect(Rails.logger).to receive(:warn).with(msg)
584
596
  get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG' }
585
597
  expect(response.code).to eq('500')
@@ -591,6 +603,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
591
603
  stub_request(:get, 'http://localhost/test_default/term?uri=http://id.worldcat.org/fast/530369').to_return(status: 501)
592
604
  end
593
605
  it 'returns 500' do
606
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
594
607
  expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term http://id.worldcat.org/fast/530369 unsuccessful for authority LOD_TERM_URI_PARAM_CONFIG")
595
608
  get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG' }
596
609
  expect(response.code).to eq('500')
@@ -603,6 +616,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
603
616
  stub_request(:get, 'http://localhost/test_default/term?uri=http://id.worldcat.org/fast/530369').to_return(status: 503)
604
617
  end
605
618
  it 'returns 503' do
619
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
606
620
  expect(Rails.logger).to receive(:warn).with("Service Unavailable - Fetch term http://id.worldcat.org/fast/530369 unsuccessful for authority LOD_TERM_URI_PARAM_CONFIG")
607
621
  get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG' }
608
622
  expect(response.code).to eq('503')
@@ -614,6 +628,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
614
628
  stub_request(:get, 'http://localhost/test_default/term?uri=http://test.org/FAKE_ID').to_return(status: 404, body: '', headers: {})
615
629
  end
616
630
  it 'returns 404' do
631
+ expect(Rails.logger).to receive(:warn).with(graph_load_failure)
617
632
  expect(Rails.logger).to receive(:warn).with('Term Not Found - Fetch term http://test.org/FAKE_ID unsuccessful for authority LOD_TERM_URI_PARAM_CONFIG')
618
633
  get :fetch, params: { uri: 'http://test.org/FAKE_ID', vocab: 'LOD_TERM_URI_PARAM_CONFIG' }
619
634
  expect(response.code).to eq('404')
@@ -82,7 +82,7 @@ describe Qa::TermsController, type: :controller do
82
82
 
83
83
  context "loc" do
84
84
  before do
85
- stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
85
+ stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
86
86
  .with(headers: { 'Accept' => 'application/json' })
87
87
  .to_return(body: webmock_fixture("loc-names-response.txt"), status: 200)
88
88
  end
@@ -188,7 +188,7 @@ describe Qa::TermsController, type: :controller do
188
188
  describe "#show" do
189
189
  context "with supported authorities" do
190
190
  before do
191
- stub_request(:get, "http://id.loc.gov/authorities/subjects/sh85077565.json")
191
+ stub_request(:get, "https://id.loc.gov/authorities/subjects/sh85077565.json")
192
192
  .with(headers: { 'Accept' => 'application/json' })
193
193
  .to_return(status: 200, body: webmock_fixture("loc-names-response.txt"), headers: {})
194
194
  end
@@ -7,6 +7,34 @@ describe Qa::Authorities::Geonames do
7
7
 
8
8
  let(:authority) { described_class.new }
9
9
 
10
+ describe ".query_url_host" do
11
+ subject { described_class.query_url_host }
12
+ it { is_expected.to eq "http://api.geonames.org" }
13
+ it "can be overridden" do
14
+ begin
15
+ before_change = described_class.query_url_host
16
+ described_class.query_url_host = "http://myhost.com"
17
+ expect(described_class.query_url_host).to eq("http://myhost.com")
18
+ ensure
19
+ described_class.query_url_host = before_change
20
+ end
21
+ end
22
+ end
23
+
24
+ describe ".find_url_host" do
25
+ subject { described_class.find_url_host }
26
+ it { is_expected.to eq "http://www.geonames.org" }
27
+ it "can be overridden" do
28
+ begin
29
+ before_change = described_class.find_url_host
30
+ described_class.find_url_host = "http://myhost.com"
31
+ expect(described_class.find_url_host).to eq("http://myhost.com")
32
+ ensure
33
+ described_class.find_url_host = before_change
34
+ end
35
+ end
36
+ end
37
+
10
38
  describe "#build_query_url" do
11
39
  subject { authority.build_query_url("foo") }
12
40
  it { is_expected.to eq 'http://api.geonames.org/searchJSON?q=foo&username=dummy&maxRows=10' }
@@ -28,9 +56,9 @@ describe Qa::Authorities::Geonames do
28
56
 
29
57
  context "with default label" do
30
58
  it "has id and label keys" do
31
- expect(subject.first).to eq("id" => 'http://sws.geonames.org/2088122/',
59
+ expect(subject.first).to eq("id" => 'https://sws.geonames.org/2088122/',
32
60
  "label" => "Port Moresby, National Capital, Papua New Guinea")
33
- expect(subject.last).to eq("id" => 'http://sws.geonames.org/377039/',
61
+ expect(subject.last).to eq("id" => 'https://sws.geonames.org/377039/',
34
62
  "label" => "Port Sudan, Red Sea, Sudan")
35
63
  expect(subject.size).to eq(10)
36
64
  end
@@ -77,7 +77,7 @@ describe Qa::Authorities::Getty::AAT do
77
77
  subject { authority.request_options }
78
78
  it { is_expected.to eq(accept: "application/sparql-results+json") }
79
79
  end
80
- # rubocop:disable Metrics/LineLength
80
+ # rubocop:disable Layout/LineLength
81
81
  describe "#sparql" do
82
82
  context "using a single subject term" do
83
83
  subject { authority.sparql('search_term') }
@@ -92,5 +92,5 @@ describe Qa::Authorities::Getty::AAT do
92
92
  }
93
93
  end
94
94
  end
95
- # rubocop:enable Metrics/LineLength
95
+ # rubocop:enable Layout/LineLength
96
96
  end
@@ -77,7 +77,7 @@ describe Qa::Authorities::Getty::TGN do
77
77
  subject { authority.request_options }
78
78
  it { is_expected.to eq(accept: "application/sparql-results+json") }
79
79
  end
80
- # rubocop:disable Metrics/LineLength
80
+ # rubocop:disable Layout/LineLength
81
81
  describe "#sparql" do
82
82
  context "using a single subject term" do
83
83
  subject { authority.sparql('search_term') }
@@ -92,5 +92,5 @@ describe Qa::Authorities::Getty::TGN do
92
92
  }
93
93
  end
94
94
  end
95
- # rubocop:enable Metrics/LineLength
95
+ # rubocop:enable Layout/LineLength
96
96
  end
@@ -28,14 +28,14 @@ describe Qa::Authorities::Loc do
28
28
  end
29
29
 
30
30
  context "for searching" do
31
- let(:url) { 'http://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
31
+ let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
32
32
  it "returns a url" do
33
33
  expect(authority.build_query_url("foo")).to eq(url)
34
34
  end
35
35
  end
36
36
 
37
37
  context "for returning single terms" do
38
- let(:url) { "http://id.loc.gov/authorities/subjects/sh2002003586.json" }
38
+ let(:url) { "https://id.loc.gov/authorities/subjects/sh2002003586.json" }
39
39
  it "returns a url with an authority and id" do
40
40
  expect(authority.find_url("sh2002003586")).to eq(url)
41
41
  end
@@ -49,15 +49,15 @@ describe Qa::Authorities::Loc do
49
49
  end
50
50
 
51
51
  before do
52
- stub_request(:get, "http://id.loc.gov/search/?format=json&q=cs:http://id.loc.gov/authorities/subjects")
52
+ stub_request(:get, "https://id.loc.gov/search/?format=json&q=cs:http://id.loc.gov/authorities/subjects")
53
53
  .with(headers: { 'Accept' => 'application/json' })
54
54
  .to_return(status: 200, body: "")
55
55
  end
56
56
 
57
57
  context "with flat params encoded" do
58
- let(:url) { 'http://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
58
+ let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
59
59
  it "returns a response" do
60
- flat_params_url = "http://id.loc.gov/search/?format=json&q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects"
60
+ flat_params_url = "https://id.loc.gov/search/?format=json&q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects"
61
61
  expect(subject.env.url.to_s).to eq(flat_params_url)
62
62
  end
63
63
  end
@@ -66,7 +66,7 @@ describe Qa::Authorities::Loc do
66
66
  describe "#search" do
67
67
  context "any LOC authorities" do
68
68
  let :authority do
69
- stub_request(:get, "http://id.loc.gov/search/?format=json&q=s&q=cs:http://id.loc.gov/vocabulary/geographicAreas")
69
+ stub_request(:get, "https://id.loc.gov/search/?format=json&q=s&q=cs:http://id.loc.gov/vocabulary/geographicAreas")
70
70
  .with(headers: { 'Accept' => 'application/json' })
71
71
  .to_return(body: webmock_fixture("loc-response.txt"), status: 200)
72
72
  described_class.subauthority_for("geographicAreas")
@@ -95,7 +95,7 @@ describe Qa::Authorities::Loc do
95
95
 
96
96
  context "subject terms" do
97
97
  let :results do
98
- stub_request(:get, "http://id.loc.gov/search/?format=json&q=History--&q=cs:http://id.loc.gov/authorities/subjects")
98
+ stub_request(:get, "https://id.loc.gov/search/?format=json&q=History--&q=cs:http://id.loc.gov/authorities/subjects")
99
99
  .with(headers: { 'Accept' => 'application/json' })
100
100
  .to_return(body: webmock_fixture("loc-subjects-response.txt"), status: 200)
101
101
  described_class.subauthority_for("subjects").search("History--")
@@ -111,7 +111,7 @@ describe Qa::Authorities::Loc do
111
111
 
112
112
  context "name terms" do
113
113
  let :results do
114
- stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
114
+ stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
115
115
  .with(headers: { 'Accept' => 'application/json' })
116
116
  .to_return(body: webmock_fixture("loc-names-response.txt"), status: 200)
117
117
  described_class.subauthority_for("names").search("Berry")
@@ -125,7 +125,7 @@ describe Qa::Authorities::Loc do
125
125
  describe "#find" do
126
126
  context "using a subject id" do
127
127
  let :results do
128
- stub_request(:get, "http://id.loc.gov/authorities/subjects/sh2002003586.json")
128
+ stub_request(:get, "https://id.loc.gov/authorities/subjects/sh2002003586.json")
129
129
  .with(headers: { 'Accept' => 'application/json' })
130
130
  .to_return(status: 200, body: webmock_fixture("loc-subject-find-response.txt"), headers: {})
131
131
  described_class.subauthority_for("subjects").find("sh2002003586")
@@ -47,7 +47,7 @@ EOS
47
47
  expect(records[1]).to eq({})
48
48
  end
49
49
 
50
- # rubocop:disable Metrics/LineLength
50
+ # rubocop:disable Layout/LineLength
51
51
  it 'parses a sample mesh file' do
52
52
  mesh = described_class.new(webmock_fixture('mesh.txt'))
53
53
  records = mesh.all_records
@@ -117,5 +117,5 @@ EOS
117
117
  "DX" => ["19840101"],
118
118
  "UI" => ["D000001"])
119
119
  end
120
- # rubocop:enable Metrics/LineLength
120
+ # rubocop:enable Layout/LineLength
121
121
  end
@@ -2,8 +2,44 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Qa::LinkedData::RequestHeaderService do
4
4
  let(:request) { double }
5
+ let(:request_id) { 'anID' }
6
+ let(:some_params) { double }
7
+ let(:location) { double }
8
+ let(:fake_ip) { '111.22.33.4444' }
9
+ let(:city) { 'Ithaca' }
10
+ let(:state) { 'New York' }
11
+ let(:country) { 'US' }
12
+ before do
13
+ allow(request).to receive(:request_id).and_return(request_id)
14
+ allow(request).to receive_message_chain(:path_parameters, :[]).with(:action).and_return('search') # rubocop:disable RSpec/MessageChain
15
+ allow(request).to receive(:location).and_return(location)
16
+ allow(request).to receive(:ip).and_return(fake_ip)
17
+ allow(location).to receive(:city).and_return(city)
18
+ allow(location).to receive(:state).and_return(state)
19
+ allow(location).to receive(:country).and_return(country)
20
+ end
21
+
22
+ describe '#initialize' do
23
+ context 'when Qa.config.suppress_ip_data_from_log is true' do
24
+ before { allow(Qa).to receive_message_chain(:config, :suppress_ip_data_from_log).and_return(true) } # rubocop:disable RSpec/MessageChain
25
+ it 'does not include IP info in log message' do
26
+ expect(Rails.logger).to receive(:info).with("******** SEARCH")
27
+ described_class.new(request: request, params: some_params)
28
+ end
29
+ end
30
+
31
+ context 'when Qa.config.suppress_ip_data_from_log is false' do
32
+ before { allow(Qa).to receive_message_chain(:config, :suppress_ip_data_from_log).and_return(false) } # rubocop:disable RSpec/MessageChain
33
+ it 'does include IP info in log message' do
34
+ expect(Rails.logger).to receive(:info).with("******** SEARCH from IP #{fake_ip} in {city: #{city}, state: #{state}, country: #{country}}")
35
+ described_class.new(request: request, params: some_params)
36
+ end
37
+ end
38
+ end
5
39
 
6
40
  describe '#search_header' do
41
+ let(:request_id) { 's1' }
42
+
7
43
  context 'when optional params are defined' do
8
44
  let(:search_params) do
9
45
  {
@@ -20,6 +56,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
20
56
  it 'uses passed in params' do
21
57
  expected_results =
22
58
  {
59
+ request: request,
60
+ request_id: request_id,
23
61
  context: true,
24
62
  performance_data: true,
25
63
  replacements: { 'maxRecords' => '4' },
@@ -37,6 +75,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
37
75
  it 'returns defaults' do
38
76
  expected_results =
39
77
  {
78
+ request: request,
79
+ request_id: request_id,
40
80
  context: false,
41
81
  performance_data: false,
42
82
  replacements: {},
@@ -53,6 +93,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
53
93
  it 'returns defaults with language set to request language' do
54
94
  expected_results =
55
95
  {
96
+ request: request,
97
+ request_id: request_id,
56
98
  context: false,
57
99
  performance_data: false,
58
100
  replacements: {},
@@ -67,6 +109,7 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
67
109
  end
68
110
 
69
111
  describe '#fetch_header' do
112
+ let(:request_id) { 'f1' }
70
113
  context 'when optional params are defined' do
71
114
  let(:fetch_params) do
72
115
  {
@@ -84,6 +127,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
84
127
  it 'uses passed in params' do
85
128
  expected_results =
86
129
  {
130
+ request: request,
131
+ request_id: request_id,
87
132
  format: 'n3',
88
133
  performance_data: true,
89
134
  replacements: { 'extra' => 'data', 'even' => 'more data' },
@@ -101,6 +146,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
101
146
  it 'returns defaults' do
102
147
  expected_results =
103
148
  {
149
+ request: request,
150
+ request_id: request_id,
104
151
  format: 'json',
105
152
  performance_data: false,
106
153
  replacements: {},
@@ -117,6 +164,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
117
164
  it 'returns defaults with language set to request language' do
118
165
  expected_results =
119
166
  {
167
+ request: request,
168
+ request_id: request_id,
120
169
  format: 'json',
121
170
  performance_data: false,
122
171
  replacements: {},
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.2.0
4
+ version: 5.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Anderson
@@ -13,10 +13,10 @@ authors:
13
13
  - Mike Stroming
14
14
  - Adam Wead
15
15
  - E. Lynette Rayle
16
- autorequire:
16
+ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2019-12-03 00:00:00.000000000 Z
19
+ date: 2020-08-14 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activerecord-import
@@ -60,6 +60,20 @@ dependencies:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: geocoder
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
63
77
  - !ruby/object:Gem::Dependency
64
78
  name: ldpath
65
79
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +142,40 @@ dependencies:
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: 1.0.0
145
+ version: 3.0.0
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: 1.0.0
152
+ version: 3.0.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: rails
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "!="
158
+ - !ruby/object:Gem::Version
159
+ version: 5.2.0
160
+ - - "!="
161
+ - !ruby/object:Gem::Version
162
+ version: 5.2.1
163
+ - - "!="
164
+ - !ruby/object:Gem::Version
165
+ version: 5.2.2
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "!="
171
+ - !ruby/object:Gem::Version
172
+ version: 5.2.0
173
+ - - "!="
174
+ - !ruby/object:Gem::Version
175
+ version: 5.2.1
176
+ - - "!="
177
+ - !ruby/object:Gem::Version
178
+ version: 5.2.2
139
179
  - !ruby/object:Gem::Dependency
140
180
  name: byebug
141
181
  requirement: !ruby/object:Gem::Requirement
@@ -577,7 +617,7 @@ homepage: https://github.com/projecthydra/questioning_authority
577
617
  licenses:
578
618
  - APACHE-2
579
619
  metadata: {}
580
- post_install_message:
620
+ post_install_message:
581
621
  rdoc_options: []
582
622
  require_paths:
583
623
  - lib
@@ -592,9 +632,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
592
632
  - !ruby/object:Gem::Version
593
633
  version: '0'
594
634
  requirements: []
595
- rubyforge_project:
596
- rubygems_version: 2.6.14
597
- signing_key:
635
+ rubygems_version: 3.0.8
636
+ signing_key:
598
637
  specification_version: 4
599
638
  summary: You should question your authorities.
600
639
  test_files: