gds-api-adapters 23.2.1 → 23.2.2

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: da4e4ae0fc44e8c9ebe795756199c5077dd6d318
4
- data.tar.gz: 8bd24552bad840fa445a1aa1ea965d20d7af8772
3
+ metadata.gz: 146fc2c08df691e77339fe6b7bc1fa0610e5524f
4
+ data.tar.gz: 16b5c231df6ba9635b444d0361bda7612f973903
5
5
  SHA512:
6
- metadata.gz: d87312aceb19389654c848d02bbf0815713fec58ced7d8a914035bb4c18149987da6f1866cbd9af27eaaaecb6dfea0c681ef23928a55d3a3bf378b1df4c3696a
7
- data.tar.gz: d3ddb7828a6469a7bfcc5cce1c372810debb85899a3c490486f12321a2a746c07ff836c4e96287734dd416a519de54fdaa8133339b5233efd7a033674547adba
6
+ metadata.gz: 9294bcfdfdcc7c4548e74bd617e7df6ecdc5562ced0f01e0393f579b7fdc4fbe8f5b25d1a6174fdfc2c0a9c15910ea610a1af0963398508e758f0a101279f287
7
+ data.tar.gz: eeb30426caaa3501e658041ea962e90347aa040e89352e0ceb7dd3588f15d5f9a98ccdfa4e2bf62c8b223ab9fd260dd67b23b693fe721005f381de04d0d908a9
@@ -1,4 +1,5 @@
1
1
  require "gds_api/publishing_api"
2
+ require "time"
2
3
 
3
4
  module GdsApi
4
5
  class PublishingApi < GdsApi::Base
@@ -25,12 +26,16 @@ module GdsApi
25
26
  publishing_app: options.fetch(:publishing_app),
26
27
  rendering_app: options.fetch(:rendering_app),
27
28
  update_type: "major",
28
- public_updated_at: (Time.respond_to?(:zone) ? Time.zone.try(:now) : Time.now).iso8601,
29
+ public_updated_at: time.now.iso8601,
29
30
  })
30
31
  end
31
32
 
32
33
  private
33
34
  attr_reader :logger, :publishing_api
35
+
36
+ def time
37
+ (Time.respond_to?(:zone) && Time.zone) || Time
38
+ end
34
39
  end
35
40
  end
36
41
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '23.2.1'
2
+ VERSION = '23.2.2'
3
3
  end
@@ -3,44 +3,77 @@ require "gds_api/publishing_api/special_route_publisher"
3
3
 
4
4
  describe GdsApi::PublishingApi::SpecialRoutePublisher do
5
5
  let(:publishing_api) {
6
- stub(:publishing_api)
6
+ stub(:publishing_api, put_content_item: nil)
7
7
  }
8
8
 
9
9
  let(:publisher) {
10
10
  GdsApi::PublishingApi::SpecialRoutePublisher.new(publishing_api: publishing_api)
11
11
  }
12
12
 
13
+ let(:special_route) {
14
+ {
15
+ content_id: "a-content-id-of-sorts",
16
+ title: "A title",
17
+ description: "A description",
18
+ base_path: "/favicon.ico",
19
+ type: "exact",
20
+ publishing_app: "static-publisher",
21
+ rendering_app: "static-frontend",
22
+ }
23
+ }
24
+
13
25
  describe ".publish" do
14
26
  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
- )
27
+ Timecop.freeze(Time.now) do
28
+ publishing_api.expects(:put_content_item).with(
29
+ special_route[:base_path],
30
+ {
31
+ content_id: special_route[:content_id],
32
+ format: "special_route",
33
+ title: special_route[:title],
34
+ description: special_route[:description],
35
+ routes: [
36
+ {
37
+ path: special_route[:base_path],
38
+ type: special_route[:type],
39
+ }
40
+ ],
41
+ publishing_app: special_route[:publishing_app],
42
+ rendering_app: special_route[:rendering_app],
43
+ update_type: "major",
44
+ public_updated_at: Time.now.iso8601,
45
+ }
46
+ )
47
+
48
+ publisher.publish(special_route)
49
+ end
50
+ end
51
+
52
+ it "is robust to Time.zone returning nil" do
53
+ Timecop.freeze(Time.now) do
54
+ Time.stubs(:zone).returns(nil)
55
+
56
+ publishing_api.expects(:put_content_item).with(
57
+ anything,
58
+ has_entries(public_updated_at: Time.now.iso8601)
59
+ )
60
+
61
+ publisher.publish(special_route)
62
+ end
63
+ end
64
+
65
+ it "uses Time.zone if available" do
66
+ Timecop.freeze(Time.now) do
67
+ time_in_zone = stub("Time in zone", now: Time.parse("2010-01-01 10:10:10 +04:00"))
68
+ Time.stubs(:zone).returns(time_in_zone)
69
+
70
+ publishing_api.expects(:put_content_item).with(
71
+ anything,
72
+ has_entries(public_updated_at: time_in_zone.now.iso8601)
73
+ )
74
+
75
+ publisher.publish(special_route)
76
+ end
44
77
  end
45
78
  end
46
79
  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.2.1
4
+ version: 23.2.2
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-08-12 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek