gds-api-adapters 26.0.0 → 26.1.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: 66e74267e0f6000e782fdb7a29edc89458d17d1c
4
- data.tar.gz: ea45a63f2bb0cb8e8dd03c2f8078ac78c294af1a
3
+ metadata.gz: 73b0b78f10cd055ff72a24be044a44f7c5001df4
4
+ data.tar.gz: 2b1498057649a161321089c2f8ddbabfb0282a50
5
5
  SHA512:
6
- metadata.gz: 25d4e1618e12b774d0687f2fd2a2e0cd6bfdd99e0d5c369a5d309fda42b6356e67b7526a64ef9f18aa27e22b67e152687a3562929cfbf1ac75be4628cb36b0cb
7
- data.tar.gz: 91b34e5c8efb6732c07ad3966287f67ce868663dc152064fcb212c73b3d46b733dc80f31659da508fbfe6bad76a36759ebbf0bb7013d9381cb1433aaba254abc
6
+ metadata.gz: 54b851820f3b41ba2a7414c750960d22b00e8217f29c51727b57c8d7864fe9f1bcfc1bd6de9a0b18c8f6bfc243eab88ddf72bbefb83be57419a449c64a39a2d4
7
+ data.tar.gz: 234a3533b03f9cbf799d16067a6d733734b6a40fb912948b5ce5744e21a9b016149a4c88195f9c2558f36c98d786aa6a9b52090d724f895981e7674d812cb008
@@ -1,7 +1,6 @@
1
1
  require_relative 'base'
2
2
 
3
3
  class GdsApi::PublishingApiV2 < GdsApi::Base
4
-
5
4
  def put_content(content_id, payload)
6
5
  put_json!(content_url(content_id), payload)
7
6
  end
@@ -47,6 +46,10 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
47
46
  get_json("#{endpoint}/v2/content#{query}")
48
47
  end
49
48
 
49
+ def discard_draft(content_id)
50
+ post_json!(discard_url(content_id), {})
51
+ end
52
+
50
53
  private
51
54
 
52
55
  def content_url(content_id, params = {})
@@ -62,6 +65,10 @@ private
62
65
  "#{endpoint}/v2/content/#{content_id}/publish"
63
66
  end
64
67
 
68
+ def discard_url(content_id)
69
+ "#{endpoint}/v2/content/#{content_id}/discard-draft"
70
+ end
71
+
65
72
  def merge_optional_keys(params, options, optional_keys)
66
73
  optional_keys.each_with_object(params) do |optional_key, hash|
67
74
  hash.merge!(optional_key => options[optional_key]) if options[optional_key]
@@ -23,6 +23,11 @@ module GdsApi
23
23
  stub_request(:post, url).with(body: body).to_return(status: 200, body: '{}', headers: {"Content-Type" => "application/json; charset=utf-8"})
24
24
  end
25
25
 
26
+ def stub_publishing_api_discard_draft(content_id)
27
+ url = PUBLISHING_API_V2_ENDPOINT + "/content/#{content_id}/discard-draft"
28
+ stub_request(:post, url).to_return(status: 200, headers: {"Content-Type" => "application/json; charset=utf-8"})
29
+ end
30
+
26
31
  def stub_publishing_api_put_content_links_and_publish(body, content_id = nil, publish_options = nil)
27
32
  content_id ||= body[:content_id]
28
33
  publish_options ||= { update_type: { update_type: body[:update_type], locale: body[:locale] } }
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '26.0.0'
2
+ VERSION = '26.1.0'
3
3
  end
@@ -926,4 +926,59 @@ describe GdsApi::PublishingApiV2 do
926
926
  ], response.to_a
927
927
  end
928
928
  end
929
+
930
+ describe "#discard_draft(content_id)" do
931
+ describe "when the content item exists" do
932
+ before do
933
+ @content_item = content_item_for_content_id(@content_id)
934
+
935
+ publishing_api
936
+ .given("a content item exists with content_id: #{@content_id}")
937
+ .upon_receiving("a request to discard draft content")
938
+ .with(
939
+ method: :post,
940
+ path: "/v2/content/#{@content_id}/discard-draft",
941
+ body: {},
942
+ headers: {
943
+ "Content-Type" => "application/json",
944
+ },
945
+ )
946
+ .will_respond_with(
947
+ status: 200,
948
+ )
949
+ end
950
+
951
+ it "responds with 200" do
952
+ response = @api_client.discard_draft(@content_id)
953
+ assert_equal 200, response.code
954
+ end
955
+ end
956
+
957
+ describe "when there is no content with that content_id" do
958
+ before do
959
+ publishing_api
960
+ .given("no content exists")
961
+ .upon_receiving("a request to discard draft content")
962
+ .with(
963
+ method: :post,
964
+ path: "/v2/content/#{@content_id}/discard-draft",
965
+ body: {},
966
+ headers: {
967
+ "Content-Type" => "application/json",
968
+ },
969
+ )
970
+ .will_respond_with(
971
+ status: 404,
972
+ )
973
+ end
974
+
975
+ it "responds with a 404" do
976
+ error = assert_raises GdsApi::HTTPClientError do
977
+ @api_client.discard_draft(@content_id)
978
+ end
979
+
980
+ assert_equal 404, error.code
981
+ end
982
+ end
983
+ end
929
984
  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: 26.0.0
4
+ version: 26.1.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-11-26 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek