gds-api-adapters 27.2.0 → 27.2.1

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: dc7475596bb3598a6a5a759f53d4741ca8ff8aea
4
- data.tar.gz: 21a71b66b3be97ee6ce8f39af84cc78dc8e0cd0d
3
+ metadata.gz: e2f279aa3d9a7e19735b40e8bc8c35f6cccbe038
4
+ data.tar.gz: f3f11d44a629ec3c0b00be1c96a8ce177ddff29c
5
5
  SHA512:
6
- metadata.gz: e1b8d8c47778a1a2c4042df7e08ff990cd75f190f2156d5d4ffeb568029579de9fb23129419d364f7708de31de303a3abe50ffa78e03ec4bccbf5df0e3fc63ee
7
- data.tar.gz: bbe6af24984a932b38a1bf0b46698b647f91f9bfa72aad63f38d18cf75de155cc89f1727b586c9d52589ffe9edfaa7f37d9f528c4ec3f2c6cd9efb4b3619ef08
6
+ metadata.gz: 8189ca648010ca2a59cb275201bd26ec5638e93593fa89213e49d8bd2af60d883834a24d2c3b49a2cbbb4f19dcd482f1f5f7ba9ae73939a55cc19b7f34bbac36
7
+ data.tar.gz: 303c315106e8e21598118b975f5defbb5fdd0d0051b7437b316c1a8558cf1bbbeda9a54979b2e22fa3329c71b9b17015f8dfd18cbe6e11f2db14c49e1576b992
@@ -59,25 +59,30 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
59
59
 
60
60
  def get_linked_items(content_id, params = {})
61
61
  query = query_string(params)
62
+ validate_content_id(content_id)
62
63
  get_json("#{endpoint}/v2/linked/#{content_id}#{query}")
63
64
  end
64
65
 
65
66
  private
66
67
 
67
68
  def content_url(content_id, params = {})
69
+ validate_content_id(content_id)
68
70
  query = query_string(params)
69
71
  "#{endpoint}/v2/content/#{content_id}#{query}"
70
72
  end
71
73
 
72
74
  def links_url(content_id)
75
+ validate_content_id(content_id)
73
76
  "#{endpoint}/v2/links/#{content_id}"
74
77
  end
75
78
 
76
79
  def publish_url(content_id)
80
+ validate_content_id(content_id)
77
81
  "#{endpoint}/v2/content/#{content_id}/publish"
78
82
  end
79
83
 
80
84
  def discard_url(content_id)
85
+ validate_content_id(content_id)
81
86
  "#{endpoint}/v2/content/#{content_id}/discard-draft"
82
87
  end
83
88
 
@@ -86,4 +91,8 @@ private
86
91
  hash.merge!(optional_key => options[optional_key]) if options[optional_key]
87
92
  end
88
93
  end
94
+
95
+ def validate_content_id(content_id)
96
+ raise ArgumentError, "content_id cannot be nil" unless content_id
97
+ end
89
98
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '27.2.0'
2
+ VERSION = '27.2.1'
3
3
  end
@@ -1021,6 +1021,36 @@ describe GdsApi::PublishingApiV2 do
1021
1021
  { 'content_id' => @content_id, 'locale' => 'ar' },
1022
1022
  ], response.to_a
1023
1023
  end
1024
+
1025
+ it "returns details hashes" do
1026
+ publishing_api
1027
+ .given("a content item exists with content_id: #{@content_id} and it has details")
1028
+ .upon_receiving("a get entries request with details field")
1029
+ .with(
1030
+ method: :get,
1031
+ path: "/v2/content",
1032
+ query: "content_format=topic&fields%5B%5D=content_id&fields%5B%5D=details",
1033
+ headers: {
1034
+ "Content-Type" => "application/json",
1035
+ },
1036
+ )
1037
+ .will_respond_with(
1038
+ status: 200,
1039
+ body: [
1040
+ { content_id: @content_id, details: {foo: :bar} },
1041
+ ]
1042
+ )
1043
+
1044
+ response = @api_client.get_content_items(
1045
+ content_format: 'topic',
1046
+ fields: [:content_id, :details],
1047
+ )
1048
+
1049
+ assert_equal 200, response.code
1050
+ assert_equal [
1051
+ { 'content_id' => @content_id, 'details' => {"foo"=>"bar"} },
1052
+ ], response.to_a
1053
+ end
1024
1054
  end
1025
1055
 
1026
1056
  describe "#discard_draft(content_id, options = {})" do
@@ -1202,4 +1232,24 @@ describe GdsApi::PublishingApiV2 do
1202
1232
  end
1203
1233
  end
1204
1234
  end
1235
+
1236
+ describe "content ID validation" do
1237
+ [:get_content, :get_links, :get_linked_items, :discard_draft].each do |method|
1238
+ it "happens on #{method}" do
1239
+ proc { @api_client.send(method, nil) }.must_raise ArgumentError
1240
+ end
1241
+ end
1242
+
1243
+ it "happens on publish" do
1244
+ proc { @api_client.publish(nil, "major") }.must_raise ArgumentError
1245
+ end
1246
+
1247
+ it "happens on put_content" do
1248
+ proc { @api_client.put_content(nil, {}) }.must_raise ArgumentError
1249
+ end
1250
+
1251
+ it "happens on put_links" do
1252
+ proc { @api_client.put_links(nil, links: {}) }.must_raise ArgumentError
1253
+ end
1254
+ end
1205
1255
  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: 27.2.0
4
+ version: 27.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-26 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek