gds-api-adapters 24.7.0 → 24.8.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
  SHA1:
3
- metadata.gz: 4ef68ae8d9f4be614277bc8a7acb8027f1c07545
4
- data.tar.gz: 932afdaf75d50446a826c4f3792457977eebe3c8
3
+ metadata.gz: a073f86ca24d44d7389466bda9ee3c259029df9d
4
+ data.tar.gz: 609242e328b2e2fb8ec3fbd8c01ea9a399a8aaa8
5
5
  SHA512:
6
- metadata.gz: c09577ea35742649e8614f0c0a274e5604fd416c031f47b1d22853a21724cc8d2826aeafd571f125f690be6b7ba794e9eb8451228c9ec3356f8160b1efe71e31
7
- data.tar.gz: 06d0fa4e1ec14347dbb178d57aa011a5b75c188255f2e1cee60ec718aaa614820011c0a2da8a2c1836f1c91e62fb11792c98646e37c9b2dfa7a8fe60cdd17c04
6
+ metadata.gz: d2229ed8f4e1a8ab1a66b8ba34e7ce124b2d3e6ec9154749637b712957c01500a395ac59c8192761bbd441164e2745bb9a281145334ef724f6046efc5c6517c2
7
+ data.tar.gz: 07af7d58f6d87bad27265de4402be76aab7e208e7c5b8f07556254040e2b7dc32c10194bdfca70fc606c1c97a05465a44dad8e1436b5add0cc213b0e89488acd
@@ -90,6 +90,39 @@ module GdsApi
90
90
  stub_request(:any, /#{PUBLISHING_API_ENDPOINT}\/.*/).to_return(:status => 503)
91
91
  end
92
92
 
93
+ def stub_default_publishing_api_path_reservation
94
+ stub_request(:put, %r[\A#{PUBLISHING_API_ENDPOINT}/paths/]).to_return { |request|
95
+ base_path = request.uri.path.sub(%r{\A/paths/}, "")
96
+ { :status => 200, :headers => {:content_type => "application/json"},
97
+ :body => publishing_api_path_data_for(base_path).to_json }
98
+ }
99
+ end
100
+
101
+ def publishing_api_has_path_reservation_for(path, publishing_app)
102
+ data = publishing_api_path_data_for(path, "publishing_app" => publishing_app)
103
+ error_data = data.merge({
104
+ "errors" => {"path" => ["is already reserved by the #{publishing_app} application"]},
105
+ })
106
+
107
+ stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}").
108
+ to_return(:status => 422, :body => error_data.to_json,
109
+ :headers => {:content_type => "application/json"})
110
+
111
+ stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}").
112
+ with(:body => {"publishing_app" => publishing_app}).
113
+ to_return(:status => 200,
114
+ :headers => {:content_type => "application/json"},
115
+ :body => data.to_json)
116
+ end
117
+
118
+ def publishing_api_returns_path_reservation_validation_error_for(path, error_details = nil)
119
+ error_details ||= {"base" => ["computer says no"]}
120
+ error_data = publishing_api_path_data_for(path).merge("errors" => error_details)
121
+
122
+ stub_request(:put, "#{PUBLISHING_API_ENDPOINT}/paths#{path}").
123
+ to_return(:status => 422, :body => error_data.to_json, :headers => {:content_type => "application/json"})
124
+ end
125
+
93
126
  private
94
127
  def values_match_recursively(expected_value, actual_value)
95
128
  case expected_value
@@ -117,6 +150,16 @@ module GdsApi
117
150
  def intent_for_publishing_api(base_path, publishing_app="publisher")
118
151
  intent_for_base_path(base_path).merge("publishing_app" => publishing_app)
119
152
  end
153
+
154
+ def publishing_api_path_data_for(path, override_attributes = {})
155
+ now = Time.zone.now.utc.iso8601
156
+ {
157
+ "path" => path,
158
+ "publishing_app" => "foo-publisher",
159
+ "created_at" => now,
160
+ "updated_at" => now,
161
+ }.merge(override_attributes)
162
+ end
120
163
  end
121
164
  end
122
165
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '24.7.0'
2
+ VERSION = '24.8.0'
3
3
  end
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: 24.7.0
4
+ version: 24.8.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: 2015-10-26 00:00:00.000000000 Z
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek