zendesk-ar_mailer 2.1.6 → 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,7 +44,7 @@ class ActionMailer::ARSendmail
44
44
  ##
45
45
  # The version of ActionMailer::ARSendmail you are running.
46
46
 
47
- VERSION = '2.1.5'
47
+ VERSION = '2.1.7'
48
48
 
49
49
  ##
50
50
  # Maximum number of times authentication will be consecutively retried
@@ -396,7 +396,7 @@ class ActionMailer::ARSendmail
396
396
  until emails.empty? do
397
397
  email = emails.shift
398
398
  if locking_enabled?
399
- next unless email.lock_with_expirey
399
+ next unless email.lock_with_expiry
400
400
  end
401
401
 
402
402
  begin
@@ -446,7 +446,7 @@ class ActionMailer::ARSendmail
446
446
  end
447
447
 
448
448
  def locking_enabled?
449
- @locking_enabled ||= ActionMailer::Base.email_class.instance_methods.include?('lock_with_expirey')
449
+ @locking_enabled ||= ActionMailer::Base.email_class.instance_methods.include?('lock_with_expiry')
450
450
  end
451
451
 
452
452
  ##
@@ -465,12 +465,20 @@ class ActionMailer::ARSendmail
465
465
  def find_emails
466
466
  options = { :conditions => ['last_send_attempt < ?', Time.now.to_i - 300] }
467
467
  options[:limit] = batch_size unless batch_size.nil?
468
- mail = ActionMailer::Base.email_class.find :all, options
468
+ mail = email_finder(options)
469
469
 
470
470
  log "found #{mail.length} emails to send"
471
471
  mail
472
472
  end
473
473
 
474
+ def email_finder(options)
475
+ if locking_enabled?
476
+ ActionMailer::Base.email_class.unlocked.all(options)
477
+ else
478
+ ActionMailer::Base.email_class.find(:all, options)
479
+ end
480
+ end
481
+
474
482
  ##
475
483
  # Installs signal handlers to gracefully exit.
476
484
 
@@ -526,7 +526,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
526
526
 
527
527
  def test_deliver_with_locking_acquired
528
528
  email = Email.create :mail => 'body', :to => 'to', :from => 'from'
529
- Email.any_instance.stubs(:lock_with_expirey).returns(true)
529
+ Email.any_instance.stubs(:lock_with_expiry).returns(true)
530
530
  Email.any_instance.expects(:unlock)
531
531
  assert_equal true, @sm.locking_enabled?
532
532
  out, err = capture_io do
@@ -538,7 +538,7 @@ Last send attempt: Thu Aug 10 11:40:05 %s 2006
538
538
 
539
539
  def test_deliver_with_locking_not_acquired
540
540
  email = Email.create :mail => 'body', :to => 'to', :from => 'from'
541
- Email.any_instance.stubs(:lock_with_expirey).returns(false)
541
+ Email.any_instance.stubs(:lock_with_expiry).returns(false)
542
542
  Email.any_instance.expects(:unlock).never
543
543
  assert_equal true, @sm.locking_enabled?
544
544
  out, err = capture_io do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk-ar_mailer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 6
10
- version: 2.1.6
9
+ - 7
10
+ version: 2.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Hodel
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-07-26 00:00:00 -07:00
20
+ date: 2010-08-24 00:00:00 -07:00
21
21
  default_executable: ar_sendmail
22
22
  dependencies: []
23
23