|
64 | 64 | expect(@cc.state).to eql(:retired) |
65 | 65 | @cc.re_activate |
66 | 66 | expect(@cc.state).to eql(:active) |
67 | | - |
| 67 | + |
68 | 68 | communication_channel_model(:path => "another_path@example.com") |
69 | 69 | expect(@cc.state).to eql(:unconfirmed) |
70 | 70 | @cc.retire |
|
89 | 89 | communication_channel_model |
90 | 90 | expect(@cc.confirmation_code).to eql('abc123') |
91 | 91 | end |
92 | | - |
| 92 | + |
93 | 93 | it "should be able to reset a confirmation code" do |
94 | 94 | communication_channel_model |
95 | 95 | old_cc = @cc.confirmation_code |
96 | 96 | @cc.set_confirmation_code(true) |
97 | 97 | expect(@cc.confirmation_code).not_to eql(old_cc) |
98 | 98 | end |
99 | | - |
| 99 | + |
100 | 100 | it "should use a 15-digit confirmation code for default or email path_type settings" do |
101 | 101 | communication_channel_model |
102 | 102 | expect(@cc.path_type).to eql('email') |
103 | 103 | expect(@cc.confirmation_code.size).to eql(25) |
104 | 104 | end |
105 | | - |
| 105 | + |
106 | 106 | it "should use a 4-digit confirmation_code for settings other than email" do |
107 | 107 | communication_channel_model |
108 | 108 | @cc.path_type = 'sms' |
109 | 109 | @cc.set_confirmation_code(true) |
110 | 110 | expect(@cc.confirmation_code.size).to eql(4) |
111 | 111 | end |
112 | | - |
| 112 | + |
113 | 113 | it "should default the path type to email" do |
114 | 114 | communication_channel_model |
115 | 115 | expect(@cc.path_type).to eql('email') |
|
134 | 134 | @cc.path_type = 'not valid'; @cc.save |
135 | 135 | expect(@cc.path_type).to eql('email') |
136 | 136 | end |
137 | | - |
| 137 | + |
138 | 138 | it "should act as list" do |
139 | 139 | expect(CommunicationChannel).to be_respond_to(:acts_as_list) |
140 | 140 | end |
141 | | - |
| 141 | + |
142 | 142 | it "should scope the list to the user" do |
143 | 143 | @u1 = User.create! |
144 | 144 | @u2 = User.create! |
|
161 | 161 | @cc3.reload |
162 | 162 | expect(@cc3.position).to eql(1) |
163 | 163 | end |
164 | | - |
| 164 | + |
165 | 165 | context "can_notify?" do |
166 | 166 | it "should normally be able to be used" do |
167 | 167 | communication_channel_model |
168 | 168 | expect(@communication_channel).to be_can_notify |
169 | 169 | end |
170 | | - |
| 170 | + |
171 | 171 | it "should not be able to be used if it has a policy to not use it" do |
172 | 172 | communication_channel_model |
173 | 173 | notification_policy_model(:frequency => "never", :communication_channel => @communication_channel) |
|
298 | 298 | path: path, |
299 | 299 | timestamp: nil, |
300 | 300 | details: nil, |
| 301 | + permanent_bounce: true, |
301 | 302 | suppression_bounce: false |
302 | 303 | ) |
303 | 304 | end |
|
315 | 316 | cc = communication_channel_model( |
316 | 317 | path: 'foo@bar.edu', |
317 | 318 | last_bounce_at: '2015-01-01T01:01:01.000Z', |
318 | | - last_suppression_bounce_at: '2015-03-03T03:03:03.000Z' |
| 319 | + last_suppression_bounce_at: '2015-03-03T03:03:03.000Z', |
| 320 | + last_transient_bounce_at: '2015-04-04T04:04:04.000Z' |
319 | 321 | ) |
320 | 322 | CommunicationChannel.bounce_for_path( |
321 | 323 | path: 'foo@bar.edu', |
322 | 324 | timestamp: '2015-02-02T02:02:02.000Z', |
323 | 325 | details: nil, |
| 326 | + permanent_bounce: true, |
324 | 327 | suppression_bounce: false |
325 | 328 | ) |
326 | 329 |
|
327 | 330 | cc.reload |
328 | 331 | expect(cc.last_bounce_at).to eq('2015-02-02T02:02:02.000Z') |
329 | 332 | expect(cc.last_suppression_bounce_at).to eq('2015-03-03T03:03:03.000Z') |
| 333 | + expect(cc.last_transient_bounce_at).to eq('2015-04-04T04:04:04.000Z') |
| 334 | + end |
| 335 | + |
| 336 | + it "stores the date of the last soft bounce bounce" do |
| 337 | + cc = communication_channel_model( |
| 338 | + path: 'foo@bar.edu', |
| 339 | + last_bounce_at: '2015-01-01T01:01:01.000Z', |
| 340 | + last_suppression_bounce_at: '2015-03-03T03:03:03.000Z', |
| 341 | + last_transient_bounce_at: '2015-04-04T04:04:04.000Z' |
| 342 | + ) |
| 343 | + CommunicationChannel.bounce_for_path( |
| 344 | + path: 'foo@bar.edu', |
| 345 | + timestamp: '2015-05-05T05:05:05.000Z', |
| 346 | + details: nil, |
| 347 | + permanent_bounce: false, |
| 348 | + suppression_bounce: false |
| 349 | + ) |
| 350 | + |
| 351 | + cc.reload |
| 352 | + expect(cc.last_bounce_at).to eq('2015-01-01T01:01:01.000Z') |
| 353 | + expect(cc.last_suppression_bounce_at).to eq('2015-03-03T03:03:03.000Z') |
| 354 | + expect(cc.last_transient_bounce_at).to eq('2015-05-05T05:05:05.000Z') |
330 | 355 | end |
331 | 356 |
|
332 | 357 | it "stores the date of the last suppression bounce" do |
333 | 358 | cc = communication_channel_model( |
334 | 359 | path: 'foo@bar.edu', |
335 | 360 | last_bounce_at: '2015-01-01T01:01:01.000Z', |
336 | | - last_suppression_bounce_at: '2015-03-03T03:03:03.000Z' |
| 361 | + last_suppression_bounce_at: '2015-03-03T03:03:03.000Z', |
| 362 | + last_transient_bounce_at: '2015-04-04T04:04:04.000Z' |
337 | 363 | ) |
338 | 364 | CommunicationChannel.bounce_for_path( |
339 | 365 | path: 'foo@bar.edu', |
340 | 366 | timestamp: '2015-02-02T02:02:02.000Z', |
341 | 367 | details: nil, |
| 368 | + permanent_bounce: true, |
342 | 369 | suppression_bounce: true |
343 | 370 | ) |
344 | 371 |
|
345 | 372 | cc.reload |
346 | 373 | expect(cc.last_bounce_at).to eq('2015-01-01T01:01:01.000Z') |
347 | 374 | expect(cc.last_suppression_bounce_at).to eq('2015-02-02T02:02:02.000Z') |
| 375 | + expect(cc.last_transient_bounce_at).to eq('2015-04-04T04:04:04.000Z') |
348 | 376 | end |
349 | 377 |
|
350 | 378 | it "stores the details of the last hard bounce" do |
|
353 | 381 | path: 'foo@bar.edu', |
354 | 382 | timestamp: nil, |
355 | 383 | details: {'some' => 'details', 'foo' => 'bar'}, |
| 384 | + permanent_bounce: true, |
356 | 385 | suppression_bounce: false |
357 | 386 | ) |
358 | 387 |
|
359 | 388 | cc.reload |
360 | 389 | expect(cc.last_bounce_details).to eq('some' => 'details', 'foo' => 'bar') |
| 390 | + expect(cc.last_transient_bounce_details).to be_nil |
| 391 | + end |
| 392 | + |
| 393 | + it "stores the details of the last soft bounce" do |
| 394 | + cc = communication_channel_model(path: 'foo@bar.edu') |
| 395 | + CommunicationChannel.bounce_for_path( |
| 396 | + path: 'foo@bar.edu', |
| 397 | + timestamp: nil, |
| 398 | + details: {'some' => 'details', 'foo' => 'bar'}, |
| 399 | + permanent_bounce: false, |
| 400 | + suppression_bounce: false |
| 401 | + ) |
| 402 | + |
| 403 | + cc.reload |
| 404 | + expect(cc.last_transient_bounce_details).to eq('some' => 'details', 'foo' => 'bar') |
| 405 | + expect(cc.last_bounce_details).to be_nil |
361 | 406 | end |
362 | 407 |
|
363 | 408 | it "does not store the details of the last suppression bounce" do |
|
369 | 414 | path: 'foo@bar.edu', |
370 | 415 | timestamp: nil, |
371 | 416 | details: {'some' => 'details', 'foo' => 'bar'}, |
| 417 | + permanent_bounce: true, |
372 | 418 | suppression_bounce: true |
373 | 419 | ) |
374 | 420 |
|
375 | 421 | cc.reload |
376 | 422 | expect(cc.last_bounce_details).to eq('existing' => 'details') |
| 423 | + expect(cc.last_transient_bounce_details).to be_nil |
377 | 424 | end |
378 | 425 | end |
379 | 426 |
|
|
431 | 478 | path: path, |
432 | 479 | timestamp: nil, |
433 | 480 | details: nil, |
| 481 | + permanent_bounce: true, |
434 | 482 | suppression_bounce: false |
435 | 483 | ) |
436 | 484 | end |
|
0 commit comments