maily_herald 0.8.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +1 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +0 -2
  5. data/Gemfile.lock +5 -13
  6. data/README.md +186 -69
  7. data/app/mailers/maily_herald/mailer.rb +44 -26
  8. data/app/models/maily_herald/ad_hoc_mailing.rb +109 -0
  9. data/app/models/maily_herald/dispatch.rb +97 -4
  10. data/app/models/maily_herald/list.rb +36 -7
  11. data/app/models/maily_herald/log.rb +79 -0
  12. data/app/models/maily_herald/mailing.rb +149 -24
  13. data/app/models/maily_herald/one_time_mailing.rb +114 -9
  14. data/app/models/maily_herald/periodical_mailing.rb +76 -47
  15. data/app/models/maily_herald/sequence.rb +57 -18
  16. data/app/models/maily_herald/sequence_mailing.rb +29 -20
  17. data/app/models/maily_herald/subscription.rb +23 -2
  18. data/config/routes.rb +2 -2
  19. data/lib/maily_herald.rb +57 -18
  20. data/lib/maily_herald/autonaming.rb +8 -0
  21. data/lib/maily_herald/context.rb +6 -2
  22. data/lib/maily_herald/logging.rb +2 -0
  23. data/lib/maily_herald/manager.rb +15 -31
  24. data/lib/maily_herald/utils.rb +65 -24
  25. data/lib/maily_herald/version.rb +1 -1
  26. data/maily_herald.gemspec +1 -1
  27. data/spec/controllers/maily_herald/tokens_controller_spec.rb +13 -13
  28. data/spec/dummy/app/mailers/ad_hoc_mailer.rb +11 -0
  29. data/spec/dummy/app/mailers/custom_one_time_mailer.rb +11 -0
  30. data/spec/dummy/config/application.rb +1 -1
  31. data/spec/dummy/config/environments/test.rb +1 -1
  32. data/spec/dummy/config/initializers/maily_herald.rb +3 -69
  33. data/spec/dummy/config/maily_herald.yml +3 -0
  34. data/spec/dummy/db/seeds.rb +73 -0
  35. data/spec/lib/context_spec.rb +7 -7
  36. data/spec/lib/maily_herald_spec.rb +7 -8
  37. data/spec/lib/utils_spec.rb +65 -25
  38. data/spec/mailers/maily_herald/mailer_spec.rb +20 -13
  39. data/spec/models/maily_herald/ad_hoc_mailing_spec.rb +169 -0
  40. data/spec/models/maily_herald/list_spec.rb +2 -1
  41. data/spec/models/maily_herald/log_spec.rb +10 -10
  42. data/spec/models/maily_herald/mailing_spec.rb +9 -8
  43. data/spec/models/maily_herald/one_time_mailing_spec.rb +212 -39
  44. data/spec/models/maily_herald/periodical_mailing_spec.rb +158 -92
  45. data/spec/models/maily_herald/sequence_mailing_spec.rb +2 -2
  46. data/spec/models/maily_herald/sequence_spec.rb +152 -139
  47. data/spec/models/maily_herald/subscription_spec.rb +21 -4
  48. metadata +17 -8
  49. data/lib/maily_herald/condition_evaluator.rb +0 -82
  50. data/lib/maily_herald/config.rb +0 -5
  51. data/spec/dummy/app/mailers/test_mailer.rb +0 -11
@@ -3,11 +3,11 @@ require 'spec_helper'
3
3
  describe MailyHerald::PeriodicalMailing do
4
4
  before(:each) do
5
5
  @mailing = MailyHerald.periodical_mailing(:weekly_summary)
6
- @mailing.should be_a MailyHerald::PeriodicalMailing
7
- @mailing.should_not be_a_new_record
6
+ expect(@mailing).to be_kind_of(MailyHerald::PeriodicalMailing)
7
+ expect(@mailing).not_to be_a_new_record
8
8
 
9
9
  @list = @mailing.list
10
- @mailing.start_at.should eq("user.created_at")
10
+ expect(@mailing.start_at).to eq("user.created_at")
11
11
  end
12
12
 
13
13
  after do
@@ -21,7 +21,7 @@ describe MailyHerald::PeriodicalMailing do
21
21
  end
22
22
 
23
23
  it "should create schedule" do
24
- MailyHerald::Log.scheduled.for_mailing(@mailing).count.should eq(1)
24
+ expect(MailyHerald::Log.scheduled.for_mailing(@mailing).count).to eq(1)
25
25
  end
26
26
  end
27
27
 
@@ -38,21 +38,21 @@ describe MailyHerald::PeriodicalMailing do
38
38
  end
39
39
 
40
40
  it "should be triggered by start_at change" do
41
- MailyHerald::Log.scheduled.for_mailing(@mailing).count.should eq(1)
41
+ expect(MailyHerald::Log.scheduled.for_mailing(@mailing).count).to eq(1)
42
42
  schedule = MailyHerald::Log.scheduled.for_mailing(@mailing).first
43
- schedule.processing_at.to_i.should eq(@entity.created_at.to_i)
43
+ expect(schedule.processing_at.to_i).to eq(@entity.created_at.to_i)
44
44
 
45
45
  time = Time.now + 10.days
46
46
  @mailing.update_attribute(:start_at, time.to_s)
47
47
 
48
48
  schedule.reload
49
- schedule.processing_at.to_i.should eq(time.to_i)
49
+ expect(schedule.processing_at.to_i).to eq(time.to_i)
50
50
  end
51
51
 
52
52
  it "should be triggered by unsubscribe" do
53
- MailyHerald::Log.scheduled.for_mailing(@mailing).count.should eq(1)
53
+ expect(MailyHerald::Log.scheduled.for_mailing(@mailing).count).to eq(1)
54
54
  schedule = MailyHerald::Log.scheduled.for_mailing(@mailing).first
55
- schedule.processing_at.to_i.should eq(@entity.created_at.to_i)
55
+ expect(schedule.processing_at.to_i).to eq(@entity.created_at.to_i)
56
56
 
57
57
  @list.unsubscribe! @entity
58
58
 
@@ -60,9 +60,9 @@ describe MailyHerald::PeriodicalMailing do
60
60
  end
61
61
 
62
62
  it "should be triggered by disabling mailing" do
63
- MailyHerald::Log.scheduled.for_mailing(@mailing).count.should eq(1)
63
+ expect(MailyHerald::Log.scheduled.for_mailing(@mailing).count).to eq(1)
64
64
  schedule = MailyHerald::Log.scheduled.for_mailing(@mailing).first
65
- schedule.processing_at.to_i.should eq(@entity.created_at.to_i)
65
+ expect(schedule.processing_at.to_i).to eq(@entity.created_at.to_i)
66
66
 
67
67
  @mailing.disable!
68
68
 
@@ -90,20 +90,20 @@ describe MailyHerald::PeriodicalMailing do
90
90
  end
91
91
 
92
92
  it "should parse start_at" do
93
- @entity.should be_a(User)
94
- @mailing.start_processing_time(@entity).should be_a(Time)
95
- @mailing.next_processing_time(@entity).should be_a(Time)
96
- @mailing.next_processing_time(@entity).to_i.should eq(@entity.created_at.to_i)
93
+ expect(@entity).to be_kind_of(User)
94
+ expect(@mailing.start_processing_time(@entity)).to be_kind_of(Time)
95
+ expect(@mailing.next_processing_time(@entity)).to be_kind_of(Time)
96
+ expect(@mailing.next_processing_time(@entity).to_i).to eq(@entity.created_at.to_i)
97
97
  end
98
98
 
99
99
  it "should use absolute start date if possible" do
100
- @entity.should be_a(User)
100
+ expect(@entity).to be_kind_of(User)
101
101
  time = (@entity.created_at + rand(100).days + rand(24).hours + rand(60).minutes).round
102
102
  @mailing.update_attribute(:start_at, time.to_s)
103
103
 
104
- @mailing.start_processing_time(@entity).should be_a(Time)
105
- @mailing.next_processing_time(@entity).should be_a(Time)
106
- @mailing.next_processing_time(@entity).should eq(time)
104
+ expect(@mailing.start_processing_time(@entity)).to be_a(Time)
105
+ expect(@mailing.next_processing_time(@entity)).to be_kind_of(Time)
106
+ expect(@mailing.next_processing_time(@entity)).to eq(time)
107
107
  end
108
108
  end
109
109
 
@@ -114,111 +114,115 @@ describe MailyHerald::PeriodicalMailing do
114
114
  end
115
115
 
116
116
  it "should deliver mailings periodically" do
117
- @mailing.period.should eq 7.days
117
+ expect(@mailing.period).to eq 7.days
118
118
 
119
- @mailing.last_processing_time(@entity).should eq nil
120
- @mailing.next_processing_time(@entity).to_i.should eq((@entity.created_at).to_i)
119
+ expect(@mailing.last_processing_time(@entity)).to be_nil
120
+ expect(@mailing.next_processing_time(@entity).to_i).to eq((@entity.created_at).to_i)
121
121
 
122
122
  Timecop.freeze @entity.created_at
123
- @mailing.run
124
-
125
- @mailing.last_processing_time(@entity).to_i.should eq @entity.created_at.to_i
126
- @mailing.next_processing_time(@entity).to_i.should eq((@entity.created_at + 7.days).to_i)
123
+ ret = @mailing.run
124
+ expect(ret).to be_a(Array)
125
+ expect(ret.first).to be_kind_of(MailyHerald::Log)
126
+ expect(ret.first.mail).to be_kind_of(Mail::Message)
127
+ expect(ret.first).to be_delivered
128
+
129
+ expect(@mailing.last_processing_time(@entity).to_i).to eq @entity.created_at.to_i
130
+ expect(@mailing.next_processing_time(@entity).to_i).to eq((@entity.created_at + 7.days).to_i)
127
131
  end
128
132
 
129
133
  it "should deliver mailings after period" do
130
- MailyHerald::Subscription.count.should eq(1)
131
- MailyHerald::Log.processed.count.should eq(0)
134
+ expect(MailyHerald::Subscription.count).to eq(1)
135
+ expect(MailyHerald::Log.processed.count).to eq(0)
132
136
 
133
137
  Timecop.freeze @entity.created_at
134
138
 
135
- @mailing.conditions_met?(@entity).should be_truthy
136
- @mailing.processable?(@entity).should be_truthy
137
- @mailing.next_processing_time(@entity).should be <= @entity.created_at
139
+ expect(@mailing.conditions_met?(@entity)).to be_truthy
140
+ expect(@mailing.processable?(@entity)).to be_truthy
141
+ expect(@mailing.next_processing_time(@entity)).to be <= @entity.created_at
138
142
 
139
- @mailing.logs(@entity).scheduled.count.should eq(1)
143
+ expect(@mailing.logs(@entity).scheduled.count).to eq(1)
140
144
  schedule = @mailing.logs(@entity).scheduled.first
141
145
 
142
146
  @mailing.run
143
147
 
144
148
  schedule.reload
145
- schedule.status.should eq(:delivered)
149
+ expect(schedule.status).to eq(:delivered)
146
150
 
147
- MailyHerald::Subscription.count.should eq(1)
148
- MailyHerald::Log.processed.count.should eq(1)
151
+ expect(MailyHerald::Subscription.count).to eq(1)
152
+ expect(MailyHerald::Log.processed.count).to eq(1)
149
153
 
150
154
  log = MailyHerald::Log.processed.first
151
- log.entity.should eq(@entity)
152
- log.entity_email.should eq(@entity.email)
153
- log.mailing.should eq(@mailing)
155
+ expect(log.entity).to eq(@entity)
156
+ expect(log.entity_email).to eq(@entity.email)
157
+ expect(log.mailing).to eq(@mailing)
154
158
 
155
- @mailing.logs(@entity).processed.last.should eq(log)
156
- @mailing.last_processing_time(@entity).to_i.should eq(@entity.created_at.to_i)
159
+ expect(@mailing.logs(@entity).processed.last).to eq(log)
160
+ expect(@mailing.last_processing_time(@entity).to_i).to eq(@entity.created_at.to_i)
157
161
 
158
- @mailing.logs(@entity).scheduled.count.should eq(1)
162
+ expect(@mailing.logs(@entity).scheduled.count).to eq(1)
159
163
 
160
164
  @mailing.run
161
165
 
162
- MailyHerald::Subscription.count.should eq(1)
163
- MailyHerald::Log.processed.count.should eq(1)
166
+ expect(MailyHerald::Subscription.count).to eq(1)
167
+ expect(MailyHerald::Log.processed.count).to eq(1)
164
168
 
165
169
  Timecop.freeze @entity.created_at + @mailing.period + @mailing.period/3
166
170
 
167
- @mailing.logs(@entity).scheduled.count.should eq(1)
171
+ expect(@mailing.logs(@entity).scheduled.count).to eq(1)
168
172
 
169
173
  @mailing.run
170
174
 
171
- MailyHerald::Subscription.count.should eq(1)
172
- MailyHerald::Log.processed.count.should eq(2)
175
+ expect(MailyHerald::Subscription.count).to eq(1)
176
+ expect(MailyHerald::Log.processed.count).to eq(2)
173
177
 
174
178
  Timecop.freeze @entity.created_at + @mailing.period + @mailing.period/2
175
179
 
176
180
  @mailing.run
177
181
 
178
- MailyHerald::Subscription.count.should eq(1)
179
- MailyHerald::Log.processed.count.should eq(2)
182
+ expect(MailyHerald::Subscription.count).to eq(1)
183
+ expect(MailyHerald::Log.processed.count).to eq(2)
180
184
  end
181
185
 
182
186
  it "should calculate valid next delivery date" do
183
187
  period = @mailing.period
184
188
 
185
- @mailing.last_processing_time(@entity).should be_nil
186
- @mailing.start_processing_time(@entity).should be_a(Time)
187
- @mailing.start_processing_time(@entity).should eq(@entity.created_at)
188
- @mailing.next_processing_time(@entity).to_i.should eq(@entity.created_at.to_i)
189
+ expect(@mailing.last_processing_time(@entity)).to be_nil
190
+ expect(@mailing.start_processing_time(@entity)).to be_kind_of(Time)
191
+ expect(@mailing.start_processing_time(@entity)).to eq(@entity.created_at)
192
+ expect(@mailing.next_processing_time(@entity).to_i).to eq(@entity.created_at.to_i)
189
193
  end
190
194
 
191
195
  it "should handle processing with start date evaluated to the past date" do
192
- MailyHerald::Subscription.count.should eq(1)
193
- MailyHerald::Log.processed.count.should eq(0)
196
+ expect(MailyHerald::Subscription.count).to eq(1)
197
+ expect(MailyHerald::Log.processed.count).to eq(0)
194
198
 
195
- @mailing.next_processing_time(@entity).to_i.should eq(@entity.created_at.to_i)
199
+ expect(@mailing.next_processing_time(@entity).to_i).to eq(@entity.created_at.to_i)
196
200
  start_at = @entity.created_at + 1.year
197
201
 
198
202
  Timecop.freeze start_at
199
203
 
200
- @mailing.conditions_met?(@entity).should be_truthy
201
- @mailing.processable?(@entity).should be_truthy
204
+ expect(@mailing.conditions_met?(@entity)).to be_truthy
205
+ expect(@mailing.processable?(@entity)).to be_truthy
202
206
 
203
207
  @mailing.run
204
208
 
205
- MailyHerald::Subscription.count.should eq(1)
206
- MailyHerald::Log.processed.count.should eq(1)
207
- @mailing.last_processing_time(@entity).to_i.should eq(start_at.to_i)
209
+ expect(MailyHerald::Subscription.count).to eq(1)
210
+ expect(MailyHerald::Log.processed.count).to eq(1)
211
+ expect(@mailing.last_processing_time(@entity).to_i).to eq(start_at.to_i)
208
212
 
209
213
  Timecop.freeze start_at +1
210
214
  @mailing.run
211
215
 
212
- MailyHerald::Subscription.count.should eq(1)
213
- MailyHerald::Log.delivered.count.should eq(1)
216
+ expect(MailyHerald::Subscription.count).to eq(1)
217
+ expect(MailyHerald::Log.delivered.count).to eq(1)
214
218
 
215
- @mailing.next_processing_time(@entity).to_i.should eq((start_at + @mailing.period).to_i)
219
+ expect(@mailing.next_processing_time(@entity).to_i).to eq((start_at + @mailing.period).to_i)
216
220
  Timecop.freeze start_at + @mailing.period
217
221
 
218
222
  @mailing.run
219
223
 
220
- MailyHerald::Subscription.count.should eq(1)
221
- MailyHerald::Log.delivered.count.should eq(2)
224
+ expect(MailyHerald::Subscription.count).to eq(1)
225
+ expect(MailyHerald::Log.delivered.count).to eq(2)
222
226
  end
223
227
  end
224
228
 
@@ -234,14 +238,14 @@ describe MailyHerald::PeriodicalMailing do
234
238
  end
235
239
 
236
240
  it "should handle start_at parsing errors or nil start time" do
237
- @mailing.last_processing_time(@entity).should be_nil
238
- @mailing.next_processing_time(@entity).should be_nil
241
+ expect(@mailing.last_processing_time(@entity)).to be_nil
242
+ expect(@mailing.next_processing_time(@entity)).to be_nil
239
243
 
240
244
  Timecop.freeze @entity.created_at
241
245
  @mailing.run
242
246
 
243
- @mailing.last_processing_time(@entity).should be_nil
244
- @mailing.next_processing_time(@entity).should be_nil
247
+ expect(@mailing.last_processing_time(@entity)).to be_nil
248
+ expect(@mailing.next_processing_time(@entity)).to be_nil
245
249
  end
246
250
 
247
251
  after do
@@ -259,42 +263,42 @@ describe MailyHerald::PeriodicalMailing do
259
263
  end
260
264
 
261
265
  it "should not deliver" do
262
- MailyHerald::Subscription.count.should eq(0)
263
- MailyHerald::Log.count.should eq(0)
266
+ expect(MailyHerald::Subscription.count).to eq(0)
267
+ expect(MailyHerald::Log.count).to eq(0)
264
268
 
265
269
  Timecop.freeze @entity.created_at
266
270
 
267
271
  @mailing.run
268
272
 
269
- MailyHerald::Subscription.count.should eq(0)
270
- MailyHerald::Log.count.should eq(0)
273
+ expect(MailyHerald::Subscription.count).to eq(0)
274
+ expect(MailyHerald::Log.count).to eq(0)
271
275
  end
272
276
 
273
277
  it "should not deliver individual mailing" do
274
- MailyHerald::Subscription.count.should eq(0)
275
- MailyHerald::Log.count.should eq(0)
278
+ expect(MailyHerald::Subscription.count).to eq(0)
279
+ expect(MailyHerald::Log.count).to eq(0)
276
280
 
277
281
  Timecop.freeze @entity.created_at
278
282
 
279
- @mailing.deliver_to @entity
283
+ expect{ @mailing.deliver_to @entity }.to raise_error(NoMethodError)
280
284
 
281
- MailyHerald::Subscription.count.should eq(0)
282
- MailyHerald::Log.count.should eq(0)
285
+ expect(MailyHerald::Subscription.count).to eq(0)
286
+ expect(MailyHerald::Log.count).to eq(0)
283
287
  end
284
288
 
285
289
  it "should deliver with subscription override" do
286
- MailyHerald::Subscription.count.should eq(0)
287
- MailyHerald::Log.count.should eq(0)
290
+ expect(MailyHerald::Subscription.count).to eq(0)
291
+ expect(MailyHerald::Log.count).to eq(0)
288
292
 
289
293
  @mailing.update_attribute(:override_subscription, true)
290
- MailyHerald::Log.scheduled.count.should eq(1)
294
+ expect(MailyHerald::Log.scheduled.count).to eq(1)
291
295
 
292
296
  Timecop.freeze @entity.created_at
293
297
 
294
298
  @mailing.run
295
299
 
296
- MailyHerald::Subscription.count.should eq(0)
297
- MailyHerald::Log.delivered.count.should eq(1)
300
+ expect(MailyHerald::Subscription.count).to eq(0)
301
+ expect(MailyHerald::Log.delivered.count).to eq(1)
298
302
  end
299
303
  end
300
304
 
@@ -305,15 +309,16 @@ describe MailyHerald::PeriodicalMailing do
305
309
  end
306
310
 
307
311
  it "should check mailing conditions" do
308
- MailyHerald::Subscription.count.should eq(1)
309
- MailyHerald::Log.delivered.count.should eq(0)
312
+ expect(MailyHerald::Subscription.count).to eq(1)
313
+ expect(MailyHerald::Log.delivered.count).to eq(0)
310
314
 
311
315
  Timecop.freeze @entity.created_at
312
316
 
313
317
  @mailing.run
314
318
 
315
- MailyHerald::Subscription.count.should eq(1)
316
- MailyHerald::Log.delivered.count.should eq(1)
319
+ expect(MailyHerald::Subscription.count).to eq(1)
320
+ expect(MailyHerald::Log.delivered.count).to eq(1)
321
+ expect(@mailing.schedule_for(@entity)).not_to be_nil
317
322
 
318
323
  @entity.update_attribute(:weekly_notifications, false)
319
324
  @entity.save
@@ -322,9 +327,10 @@ describe MailyHerald::PeriodicalMailing do
322
327
 
323
328
  @mailing.run
324
329
 
325
- MailyHerald::Subscription.count.should eq(1)
326
- MailyHerald::Log.delivered.count.should eq(1)
327
- MailyHerald::Log.skipped.count.should eq(1)
330
+ expect(MailyHerald::Subscription.count).to eq(1)
331
+ expect(MailyHerald::Log.delivered.count).to eq(1)
332
+ expect(MailyHerald::Log.skipped.count).to eq(1)
333
+ expect(@mailing.schedule_for(@entity)).not_to be_nil
328
334
 
329
335
  @entity.update_attribute(:weekly_notifications, true)
330
336
 
@@ -332,8 +338,68 @@ describe MailyHerald::PeriodicalMailing do
332
338
 
333
339
  @mailing.run
334
340
 
335
- MailyHerald::Subscription.count.should eq(1)
336
- MailyHerald::Log.delivered.count.should eq(2)
341
+ expect(MailyHerald::Subscription.count).to eq(1)
342
+ expect(MailyHerald::Log.delivered.count).to eq(2)
343
+ end
344
+ end
345
+
346
+ describe "general scheduling" do
347
+ before(:each) do
348
+ @entity = FactoryGirl.create :user
349
+
350
+ @mailing = MailyHerald.periodical_mailing(:general_scheduling_mailing) do |mailing|
351
+ mailing.enable
352
+ mailing.list = :generic_list
353
+ mailing.subject = "Test mailing"
354
+ mailing.start_at = Time.now.to_s
355
+ mailing.period = 1.day
356
+ mailing.template = "User name: {{user.name}}."
357
+ end
358
+
359
+ expect(@mailing).to be_valid
360
+ expect(@mailing).to be_persisted
361
+ expect(@mailing).to be_enabled
362
+ end
363
+
364
+ after(:each) do
365
+ @mailing.destroy
366
+ end
367
+
368
+ it "should detect individual/general scheduling properly" do
369
+ expect(@mailing.individual_scheduling?).to be_falsy
370
+
371
+ @mailing.start_at = "user.created_at"
372
+ expect(@mailing.individual_scheduling?).to be_truthy
373
+ end
374
+
375
+ it "should create schedules for the next period" do
376
+ schedule = @mailing.schedule_for(@entity)
377
+ expect(schedule).to be_nil
378
+
379
+ time = Time.now - 5.hours
380
+ @mailing.start_at = time
381
+ @mailing.save!
382
+
383
+ @list.subscribe!(@entity)
384
+
385
+ schedule = @mailing.schedule_for(@entity)
386
+ expect(schedule.processing_at.to_i).not_to eq(time.to_i)
387
+ expect(schedule.processing_at.to_i).to eq((time + @mailing.period).to_i)
388
+ end
389
+
390
+ it "should create schedules for the first period" do
391
+ schedule = @mailing.schedule_for(@entity)
392
+ expect(schedule).to be_nil
393
+
394
+ time = Time.now + 5.hours
395
+ @mailing.start_at = time
396
+ @mailing.save!
397
+
398
+ @list.subscribe!(@entity)
399
+
400
+ schedule = @mailing.schedule_for(@entity)
401
+ expect(schedule.processing_at.to_i).to eq(time.to_i)
402
+ expect(schedule.processing_at.to_i).not_to eq((time + @mailing.period).to_i)
337
403
  end
338
404
  end
339
405
  end
@@ -9,10 +9,10 @@ describe MailyHerald::SequenceMailing do
9
9
  describe "Validations" do
10
10
  it do
11
11
  @mailing.absolute_delay = nil
12
- @mailing.should_not be_valid
12
+ expect(@mailing).not_to be_valid
13
13
 
14
14
  @mailing.absolute_delay = ""
15
- @mailing.should_not be_valid
15
+ expect(@mailing).not_to be_valid
16
16
  end
17
17
  end
18
18
  end
@@ -3,13 +3,13 @@ require 'spec_helper'
3
3
  describe MailyHerald::Sequence do
4
4
  before(:each) do
5
5
  @sequence = MailyHerald.sequence(:newsletters)
6
- @sequence.should be_a MailyHerald::Sequence
7
- @sequence.should_not be_a_new_record
8
- @sequence.start_at.should eq("user.created_at")
9
- @sequence.mailings.length.should eq(3)
6
+ expect(@sequence).to be_a MailyHerald::Sequence
7
+ expect(@sequence).not_to be_a_new_record
8
+ expect(@sequence.start_at).to eq("user.created_at")
9
+ expect(@sequence.mailings.length).to eq(3)
10
10
 
11
11
  @list = @sequence.list
12
- @list.name.should eq "generic_list"
12
+ expect(@list.name).to eq "generic_list"
13
13
  end
14
14
 
15
15
  after(:all) do
@@ -24,19 +24,19 @@ describe MailyHerald::Sequence do
24
24
 
