gds-api-adapters 35.0.1 → 36.0.0

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
2
  SHA1:
3
- metadata.gz: e333779f06ac4e6cd7cdc357ecd49415ff7504ff
4
- data.tar.gz: 6f5769410683e7342de9505201bf22a1c02732bf
3
+ metadata.gz: 0ad34f7d7d009484cc99f916e4963eb89830733a
4
+ data.tar.gz: 19d1e39bfef4736154f26c6f225362e1ca88b42b
5
5
  SHA512:
6
- metadata.gz: 4e75bf5a23893d51a70361a55f1d2b805658678b569f5e4d2f8bd2cdef3b339f5142d3962ee612dac18841cf592685b5969ed7ad2c27b0dade2800fe1fd9c2df
7
- data.tar.gz: db78f0b50042f099c4fc43a2cd71c0286b69bccea372e7add1727cb55da56aa29a59183e9401c8496d6ba4990f51a46eb315891bb63459dada26260969a20f6f
6
+ metadata.gz: b56ad19c715ffeef14cd546a7dae1b0716e02d81c3704a7c8672d5d59c46c1e4b09680ff6cf68c46a2161f266db47716e1daf4966ea85ff0fe5dce7d302460f3
7
+ data.tar.gz: 4a9f7b802aa84a1a9e582a473f7d61774be034106c6083dce94914ac8061d60963c8c07dcb029fe276548647544021bdcd6d66b27a9208befdc8598ddad12ef1
@@ -156,9 +156,27 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
156
156
  post_json!(discard_url(content_id), params)
157
157
  end
158
158
 
159
- # FIXME: Add documentation
159
+ # Get the link set for the given content_id.
160
+ #
161
+ # Given a Content ID, it fetchs the existing link set and their version.
162
+ #
163
+ # @param content_id [String]
164
+ #
165
+ # @return [GdsApi::Response] A response containing `links` and `version`.
166
+ #
167
+ # @example
168
+ #
169
+ # publishing_api.get_links("a-content-id")
170
+ # # => {
171
+ # "content_id" => "a-content-id",
172
+ # "links" => [
173
+ # "organisation" => "organisation-content-id",
174
+ # "document_collection" => "document-collection-content-id"
175
+ # ],
176
+ # "version" => 17
177
+ # }
160
178
  #
161
- # @see https://github.com/alphagov/publishing-api/blob/master/doc/publishing-api-syntactic-usage.md#get-v2linkscontent_id
179
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2linkscontent_id
162
180
  def get_links(content_id)
163
181
  get_json(links_url(content_id))
164
182
  end
@@ -6,20 +6,9 @@ module GdsApi
6
6
 
7
7
  # Perform a search.
8
8
  #
9
- # @deprecated Alias for `#search`.
10
9
  # @param query [Hash] A valid search query. See Rummager documentation for options.
11
10
  #
12
- # @see https://github.com/alphagov/rummager/blob/master/docs/unified-search-api.md
13
- def unified_search(args)
14
- request_url = "#{base_url}/unified_search.json?#{Rack::Utils.build_nested_query(args)}"
15
- get_json!(request_url)
16
- end
17
-
18
- # Perform a search.
19
- #
20
- # @param query [Hash] A valid search query. See Rummager documentation for options.
21
- #
22
- # @see https://github.com/alphagov/rummager/blob/master/docs/unified-search-api.md
11
+ # @see https://github.com/alphagov/rummager/blob/master/docs/search-api.md
23
12
  def search(args)
24
13
  request_url = "#{base_url}/search.json?#{Rack::Utils.build_nested_query(args)}"
25
14
  get_json!(request_url)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '35.0.1'
2
+ VERSION = '36.0.0'
3
3
  end
@@ -4,7 +4,6 @@ require "gds_api/rummager"
4
4
  describe GdsApi::Rummager do
5
5
  before(:each) do
6
6
  stub_request(:get, /example.com\/advanced_search/).to_return(body: "[]")
7
- stub_request(:get, /example.com\/unified_search/).to_return(body: "[]")
8
7
  stub_request(:get, /example.com\/search/).to_return(body: "[]")
9
8
  end
10
9
 
@@ -65,74 +64,6 @@ describe GdsApi::Rummager do
65
64
  assert_requested :get, /order\[public_timestamp\]=desc/
66
65
  end
67
66
 
