gds-api-adapters 26.1.0 → 26.2.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/lib/gds_api/publishing_api_v2.rb +11 -4
- data/lib/gds_api/test_helpers/publishing_api_v2.rb +5 -0
- data/lib/gds_api/version.rb +1 -1
- data/test/publishing_api_v2_test.rb +27 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43033670f2451e74e4ecc8048760dfd834031618
|
4
|
+
data.tar.gz: 628a90354b539241f4b73e36ebc8964c37fa3c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a435d8ed882a8a758f552b527aad505eee5ab83717e5e665c9192ed9cce1f0def28ac39b9ec60ce9b98a874860aaa07b4fd4ec0b77b197556204447553aef38
|
7
|
+
data.tar.gz: 9bb98c53792e857a1a3fa595ce4bcfa42201813bf7180ac06c1521d018ae711333cda765511a4b287558305435d8bafe13052f3010dd97b9ea56644503b0bbd9
|
@@ -27,6 +27,17 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
|
|
27
27
|
post_json!(publish_url(content_id), params)
|
28
28
|
end
|
29
29
|
|
30
|
+
def discard_draft(content_id, options = {})
|
31
|
+
optional_keys = [
|
32
|
+
:locale,
|
33
|
+
:previous_version,
|
34
|
+
]
|
35
|
+
|
36
|
+
params = merge_optional_keys({}, options, optional_keys)
|
37
|
+
|
38
|
+
post_json!(discard_url(content_id), params)
|
39
|
+
end
|
40
|
+
|
30
41
|
def get_links(content_id)
|
31
42
|
get_json(links_url(content_id))
|
32
43
|
end
|
@@ -46,10 +57,6 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
|
|
46
57
|
get_json("#{endpoint}/v2/content#{query}")
|
47
58
|
end
|
48
59
|
|
49
|
-
def discard_draft(content_id)
|
50
|
-
post_json!(discard_url(content_id), {})
|
51
|
-
end
|
52
|
-
|
53
60
|
private
|
54
61
|
|
55
62
|
def content_url(content_id, params = {})
|
@@ -60,6 +60,11 @@ module GdsApi
|
|
60
60
|
assert_publishing_api(:post, url, attributes_or_matcher, times)
|
61
61
|
end
|
62
62
|
|
63
|
+
def assert_publishing_api_discard_draft(content_id, attributes_or_matcher = {}, times = 1)
|
64
|
+
url = PUBLISHING_API_V2_ENDPOINT + "/content/#{content_id}/discard-draft"
|
65
|
+
assert_publishing_api(:post, url, attributes_or_matcher, times)
|
66
|
+
end
|
67
|
+
|
63
68
|
def assert_publishing_api(verb, url, attributes_or_matcher = {}, times = 1)
|
64
69
|
if attributes_or_matcher.is_a?(Hash)
|
65
70
|
matcher = attributes_or_matcher.empty? ? nil : request_json_matching(attributes_or_matcher)
|
data/lib/gds_api/version.rb
CHANGED
@@ -927,11 +927,9 @@ describe GdsApi::PublishingApiV2 do
|
|
927
927
|
end
|
928
928
|
end
|
929
929
|
|
930
|
-
describe "#discard_draft(content_id)" do
|
930
|
+
describe "#discard_draft(content_id, options = {})" do
|
931
931
|
describe "when the content item exists" do
|
932
932
|
before do
|
933
|
-
@content_item = content_item_for_content_id(@content_id)
|
934
|
-
|
935
933
|
publishing_api
|
936
934
|
.given("a content item exists with content_id: #{@content_id}")
|
937
935
|
.upon_receiving("a request to discard draft content")
|
@@ -954,6 +952,32 @@ describe GdsApi::PublishingApiV2 do
|
|
954
952
|
end
|
955
953
|
end
|
956
954
|
|
955
|
+
describe "when the content item exists and is French" do
|
956
|
+
before do
|
957
|
+
publishing_api
|
958
|
+
.given("a French content item exists with content_id: #{@content_id}")
|
959
|
+
.upon_receiving("a request to discard French draft content")
|
960
|
+
.with(
|
961
|
+
method: :post,
|
962
|
+
path: "/v2/content/#{@content_id}/discard-draft",
|
963
|
+
body: {
|
964
|
+
locale: "fr",
|
965
|
+
},
|
966
|
+
headers: {
|
967
|
+
"Content-Type" => "application/json",
|
968
|
+
},
|
969
|
+
)
|
970
|
+
.will_respond_with(
|
971
|
+
status: 200,
|
972
|
+
)
|
973
|
+
end
|
974
|
+
|
975
|
+
it "responds with 200" do
|
976
|
+
response = @api_client.discard_draft(@content_id, locale: "fr")
|
977
|
+
assert_equal 200, response.code
|
978
|
+
end
|
979
|
+
end
|
980
|
+
|
957
981
|
describe "when there is no content with that content_id" do
|
958
982
|
before do
|
959
983
|
publishing_api
|