25
25
  it "should find or initialize sequence subscription" do
26
26
  subscription = @sequence.subscription_for @entity
27
- subscription.should be_valid
28
- subscription.should_not be_a_new_record
29
- subscription.should be_a(MailyHerald::Subscription)
30
- subscription.should be_active
27
+ expect(subscription).to be_valid
28
+ expect(subscription).not_to be_a_new_record
29
+ expect(subscription).to be_kind_of(MailyHerald::Subscription)
30
+ expect(subscription).to be_active
31
31
  end
32
32
 
33
33
  it "should find or initialize sequence subscription via mailing" do
34
34
  subscription = @sequence.mailings.first.subscription_for @entity
35
- subscription.should be_valid
36
- subscription.should_not be_a_new_record
37
- subscription.should be_a(MailyHerald::Subscription)
38
- subscription.should eq(@sequence.subscription_for(@entity))
39
- subscription.should be_active
35
+ expect(subscription).to be_valid
36
+ expect(subscription).not_to be_a_new_record
37
+ expect(subscription).to be_kind_of(MailyHerald::Subscription)
38
+ expect(subscription).to eq(@sequence.subscription_for(@entity))
39
+ expect(subscription).to be_active
40
40
  end
41
41
  end
42
42
 
@@ -81,20 +81,25 @@ describe MailyHerald::Sequence do
81
81
  end
82
82
 
83
83
  it "should parse start_var" do
84
- @entity.should be_a(User)
85
- @sequence.processed_logs(@entity).should be_empty
86
- @sequence.next_processing_time(@entity).should be_a(Time)
84
+ expect(@entity).to be_a(User)
85
+ expect(@sequence.processed_logs(@entity)).to be_empty
86
+ expect(@sequence.next_processing_time(@entity)).to be_kind_of(Time)
87
87
  end
88
88
 
89
- it "should use absolute start date if provided and greater that evaluated start date" do
90
- @entity.should be_a(User)
89
+ it "should use absolute start date if provided and greater than evaluated start date" do
90
+ expect(@entity).to be_kind_of(User)
91
91
  time = (@entity.created_at + rand(100).days + rand(24).hours + rand(60).minutes).round
92
92
  @sequence.start_at = time.to_s
93
- @sequence.save
94
- @sequence.next_processing_time(@entity).should be_a(Time)
95
- @sequence.next_processing_time(@entity).should eq(time + @sequence.mailings.first.absolute_delay)
93
+ expect(@sequence.has_start_at_proc?).to be_falsey
94
+ expect(@sequence.start_at_changed?).to be_truthy
95
+ @sequence.save!
96
+ expect(Time.parse(@sequence.start_at).to_i).to eq(time.to_i)
97
+ expect(@sequence.next_processing_time(@entity)).to be_kind_of(Time)
98
+ expect(@sequence.next_processing_time(@entity)).to eq(time + @sequence.mailings.first.absolute_delay)
96
99
 
97
100
  @subscription = @sequence.subscription_for(@entity)
101
+ expect(@subscription).to be_active
102
+ expect(@sequence.processed_mailings(@entity)).to be_empty
98
103
  end
99
104
  end
100
105
 
@@ -113,210 +118,216 @@ describe MailyHerald::Sequence do
113
118
  end
114
119
 
115
120
  it "should deliver mailings with delays" do
116
- @sequence.mailings.length.should eq(3)
117
- #@sequence.start.should be_nil
118
-
119
- @sequence.processed_mailings(@entity).length.should eq(0)
120
- @sequence.pending_mailings(@entity).length.should eq(@sequence.mailings.length)
121
- @sequence.next_mailing(@entity).absolute_delay.should_not eq(0)
122
- @sequence.next_processing_time(@entity).round.should eq((@entity.created_at + @sequence.mailings.first.absolute_delay).round)
123
- @subscription.should_not be_a_new_record
124
- @subscription.should be_active
125
- #@subscription.should be_processable
126
- @subscription.should_not be_a_new_record
121
+ expect(@sequence.mailings.length).to eq(3)
122
+ #@sequence.start).to be_nil
123
+
124
+ expect(@sequence.processed_mailings(@entity).length).to eq(0)
125
+ expect(@sequence.pending_mailings(@entity).length).to eq(@sequence.mailings.length)
126
+ expect(@sequence.next_mailing(@entity).absolute_delay).not_to eq(0)
127
+ expect(@sequence.next_processing_time(@entity).round).to eq((@entity.created_at + @sequence.mailings.first.absolute_delay).round)
128
+ expect(@subscription).not_to be_a_new_record
129
+ expect(@subscription).to be_active
130
+ #@subscription).to be_processable
131
+ expect(@subscription).not_to be_a_new_record
132
+
133
+ schedule = @sequence.schedule_for(@entity)
134
+ expect(schedule).to be_a(MailyHerald::Log)
135
+ expect(schedule.processing_at.round).to eq((@entity.created_at + @sequence.mailings.first.absolute_delay).round)
127
136
 
128
137
  Timecop.freeze @entity.created_at
129
138
 
130
139
  @sequence.run
131
140
 
132
- MailyHerald::Subscription.count.should eq(1)
133
- MailyHerald::Log.delivered.count.should eq(0)
141
+ expect(MailyHerald::Subscription.count).to eq(1)
142
+ expect(MailyHerald::Log.delivered.count).to eq(0)
134
143
 
135
144
  Timecop.freeze @entity.created_at + @sequence.mailings.first.absolute_delay
136
145
 
137
146
  @sequence.run
138
147
 
139
- MailyHerald::Subscription.count.should eq(1)
140
- MailyHerald::Log.delivered.count.should eq(1)
148
+ expect(MailyHerald::Subscription.count).to eq(1)
149
+ schedule.reload
150
+ expect(schedule.status).to eq(:delivered)
151
+ expect(MailyHerald::Log.delivered.count).to eq(1)
141
152
 
142
- @sequence.processed_mailings(@entity).length.should eq(1)
143
- @sequence.pending_mailings(@entity).length.should eq(@sequence.mailings.length - 1)
144
- @sequence.pending_mailings(@entity).first.should eq(@sequence.mailings[1])
153
+ expect(@sequence.processed_mailings(@entity).length).to eq(1)
154
+ expect(@sequence.pending_mailings(@entity).length).to eq(@sequence.mailings.length - 1)
155
+ expect(@sequence.pending_mailings(@entity).first).to eq(@sequence.mailings[1])
145
156
 
146
- @sequence.last_processed_mailing(@entity).should eq @sequence.mailings.first
157
+ expect(@sequence.last_processed_mailing(@entity)).to eq @sequence.mailings.first
147
158
  log = @sequence.mailing_processing_log_for(@entity, @sequence.mailings.first)