68
- # tests for unified search
69
-
70
- it "#unified_search should raise an exception if the service at the search URI returns a 500" do
71
- stub_request(:get, /example.com\/unified_search.json/).to_return(status: [500, "Internal Server Error"])
72
- assert_raises(GdsApi::HTTPServerError) do
73
- GdsApi::Rummager.new("http://example.com").unified_search(q: "query")
74
- end
75
- end
76
-
77
- it "#unified_search should raise an exception if the service at the search URI returns a 404" do
78
- stub_request(:get, /example.com\/unified_search/).to_return(status: [404, "Not Found"])
79
- assert_raises(GdsApi::HTTPNotFound) do
80
- GdsApi::Rummager.new("http://example.com").unified_search(q: "query")
81
- end
82
- end
83
-
84
- it "#unified_search should raise an exception if the service at the unified search URI returns a 400" do
85
- stub_request(:get, /example.com\/unified_search/).to_return(
86
- status: [400, "Bad Request"],
87
- body: %q("error":"Filtering by \"coffee\" is not allowed"),
88
- )
89
- assert_raises(GdsApi::HTTPClientError) do
90
- GdsApi::Rummager.new("http://example.com").unified_search(q: "query", filter_coffee: "tea")
91
- end
92
- end
93
-
94
- it "#unified_search should raise an exception if the service at the unified search URI returns a 422" do
95
- stub_request(:get, /example.com\/unified_search/).to_return(
96
- status: [422, "Bad Request"],
97
- body: %q("error":"Filtering by \"coffee\" is not allowed"),
98
- )
99
- assert_raises(GdsApi::HTTPClientError) do
100
- GdsApi::Rummager.new("http://example.com").unified_search(q: "query", filter_coffee: "tea")
101
- end
102
- end
103
-
104
- it "#unified_search should raise an exception if the service at the search URI times out" do
105
- stub_request(:get, /example.com\/unified_search/).to_timeout
106
- assert_raises(GdsApi::TimedOutException) do
107
- GdsApi::Rummager.new("http://example.com").unified_search(q: "query")
108
- end
109
- end
110
-
111
- it "#unified_search should return the search deserialized from json" do
112
- search_results = [{"title" => "document-title"}]
113
- stub_request(:get, /example.com\/unified_search/).to_return(body: search_results.to_json)
114
- results = GdsApi::Rummager.new("http://example.com").unified_search(q: "query")
115
- assert_equal search_results, results.to_hash
116
- end
117
-
118
- it "#unified_search should request the search results in JSON format" do
119
- GdsApi::Rummager.new("http://example.com").unified_search(q: "query")
120
-
121
- assert_requested :get, /.*/, headers: {"Accept" => "application/json"}
122
- end
123
-
124
- it "#unified_search should issue a request for all the params supplied" do
125
- GdsApi::Rummager.new("http://example.com").unified_search(
126
- q: "query & stuff",
127
- filter_topics: ["1", "2"],
128
- order: "-public_timestamp",
129
- )
130
-
131
- assert_requested :get, /q=query%20%26%20stuff/
132
- assert_requested :get, /filter_topics\[\]=1&filter_topics\[\]=2/
133
- assert_requested :get, /order=-public_timestamp/
134
- end
135
-
136
67
  # tests for search
137
68
 
138
69
  it "#search should raise an exception if the service at the search URI returns a 500" do
@@ -149,7 +80,7 @@ describe GdsApi::Rummager do
149
80
  end
150
81
  end
151
82
 
152
- it "#search should raise an exception if the service at the unified search URI returns a 400" do
83
+ it "#search should raise an exception if the service at the search URI returns a 400" do
153
84
  stub_request(:get, /example.com\/search/).to_return(
154
85
  status: [400, "Bad Request"],
155
86
  body: %q("error":"Filtering by \"coffee\" is not allowed"),
@@ -159,7 +90,7 @@ describe GdsApi::Rummager do
159
90
  end
160
91
  end
161
92
 
162
- it "#search should raise an exception if the service at the unified search URI returns a 422" do
93
+ it "#search should raise an exception if the service at the search URI returns a 422" do
163
94
  stub_request(:get, /example.com\/search/).to_return(
164
95
  status: [422, "Bad Request"],
165
96
  body: %q("error":"Filtering by \"coffee\" is not allowed"),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 35.0.1
4
+ version: 36.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-06 00:00:00.000000000 Z
11
+ date: 2016-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek