contentful-scheduler-custom-build-john 1.12 → 1.13

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: e83307bec8f58caaa3b5c7a80325ed2786c9b870
4
- data.tar.gz: 74c479c6f4cd6f0df5f2969b995135710cf07e60
3
+ metadata.gz: cd7879dca084282d83eb0b2b68d51595ee2bb490
4
+ data.tar.gz: 70b18738b7c0299117476a673db14b5111b0662c
5
5
  SHA512:
6
- metadata.gz: d661f2c6fb9bc5546acb3d32d278e7a434211f41b1c0824d8667c34002089ac32171944be3d3ebb9e2a3dbd262ea97d3e51f5176f7bf3942513ed69728f7fad9
7
- data.tar.gz: 61e4867c01e33ec98f34f6c1e8ebbfcfc8bff8202e66d312ec83891f16452beb94af79adda9e369f80c39d581196088327837c819bd3df876677a4617c10fc1a
6
+ metadata.gz: de387823a3772352a2eeaa82291699ebba8163a7b96445abfed4f0389af8e84a38ce4b418bc1f06c02aa26984c3988e59c2dc34364b6587c229a358f934fbdfb
7
+ data.tar.gz: 91bb034e50171ffadc658ed5c21dafc56a3932cfb8285e842402c9b32495de49b280ee01df799fdfbae0f12a146574e5ca6113a905ccf066971ee23e14f47989
@@ -63,7 +63,8 @@ module Contentful
63
63
 
64
64
  def already_published?(webhook)
65
65
  return true if publish_date(webhook) < Time.now.utc
66
- if !webhook_is_publish_in_future(webhook).nil?
66
+ puts !webhook_is_publish_in_future(webhook)
67
+ if !webhook_is_publish_in_future(webhook)
67
68
  return false unless webhook.sys.key?('publishedAt')
68
69
  if !webhook.sys['publishedAt'].nil?
69
70
  return Chronic.parse(webhook.sys['publishedAt']).utc < Time.now.utc
@@ -98,7 +99,11 @@ module Contentful
98
99
  end
99
100
 
100
101
  def webhook_is_publish_in_future(webhook)
101
- webhook.fields[spaces[webhook.space_id][:is_publish_in_future]]
102
+ if webhook.fields.key?(spaces.fetch(webhook.space_id, {})[:is_publish_in_future])
103
+ return webhook.fields[spaces[webhook.space_id][:is_publish_in_future]]
104
+ else
105
+ return true
106
+ end
102
107
  end
103
108
 
104
109
  private
@@ -1,5 +1,5 @@
1
1
  module Contentful
2
2
  module Scheduler
3
- VERSION = "1.12"
3
+ VERSION = "1.13"
4
4
  end
5
5
  end
@@ -132,10 +132,10 @@ describe Contentful::Scheduler::Queue do
132
132
  )).to be_falsey
133
133
  end
134
134
 
135
- it 'true if sys.publishedAt is in past and is_publish_in_future is true' do
135
+ it 'false if sys.publishedAt is in past and is_publish_in_future is true' do
136
136
  expect(subject.already_published?(
137
137
  WebhookDouble.new('bar', 'foo', {'publishedAt' => '2011-04-04T22:00:00+00:00'}, {'my_field' => '2099-04-04T22:00:00+00:00', 'is_publish_in_future' => true})
138
- )).to be_truthy
138
+ )).to be_falsey
139
139
  end
140
140
 
141
141
  it 'false if sys.publishedAt is not present and is_publish_in_future is false' do
@@ -149,6 +149,18 @@ describe Contentful::Scheduler::Queue do
149
149
  WebhookDouble.new('bar', 'foo', {}, {'my_field' => '2011-04-04T22:00:00+00:00', 'is_publish_in_future' => true})
150
150
  )).to be_truthy
151
151
  end
152
+
153
+ it 'false if webhook publish_date is in future and is_publish_in_future is false' do
154
+ expect(subject.already_published?(
155
+ WebhookDouble.new('bar', 'foo', {}, {'my_field' => '2099-04-04T22:00:00+00:00', 'is_publish_in_future' => false})
156
+ )).to be_falsey
157
+ end
158
+
159
+ it 'true if webhook publish_date is in future and is_publish_in_future is false' do
160
+ expect(subject.already_published?(
161
+ WebhookDouble.new('bar', 'foo', {'publishedAt' => '2011-04-04T22:00:00+00:00'}, {'my_field' => '2099-04-04T22:00:00+00:00', 'is_publish_in_future' => false})
162
+ )).to be_truthy
163
+ end
152
164
  end
153
165
 
154
166
  describe '#publishable?' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentful-scheduler-custom-build-john
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.12'
4
+ version: '1.13'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentful GmbH (David Litvak Bruno0