148
- log.processing_at.to_i.should eq (@entity.created_at + @sequence.mailings.first.absolute_delay).to_i
159
+ expect(log.processing_at.to_i).to eq (@entity.created_at + @sequence.mailings.first.absolute_delay).to_i
149
160
 
150
161
  Timecop.freeze @entity.created_at + (@sequence.mailings[0].absolute_delay + @sequence.mailings[1].absolute_delay)/2.0
151
162
 
152
163
  @sequence.run
153
164
 
154
- MailyHerald::Subscription.count.should eq(1)
155
- MailyHerald::Log.delivered.count.should eq(1)
165
+ expect(MailyHerald::Subscription.count).to eq(1)
166
+ expect(MailyHerald::Log.delivered.count).to eq(1)
156
167
 
157
168
  Timecop.freeze @entity.created_at + @sequence.mailings[1].absolute_delay
158
169
 
159
170
  @sequence.run
160
171
 
161
- MailyHerald::Subscription.count.should eq(1)
162
- MailyHerald::Log.delivered.count.should eq(2)
172
+ expect(MailyHerald::Subscription.count).to eq(1)
173
+ expect(MailyHerald::Log.delivered.count).to eq(2)
163
174
 
164
175
  log = @sequence.mailing_processing_log_for(@entity, @sequence.mailings.first)
165
- log.should be_a(MailyHerald::Log)
166
- log.entity.should eq(@entity)
176
+ expect(log).to be_kind_of(MailyHerald::Log)
177
+ expect(log.entity).to eq(@entity)
167
178
 
168
179
  log = @sequence.mailing_processing_log_for(@entity, @sequence.mailings[1])
169
- log.should be_a(MailyHerald::Log)
170
- log.entity.should eq(@entity)
171
- log.entity_email.should eq(@entity.email)
180
+ expect(log).to be_kind_of(MailyHerald::Log)
181
+ expect(log.entity).to eq(@entity)
182
+ expect(log.entity_email).to eq(@entity.email)
172
183
  end
173
184
 
174
185
  it "should handle processing with start date evaluated to the past date" do
175
- @sequence.mailings.length.should eq(3)
176
- #@sequence.start.should be_nil
186
+ expect(@sequence.mailings.length).to eq(3)
187
+ #expect(@sequence.start).to be_nil
177
188
 
178
189
  start_at = @entity.created_at.round + 1.year
179
190
 
180
- @sequence.processed_mailings(@entity).length.should eq(0)
181
- @sequence.pending_mailings(@entity).length.should eq(@sequence.mailings.length)
182
- @sequence.next_mailing(@entity).absolute_delay.should_not eq(0)
183
- @sequence.next_processing_time(@entity).round.should eq((@entity.created_at + @sequence.mailings.first.absolute_delay).round)
191
+ expect(@sequence.processed_mailings(@entity).length).to eq(0)
192
+ expect(@sequence.pending_mailings(@entity).length).to eq(@sequence.mailings.length)
193
+ expect(@sequence.next_mailing(@entity).absolute_delay).not_to eq(0)
194
+ expect(@sequence.next_processing_time(@entity).round).to eq((@entity.created_at + @sequence.mailings.first.absolute_delay).round)
184
195
 
185
196
  Timecop.freeze start_at
186
197
 
187
198
  @sequence.run
188
199
 
189
- MailyHerald::Subscription.count.should eq(1)
190
- MailyHerald::Log.delivered.count.should eq(1)
200
+ expect(MailyHerald::Subscription.count).to eq(1)
201
+ expect(MailyHerald::Log.delivered.count).to eq(1)
191
202
 
192
203
  Timecop.freeze start_at + 1
193
204
 
194
205
  @sequence.run
195
206
 
196
- MailyHerald::Subscription.count.should eq(1)
197
- MailyHerald::Log.delivered.count.should eq(1)
207
+ expect(MailyHerald::Subscription.count).to eq(1)
208
+ expect(MailyHerald::Log.delivered.count).to eq(1)
198
209
 
199
- @sequence.next_processing_time(@entity).to_i.should eq((start_at - @sequence.mailings.first.absolute_delay + @sequence.pending_mailings(@entity).first.absolute_delay).to_i)
210
+ expect(@sequence.next_processing_time(@entity).to_i).to eq((start_at - @sequence.mailings.first.absolute_delay + @sequence.pending_mailings(@entity).first.absolute_delay).to_i)
200
211
  Timecop.freeze start_at - @sequence.mailings.first.absolute_delay + @sequence.pending_mailings(@entity).first.absolute_delay
201
212
 
202
213
  @sequence.run
203
214
 
204
- MailyHerald::Subscription.count.should eq(1)
205
- MailyHerald::Log.delivered.count.should eq(2)
215
+ expect(MailyHerald::Subscription.count).to eq(1)
216
+ expect(MailyHerald::Log.delivered.count).to eq(2)
206
217
  end
207
218
 
208
219
  it "should calculate delivery times relatively based on existing logs" do
209
- @sequence.mailings.length.should eq(3)
210
- #@sequence.start.should be_nil
220
+ expect(@sequence.mailings.length).to eq(3)
221
+ #expect(@sequence.start).to be_nil
211
222
 
212
223
  Timecop.freeze @entity.created_at + @sequence.mailings[0].absolute_delay
213
224
 
214
225
  @sequence.run
215
226
 
216
- MailyHerald::Log.delivered.count.should eq(1)
227
+ expect(MailyHerald::Log.delivered.count).to eq(1)
217
228
 
218
229
  Timecop.freeze @entity.created_at + @sequence.mailings[2].absolute_delay
219
230
 
220
231
  @sequence.run
221
232
  @sequence.run
222
233
 
223
- MailyHerald::Log.delivered.count.should eq(2)
234
+ expect(MailyHerald::Log.delivered.count).to eq(2)
224
235
 
225
236
  Timecop.freeze @entity.created_at + @sequence.mailings[2].absolute_delay + (@sequence.mailings[2].absolute_delay - @sequence.mailings[1].absolute_delay)
226
237
 
227
238
  @sequence.run
228
239
 
229
- MailyHerald::Log.delivered.count.should eq(3)
240
+ expect(MailyHerald::Log.delivered.count).to eq(3)
230
241
  end
231
242
 
232
243
  it "should skip disabled mailings and go on with processing" do
233
- @sequence.mailings.length.should eq(3)
234
- #@sequence.start.should be_nil
235
- @sequence.should be_enabled
244
+ expect(@sequence.mailings.length).to eq(3)
245
+ #expect(@sequence.start).to be_nil
246
+ expect(@sequence).to be_enabled
236
247
 
237
- @sequence.mailings[0].should be_enabled
238
- @sequence.mailings[1].should be_enabled
239
- @sequence.mailings[2].should be_enabled
248
+ expect(@sequence.mailings[0]).to be_enabled
249
+ expect(@sequence.mailings[1]).to be_enabled
250
+ expect(@sequence.mailings[2]).to be_enabled
240
251
 
241
252
  @sequence.mailings[1].disable!
242
- @sequence.mailings[1].should_not be_enabled
253
+ expect(@sequence.mailings[1]).not_to be_enabled
243
254
 
244
- @sequence.pending_mailings(@entity).first.should eq(@sequence.mailings.first)
245
- @sequence.pending_mailings(@entity).first.should be_enabled
255
+ expect(@sequence.pending_mailings(@entity).first).to eq(@sequence.mailings.first)
256
+ expect(@sequence.pending_mailings(@entity).first).to be_enabled
246
257
 
247
258
  Timecop.freeze @entity.created_at + @sequence.pending_mailings(@entity).first.absolute_delay
248
259
 
249
260
  @sequence.run
250
261
 
251
- MailyHerald::Log.delivered.count.should eq(1)
252
- @sequence.processed_mailings(@entity).length.should eq(1)
262
+ expect(MailyHerald::Log.delivered.count).to eq(1)
263
+ expect(@sequence.processed_mailings(@entity).length).to eq(1)
253
264
 
254
- @sequence.pending_mailings(@entity).should_not include(@sequence.mailings[1])
255
- @sequence.next_mailing(@entity).should eq(@sequence.mailings[2])
265
+ expect(@sequence.pending_mailings(@entity)).not_to include(@sequence.mailings[1])
266
+ expect(@sequence.next_mailing(@entity)).to eq(@sequence.mailings[2])
256
267
 
257
268
  Timecop.freeze @entity.created_at + @sequence.mailings[2].absolute_delay
258
269
 
259
270
  @sequence.run
260
271
 
261
- MailyHerald::Log.delivered.count.should eq(2)
262
- @sequence.pending_mailings(@entity).should be_empty
272
+ expect(MailyHerald::Log.delivered.count).to eq(2)
273
+ expect(@sequence.pending_mailings(@entity)).to be_empty
263
274
  end
264
275
 
265
276
  it "should skip mailings with unmet conditions and create logs for them" do
266
277
  @sequence.mailings[1].update_attribute(:conditions, "false")
267
278
 
268
- @sequence.pending_mailings(@entity).first.should eq(@sequence.mailings.first)
279
+ expect(@sequence.pending_mailings(@entity).first).to eq(@sequence.mailings.first)
269
280
  Timecop.freeze @entity.created_at + @sequence.pending_mailings(@entity).first.absolute_delay
270
281
  @sequence.run
271
- MailyHerald::Log.processed.count.should eq(1)
272
- MailyHerald::Log.delivered.count.should eq(1)
273
- MailyHerald::Log.skipped.count.should eq(0)
274
- MailyHerald::Log.error.count.should eq(0)
282
+ expect(MailyHerald::Log.processed.count).to eq(1)
283
+ expect(MailyHerald::Log.delivered.count).to eq(1)
284
+ expect(MailyHerald::Log.skipped.count).to eq(0)
285
+ expect(MailyHerald::Log.error.count).to eq(0)
275
286
 
276
- @sequence.pending_mailings(@entity).first.should eq(@sequence.mailings[1])
287
+ expect(@sequence.pending_mailings(@entity).first).to eq(@sequence.mailings[1])
277
288
  Timecop.freeze @entity.created_at + @sequence.pending_mailings(@entity).first.absolute_delay
278
289
  @sequence.run
279
- MailyHerald::Log.processed.count.should eq(2)
280
- MailyHerald::Log.delivered.count.should eq(1)
281
- MailyHerald::Log.skipped.count.should eq(1)
282
- MailyHerald::Log.error.count.should eq(0)
290
+ expect(MailyHerald::Log.processed.count).to eq(2)
291
+ expect(MailyHerald::Log.delivered.count).to eq(1)
292
+ expect(MailyHerald::Log.skipped.count).to eq(1)
293
+ expect(MailyHerald::Log.error.count).to eq(0)
283
294
 
284
- @sequence.pending_mailings(@entity).first.should eq(@sequence.mailings[2])
295
+ expect(@sequence.pending_mailings(@entity).first).to eq(@sequence.mailings[2])
285
296
  Timecop.freeze @entity.created_at + @sequence.pending_mailings(@entity).first.absolute_delay
286
297
  @sequence.run
287
- MailyHerald::Log.processed.count.should eq(3)
288
- MailyHerald::Log.delivered.count.should eq(2)
289
- MailyHerald::Log.skipped.count.should eq(1)
290
- MailyHerald::Log.error.count.should eq(0)
298
+ expect(MailyHerald::Log.processed.count).to eq(3)
299
+ expect(MailyHerald::Log.delivered.count).to eq(2)
300
+ expect(MailyHerald::Log.skipped.count).to eq(1)
301
+ expect(MailyHerald::Log.error.count).to eq(0)
291
302
  end
292
303
 
293
304
  pending "should skip mailings with errors and create logs for them" do
294
305
  @sequence.mailings[1].update_attribute(:template, "foo {{error =! here bar")
295
306
 
296
- @sequence.pending_mailings(@entity).first.should eq(@sequence.mailings.first)
297
- @sequence.processable?(@entity).should be_truthy
307
+ expect(@sequence.pending_mailings(@entity).first).to eq(@sequence.mailings.first)
308
+ expect(@sequence.processable?(@entity)).to be_truthy
298
309
  Timecop.freeze @entity.created_at + @sequence.pending_mailings(@entity).first.absolute_delay
299
310
  @sequence.run
300
- MailyHerald::Log.processed.count.should eq(1)
301
- MailyHerald::Log.delivered.count.should eq(1)
302
- MailyHerald::Log.skipped.count.should eq(0)
303
- MailyHerald::Log.error.count.should eq(0)
311
+ expect(MailyHerald::Log.processed.count).to eq(1)
312
+ expect(MailyHerald::Log.delivered.count).to eq(1)
313
+ expect(MailyHerald::Log.skipped.count).to eq(0)
314
+ expect(MailyHerald::Log.error.count).to eq(0)
304
315
 
305
- @sequence.pending_mailings(@entity).first.should eq(@sequence.mailings[1])
316
+ expect(@sequence.pending_mailings(@entity).first).to eq(@sequence.mailings[1])
306
317
  Timecop.freeze @entity.created_at + @sequence.pending_mailings(@entity).first.absolute_delay
307
318
  @sequence.run
308
- MailyHerald::Log.processed.count.should eq(2)
309
- MailyHerald::Log.delivered.count.should eq(1)
310
- MailyHerald::Log.skipped.count.should eq(0)
311
- MailyHerald::Log.error.count.should eq(1)
319
+ expect(MailyHerald::Log.processed.count).to eq(2)
320
+ expect(MailyHerald::Log.delivered.count).to eq(1)
321
+ expect(MailyHerald::Log.skipped.count).to eq(0)
322
+ expect(MailyHerald::Log.error.count).to eq(1)
312
323
 
313
- @sequence.pending_mailings(@entity).first.should eq(@sequence.mailings[2])
324
+ expect(@sequence.pending_mailings(@entity).first).to eq(@sequence.mailings[2])
314
325
  Timecop.freeze @entity.created_at + @sequence.pending_mailings(@entity).first.absolute_delay
315
326
  @sequence.run
316
- MailyHerald::Log.processed.count.should eq(3)
317
- MailyHerald::Log.delivered.count.should eq(2)
318
- MailyHerald::Log.skipped.count.should eq(0)
319
- MailyHerald::Log.error.count.should eq(1)
327
+ expect(MailyHerald::Log.processed.count).to eq(3)
328
+ expect(MailyHerald::Log.delivered.count).to eq(2)
329
+ expect(MailyHerald::Log.skipped.count).to eq(0)
330
+ expect(MailyHerald::Log.error.count).to eq(1)
320
331
  end
321
332
 
322
333
  end
@@ -334,36 +345,36 @@ describe MailyHerald::Sequence do
334
345
  end
335
346
 
336
347
  it "should handle start_var parsing errors or nil start time" do
337
- @sequence.start_at.should eq("")
348
+ expect(@sequence.start_at).to eq("")
338
349
  @sequence = @sequence.subscription_for @entity
339
- @sequence.last_processing_time(@entity).should be_nil
340
- @sequence.next_processing_time(@entity).should be_nil
350
+ expect(@sequence.last_processing_time(@entity)).to be_nil
351
+ expect(@sequence.next_processing_time(@entity)).to be_nil
341
352
 
342
353
  Timecop.freeze @entity.created_at
343
354
  @sequence.run
344
355
 
345
356
  @sequence = @sequence.subscription_for @entity
346
- @sequence.last_processing_time(@entity).should be_nil
347
- @sequence.next_processing_time(@entity).should be_nil
357
+ expect(@sequence.last_processing_time(@entity)).to be_nil
358
+ expect(@sequence.next_processing_time(@entity)).to be_nil
348
359
  end
349
360
 
350
361
  pending "should allow to set start date via text field" do
351
362
  datetime = "2013-01-01 10:11"
352
363
 
353
364
  @sequence.start_at = datetime
354
- @sequence.should be_valid
355
- @sequence.start_at.should eq(datetime)
365
+ expect(@sequence).to be_valid
366
+ expect(@sequence.start_at).to eq(datetime)
356
367
 
357
368
  @sequence.start_at = ""
358
- @sequence.should be_valid
369
+ expect(@sequence).to be_valid
359
370
  end
360
371
  end
361
372
 
362
373
  #describe "Without autosubscribe" do
363
374
  #before(:each) do
364
375
  #@sequence.update_attribute(:autosubscribe, false)
365
- #@sequence.should be_valid
366
- #@sequence.save.should be_truthy
376
+ #expect(@sequence).to be_valid
377
+ #expect(@sequence.save).to be_truthy
367
378
  #@entity = FactoryGirl.create :user
368
379
  #end
369
380
 
@@ -374,17 +385,17 @@ describe MailyHerald::Sequence do
374
385
  #it "should create inactive subscription" do
375
386
  #subscription = @sequence.subscription_for @entity
376
387
 
377
- #MailyHerald::MailingSubscription.count.should eq(0)
378
- #MailyHerald::SequenceSubscription.count.should eq(1)
379
- #MailyHerald::Log.count.should eq(0)
388
+ #expect(MailyHerald::MailingSubscription.count).to eq(0)
389
+ #expect(MailyHerald::SequenceSubscription.count).to eq(1)
390
+ #expect(MailyHerald::Log.count).to eq(0)
380
391
 
381
392
  #Timecop.freeze @entity.created_at
382
393
 
383
394
  #@sequence.run
384
395
 
385
- #MailyHerald::MailingSubscription.count.should eq(0)
386
- #MailyHerald::SequenceSubscription.count.should eq(1)
387
- #MailyHerald::Log.count.should eq(0)
396
+ #expect(MailyHerald::MailingSubscription.count).to eq(0)
397
+ #expect(MailyHerald::SequenceSubscription.count).to eq(1)
398
+ #expect(MailyHerald::Log.count).to eq(0)
388
399
  #end
389
400
  #end
390
401
 
@@ -400,30 +411,32 @@ describe MailyHerald::Sequence do
400
411
  it "should be able to override subscription" do
401
412
  subscription = @sequence.subscription_for @entity
402
413
 
403
- subscription.should be_active
414
+ expect(subscription).to be_active
404
415
 
405
416
  next_processing = @sequence.next_processing_time(@entity)
406
417
 
407
418
  subscription.deactivate!
408
- subscription.should_not be_active
419
+ expect(subscription).not_to be_active
409
420
 
410
- @sequence.logs(@entity).count.should eq(0)
411
- @sequence.last_processing_time(@entity).should be_nil
421
+ expect(@sequence.logs(@entity).count).to eq(0)
422
+ expect(@sequence.last_processing_time(@entity)).to be_nil
412
423
 
413
424
  Timecop.freeze next_processing
414
425
 
415
426
  @sequence.run
416
427
 
417
- @sequence.logs(@entity).count.should eq(0)
418
- @sequence.last_processing_time(@entity).should be_nil
428
+ expect(@sequence.logs(@entity).count).to eq(0)
429
+ expect(@sequence.last_processing_time(@entity)).to be_nil
419
430
 
420
431
  @sequence.update_attribute(:override_subscription, true)
421
432
 
422
433
  @sequence.run
423
434
 
424
- @sequence.logs(@entity).count.should eq(1)
425
- @sequence.last_processing_time(@entity).to_i.should eq(next_processing.to_i)
435
+ expect(@sequence.logs(@entity).count).to eq(1)
436
+ expect(@sequence.last_processing_time(@entity).to_i).to eq(next_processing.to_i)
426
437
  end
427
438
  end
428
439
 
440
+ pending "unprocessable mailings - postponing them"
441
+
429
442
  end