gds-api-adapters 23.1.0 → 23.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: bd7b1a091da260080fb3bed10086d31c84e1708d
4
- data.tar.gz: 1d82d8b9d6d16adae35fe3aa6dd602330a237f5c
3
+ metadata.gz: 8a40f277fd306b18db76025ca370d8ed4bbf1b8f
4
+ data.tar.gz: 2335bc37a530d8066189ce4b5a987884802523a5
5
5
  SHA512:
6
- metadata.gz: 72c4bab7cb84d20997f1c1739c55939f113590a7d357721127d68df77fcc99568a37068edbebf4c56f381fd2e2018d4e2d1276b5a530fb30713ca923e27184af
7
- data.tar.gz: 05b9bc994f6f69880135f722e67930673a2ad47735cff4d4aa1d1409f0732d94bc84acb089ced7049eadb78bd130dcb500dfd3d13126e5bf0e0f73a0caceb18c
6
+ metadata.gz: b90e08fc3c110e59de7a8b807f83a526c3fdc271797435c333fd3c1f5658cf35b0bbab5f8ae36981e6aa0faa46dbc5b349ac286ee960e17ee063092fccad8ac0
7
+ data.tar.gz: 628cf65f392899017a2d8255f5205192520cff986c87e381a26443e941451e3a6c4d63208979cdde82e169af8142447fd96ba565d3f6035f26f5258a60ed4d69
@@ -0,0 +1,36 @@
1
+ require "gds_api/publishing_api"
2
+
3
+ module GdsApi
4
+ class PublishingApi < GdsApi::Base
5
+ class SpecialRoutePublisher
6
+ def initialize(options = {})
7
+ @logger = options[:logger] || GdsApi::Base.logger
8
+ @publishing_api = options[:publishing_api] || GdsApi::PublishingApi.new(Plek.find("publishing-api"))
9
+ end
10
+
11
+ def publish(options)
12
+ logger.info("Publishing #{options.fetch(:type)} route #{options.fetch(:base_path)}, routing to #{options.fetch(:rendering_app)}")
13
+
14
+ publishing_api.put_content_item(options.fetch(:base_path), {
15
+ content_id: options.fetch(:content_id),
16
+ format: "special_route",
17
+ title: options.fetch(:title),
18
+ description: options[:description] || "",
19
+ routes: [
20
+ {
21
+ path: options.fetch(:base_path),
22
+ type: options.fetch(:type),
23
+ }
24
+ ],
25
+ publishing_app: options.fetch(:publishing_app),
26
+ rendering_app: options.fetch(:rendering_app),
27
+ update_type: "major",
28
+ public_updated_at: (Time.respond_to?(:zone) ? Time.zone.try(:now) : Time.now).iso8601,
29
+ })
30
+ end
31
+
32
+ private
33
+ attr_reader :logger, :publishing_api
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '23.1.0'
2
+ VERSION = '23.2.0'
3
3
  end
@@ -0,0 +1,46 @@
1
+ require 'test_helper'
2
+ require "gds_api/publishing_api/special_route_publisher"
3
+
4
+ describe GdsApi::PublishingApi::SpecialRoutePublisher do
5
+ let(:publishing_api) {
6
+ stub(:publishing_api)
7
+ }
8
+
9
+ let(:publisher) {
10
+ GdsApi::PublishingApi::SpecialRoutePublisher.new(publishing_api: publishing_api)
11
+ }
12
+
13
+ describe ".publish" do
14
+ it "publishes the special routes" do
15
+ publishing_api.expects(:put_content_item).with(
16
+ "/favicon.ico",
17
+ {
18
+ content_id: "a-content-id-of-sorts",
19
+ format: "special_route",
20
+ title: "A title",
21
+ description: "A description",
22
+ routes: [
23
+ {
24
+ path: "/favicon.ico",
25
+ type: "exact",
26
+ }
27
+ ],
28
+ publishing_app: "static-publisher",
29
+ rendering_app: "static-frontend",
30
+ update_type: "major",
31
+ public_updated_at: Time.now.iso8601,
32
+ }
33
+ )
34
+
35
+ publisher.publish(
36
+ content_id: "a-content-id-of-sorts",
37
+ title: "A title",
38
+ description: "A description",
39
+ base_path: "/favicon.ico",
40
+ type: "exact",
41
+ publishing_app: "static-publisher",
42
+ rendering_app: "static-frontend",
43
+ )
44
+ end
45
+ end
46
+ 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: 23.1.0
4
+ version: 23.2.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-07-30 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek
@@ -303,6 +303,7 @@ files:
303
303
  - lib/gds_api/performance_platform/data_in.rb
304
304
  - lib/gds_api/publisher.rb
305
305
  - lib/gds_api/publishing_api.rb
306
+ - lib/gds_api/publishing_api/special_route_publisher.rb
306
307
  - lib/gds_api/railtie.rb
307
308
  - lib/gds_api/response.rb
308
309
  - lib/gds_api/router.rb
@@ -372,6 +373,7 @@ files:
372
373
  - test/panopticon_test.rb
373
374
  - test/pp_data_in_test.rb
374
375
  - test/publisher_api_test.rb
376
+ - test/publishing_api/special_route_publisher_test.rb
375
377
  - test/publishing_api_test.rb
376
378
  - test/response_test.rb
377
379
  - test/router_test.rb
@@ -413,6 +415,7 @@ test_files:
413
415
  - test/publishing_api_test.rb
414
416
  - test/whitehall_admin_api_test.rb
415
417
  - test/pp_data_in_test.rb
418
+ - test/publishing_api/special_route_publisher_test.rb
416
419
  - test/need_api_test.rb
417
420
  - test/publisher_api_test.rb
418
421
  - test/rummager_helpers_test.rb