gds-api-adapters 26.1.0 → 26.2.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: 73b0b78f10cd055ff72a24be044a44f7c5001df4
4
- data.tar.gz: 2b1498057649a161321089c2f8ddbabfb0282a50
3
+ metadata.gz: 43033670f2451e74e4ecc8048760dfd834031618
4
+ data.tar.gz: 628a90354b539241f4b73e36ebc8964c37fa3c25
5
5
  SHA512:
6
- metadata.gz: 54b851820f3b41ba2a7414c750960d22b00e8217f29c51727b57c8d7864fe9f1bcfc1bd6de9a0b18c8f6bfc243eab88ddf72bbefb83be57419a449c64a39a2d4
7
- data.tar.gz: 234a3533b03f9cbf799d16067a6d733734b6a40fb912948b5ce5744e21a9b016149a4c88195f9c2558f36c98d786aa6a9b52090d724f895981e7674d812cb008
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)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '26.1.0'
2
+ VERSION = '26.2.0'
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 26.1.0
4
+ version: 26.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stewart