gds-api-adapters 26.5.0 → 26.6.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: 6e6086fcd077f82492196d0fba5f3c57ec3c739a
4
- data.tar.gz: 9f4140565169ee3dbf5ff33a638bbb483c1124d3
3
+ metadata.gz: 3030fdcb2fb240546b4d1d5fc55a277621facf0a
4
+ data.tar.gz: 4cb591fdd8b8227355a9dd17a733dcf5d621f303
5
5
  SHA512:
6
- metadata.gz: f4ae8d18936478c15316167e6c815eb34ed715b7e99d9a19aea47779ab6b1e23f872e92a8ff2de15171399901f3c9854c156e339ad3bf212b7491af13ae2494f
7
- data.tar.gz: 32850c738b23681f5b2610351ea018a48f1aa41a4ad59462a25f788afdec48e2c360e7aa9e0f6cce7066d5af1b024cd6880354928a044cdf04e1b02244797c80
6
+ metadata.gz: e64ffcc0ffef99a3a3b298b5b9edc7e86c27da5534ef81f1d5e292952cca31730a9e284be563721c8583576887a1ebf2c3eed85cd6575c49214eeb089a938d3c
7
+ data.tar.gz: 1f7055f253784348b9349609ff65503fa124d08e9b8fc77081b9f2eca99c94d5e3c6769c92d0ec16fc492c5a37a3b09acaa807b910e66e6168f74bbbd50b9912
@@ -57,6 +57,11 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
57
57
  get_json("#{endpoint}/v2/content#{query}")
58
58
  end
59
59
 
60
+ def get_linked_items(content_id, params = {})
61
+ query = query_string(params)
62
+ get_json("#{endpoint}/v2/linked/#{content_id}#{query}")
63
+ end
64
+
60
65
  private
61
66
 
62
67
  def content_url(content_id, params = {})
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '26.5.0'
2
+ VERSION = '26.6.0'
3
3
  end
@@ -1005,4 +1005,105 @@ describe GdsApi::PublishingApiV2 do
1005
1005
  end
1006
1006
  end
1007
1007
  end
1008
+ describe "#get_linked_items" do
1009
+ describe "if the content item does not exist" do
1010
+ before do
1011
+ publishing_api
1012
+ .given("no content exists")
1013
+ .upon_receiving("a request to return the items linked to it")
1014
+ .with(
1015
+ method: :get,
1016
+ path: "/v2/linked/#{@content_id}",
1017
+ query: "fields%5B%5D=content_id&fields%5B%5D=base_path&link_type=topic",
1018
+ )
1019
+ .will_respond_with(
1020
+ status: 404,
1021
+ body: {
1022
+ "error" => {
1023
+ "code" => 404,
1024
+ "message" => Pact.term(generate: "not found", matcher:/\S+/)
1025
+ },
1026
+ },
1027
+ headers: {
1028
+ "Content-Type" => "application/json; charset=utf-8",
1029
+ },
1030
+ )
1031
+ end
1032
+
1033
+ it "404s" do
1034
+ response = @api_client.get_linked_items(
1035
+ @content_id,
1036
+ {
1037
+ link_type: "topic",
1038
+ fields: ["content_id", "base_path"],
1039
+ }
1040
+ )
1041
+ assert_nil response
1042
+ end
1043
+ end
1044
+
1045
+ describe "there are two documents that link to the wantend document" do
1046
+ before do
1047
+ content_id2 = "08dfd5c3-d935-4e81-88fd-cfe65b78893d"
1048
+ content_id3 = "e2961462-bc37-48e9-bb98-c981ef1a2d59"
1049
+
1050
+ @linked_content_item = content_item_for_content_id("6cb2cf8c-670f-4de3-97d5-6ad9114581c7")
1051
+ @linking_content_item1 = content_item_for_content_id(content_id3,
1052
+ "base_path" => "/item-b",
1053
+ "links" => {
1054
+ "topic" => [ @linked_content_item['content_id1'] ]
1055
+ })
1056
+ @linking_content_item2 = content_item_for_content_id(content_id2,
1057
+ "base_path" => "/item-a",
1058
+ "links" => {
1059
+ "topic" => [ @linked_content_item['content_id1'] ],
1060
+ })
1061
+
1062
+ publishing_api
1063
+ .given("there are two documents with a 'topic' link to another document")
1064
+ .upon_receiving("a get linked request")
1065
+ .with(
1066
+ method: :get,
1067
+ path: "/v2/linked/" + @linked_content_item['content_id'],
1068
+ query: "fields%5B%5D=content_id&fields%5B%5D=base_path&link_type=topic",
1069
+ headers: {
1070
+ "Content-Type" => "application/json",
1071
+ },
1072
+ )
1073
+ .will_respond_with(
1074
+ status: 200,
1075
+ body: [
1076
+ {
1077
+ content_id: @linking_content_item1["content_id"],
1078
+ base_path: @linking_content_item1["base_path"]
1079
+ },
1080
+ {
1081
+ content_id: @linking_content_item2["content_id"],
1082
+ base_path: @linking_content_item2["base_path"]
1083
+ }
1084
+ ]
1085
+ )
1086
+ end
1087
+
1088
+ it "returns the requested fields of linking items" do
1089
+ response = @api_client.get_linked_items(
1090
+ @linked_content_item["content_id"],
1091
+ {
1092
+ link_type: "topic",
1093
+ fields: ["content_id", "base_path"],
1094
+ }
1095
+ )
1096
+ assert_equal 200, response.code
1097
+
1098
+ expected_documents = [
1099
+ { "content_id" => @linking_content_item2["content_id"], "base_path" => "/item-a" },
1100
+ { "content_id" => @linking_content_item1["content_id"], "base_path" => "/item-b" },
1101
+ ]
1102
+
1103
+ expected_documents.each do |document|
1104
+ response.to_a.must_include document
1105
+ end
1106
+ end
1107
+ end
1108
+ end
1008
1109
  end
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.5.0
4
+ version: 26.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stewart