govuk_content_item_loader 1.2.1 → 2.0.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 +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/CHANGELOG.md +10 -1
- data/govuk_content_item_loader.gemspec +1 -0
- data/lib/govuk_content_item_loader/test_helpers.rb +16 -48
- data/lib/govuk_content_item_loader/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a00bbc8f14d56f67f1ef763163819d0ca8aa5cadc19657e99ba4138e30d5613c
|
|
4
|
+
data.tar.gz: 7ad600627ef7be66f62cf980d8e9417b044ee39367792d89dac743382c9724cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46c9ebf6a037ca8087c093f2f69f5399dc22e1273468ec0b70a833d58e7762e69332f42ad75e1da12082461eb0c94ced34b311da7166ddbf5dd85502ab971e07
|
|
7
|
+
data.tar.gz: fbbe5c0102e6e13d14a3a5685cee82973afc6c2e5cf31d565b9f96992a03819be1647571259e953c4e88d410dc832df8e05e79da5c32463696d82ea40df79182
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -38,7 +38,7 @@ jobs:
|
|
|
38
38
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
39
39
|
with:
|
|
40
40
|
ref: ${{ inputs.ref || github.ref }}
|
|
41
|
-
- uses: ruby/setup-ruby@
|
|
41
|
+
- uses: ruby/setup-ruby@3ff19f5e2baf30647122352b96108b1fbe250c64 # v1.299.0
|
|
42
42
|
with:
|
|
43
43
|
ruby-version: ${{ matrix.ruby }}
|
|
44
44
|
bundler-cache: true
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
* BREAKING: replaces `stub_conditional_loader_returns_content_item` test helper with `stub_conditional_loader_returns_content_item_for_path` to match requests to a specific request path, for testing in frontend applications.
|
|
6
|
+
* BREAKING: replaces `stub_conditional_loader_does_not_return_content_item` test helper with `stub_conditional_loader_does_not_return_content_item_for_path` to match requests to a specific request path, for testing in frontend applications.
|
|
7
|
+
|
|
8
|
+
## 1.2.2
|
|
9
|
+
|
|
10
|
+
* Update dependencies
|
|
11
|
+
|
|
3
12
|
## 1.2.1
|
|
4
13
|
|
|
5
|
-
* Stub the requests in test helpers and add Plek as dependency
|
|
14
|
+
* Stub the requests in test helpers and add Plek as dependency
|
|
6
15
|
|
|
7
16
|
## 1.2.0
|
|
8
17
|
|
|
@@ -1,58 +1,26 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "gds_api/test_helpers/content_item_helpers"
|
|
2
|
+
require "gds_api/test_helpers/content_store"
|
|
3
|
+
require "gds_api/test_helpers/publishing_api"
|
|
2
4
|
|
|
3
5
|
module GovukConditionalContentItemLoaderTestHelpers
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
include GdsApi::TestHelpers::ContentStore
|
|
7
|
+
include GdsApi::TestHelpers::PublishingApi
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# :max_age will set the max-age of the Cache-Control header in the response. Defaults to 900
|
|
11
|
-
# :private if true, the Cache-Control header will include the "private" directive. By default it
|
|
12
|
-
# will include "public"
|
|
13
|
-
def stub_conditional_loader_returns_content_item(body, options = {})
|
|
14
|
-
body = body.is_a?(String) ? body : body.to_json
|
|
15
|
-
max_age = options.fetch(:max_age, 900)
|
|
16
|
-
visibility = options[:private] ? "private" : "public"
|
|
17
|
-
|
|
18
|
-
[CONTENT_STORE_ENDPOINT, PUBLISHING_API_ENDPOINT].each do |endpoint|
|
|
19
|
-
stub_request(:get, %r{#{Regexp.escape(endpoint)}}).to_return(
|
|
20
|
-
status: 200,
|
|
21
|
-
body: body,
|
|
22
|
-
headers: {
|
|
23
|
-
"Cache-Control" => "#{visibility}, max-age=#{max_age}",
|
|
24
|
-
"Date" => Time.now.httpdate,
|
|
25
|
-
},
|
|
26
|
-
)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
loader = instance_double(GovukConditionalContentItemLoader, load: JSON.parse(body))
|
|
30
|
-
|
|
31
|
-
allow(GovukConditionalContentItemLoader).to receive(:new).with(request: anything)
|
|
32
|
-
.and_return(loader)
|
|
9
|
+
def stub_conditional_loader_returns_content_item_for_path(base_path, body = content_item_for_base_path(base_path), options = {})
|
|
10
|
+
stub_content_store_has_item(base_path, body, options)
|
|
11
|
+
stub_publishing_api_graphql_has_item(base_path, body, options)
|
|
33
12
|
end
|
|
34
13
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
# :message the error message. Defaults to "Not Found"
|
|
40
|
-
# :error_details optional additional error details to attach to the exception
|
|
41
|
-
# :http_body optional raw response body to attach to the exception
|
|
42
|
-
def stub_conditional_loader_does_not_return_content_item(options = {})
|
|
43
|
-
status = options.fetch(:status, 404)
|
|
44
|
-
message = options.fetch(:message, "Not Found")
|
|
45
|
-
error_details = options[:error_details]
|
|
46
|
-
http_body = options[:http_body]
|
|
47
|
-
|
|
48
|
-
error = GdsApi::HTTPErrorResponse.new(status, message, error_details, http_body)
|
|
14
|
+
def stub_conditional_loader_does_not_return_content_item_for_path(base_path, options = {})
|
|
15
|
+
stub_content_store_does_not_have_item(base_path, options)
|
|
16
|
+
stub_publishing_api_graphql_does_not_have_item(base_path)
|
|
17
|
+
end
|
|
49
18
|
|
|
50
|
-
|
|
19
|
+
private
|
|
51
20
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
allow(loader).to receive(:load).and_raise(error)
|
|
21
|
+
def content_item_for_base_path(base_path)
|
|
22
|
+
include GdsApi::TestHelpers::ContentItemHelpers
|
|
55
23
|
|
|
56
|
-
|
|
24
|
+
super.merge("base_path" => base_path)
|
|
57
25
|
end
|
|
58
26
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: govuk_content_item_loader
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GOV.UK Dev
|
|
@@ -149,6 +149,20 @@ dependencies:
|
|
|
149
149
|
- - ">="
|
|
150
150
|
- !ruby/object:Gem::Version
|
|
151
151
|
version: '0'
|
|
152
|
+
- !ruby/object:Gem::Dependency
|
|
153
|
+
name: webmock
|
|
154
|
+
requirement: !ruby/object:Gem::Requirement
|
|
155
|
+
requirements:
|
|
156
|
+
- - ">="
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: '0'
|
|
159
|
+
type: :development
|
|
160
|
+
prerelease: false
|
|
161
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
162
|
+
requirements:
|
|
163
|
+
- - ">="
|
|
164
|
+
- !ruby/object:Gem::Version
|
|
165
|
+
version: '0'
|
|
152
166
|
email:
|
|
153
167
|
- govuk-dev@digital.cabinet-office.gov.uk
|
|
154
168
|
executables: []
|
|
@@ -196,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
196
210
|
- !ruby/object:Gem::Version
|
|
197
211
|
version: '0'
|
|
198
212
|
requirements: []
|
|
199
|
-
rubygems_version: 4.0.
|
|
213
|
+
rubygems_version: 4.0.9
|
|
200
214
|
specification_version: 4
|
|
201
215
|
summary: Provides a standardised content item loader for GOV.UK frontend apps with
|
|
202
216
|
configurable GraphQL traffic routing and automatic fallback to the Content Store
|