mail_manager 3.2.5 → 3.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -1
  3. data/app/controllers/mail_manager/bounces_controller.rb +13 -1
  4. data/app/controllers/mail_manager/contacts_controller.rb +1 -2
  5. data/app/controllers/mail_manager/mailings_controller.rb +2 -4
  6. data/app/controllers/mail_manager/subscriptions_controller.rb +0 -2
  7. data/app/models/mail_manager/bounce.rb +9 -7
  8. data/app/models/mail_manager/contactable_registry.rb +2 -1
  9. data/app/models/mail_manager/mailable.rb +11 -9
  10. data/app/models/mail_manager/mailer.rb +13 -5
  11. data/app/models/mail_manager/mailing.rb +13 -25
  12. data/app/models/mail_manager/mailing_list.rb +17 -0
  13. data/app/models/mail_manager/message.rb +12 -1
  14. data/app/models/mail_manager/subscription.rb +12 -0
  15. data/app/views/mail_manager/bounces/_email_parts.html.erb +3 -1
  16. data/app/views/mail_manager/bounces/index.html.erb +1 -1
  17. data/app/views/mail_manager/bounces/show.html.erb +2 -2
  18. data/app/views/mail_manager/contacts/_form.html.erb +1 -1
  19. data/app/views/mail_manager/mailings/index.html.erb +3 -3
  20. data/app/views/mail_manager/messages/index.html.erb +1 -1
  21. data/app/views/mail_manager/subscriptions/_subscriptions.html.erb +6 -3
  22. data/config/routes.rb +2 -2
  23. data/lib/delayed/status.rb +5 -2
  24. data/lib/delayed/status_job.rb +5 -21
  25. data/lib/delayed_overrides/job.rb +6 -0
  26. data/lib/mail_manager/engine.rb +23 -1
  27. data/lib/mail_manager/version.rb +1 -1
  28. data/mail_manager.gemspec +10 -3
  29. data/spec/test_app/Procfile +5 -3
  30. data/spec/test_app/config/mail_manager.yml +3 -0
  31. data/spec/test_app/features/contact_management.feature +7 -0
  32. data/spec/test_app/features/message_management.feature +8 -1
  33. data/spec/test_app/features/step_definitions/webrat_steps.rb +6 -2
  34. data/spec/test_app/lib/debugging.rb +2 -2
  35. data/spec/test_app/script/full_suite +7 -5
  36. data/spec/test_app/spec/controllers/mail_manager/bounces_controller_spec.rb +39 -0
  37. data/spec/test_app/spec/controllers/mail_manager/mailings_controller_spec.rb +12 -0
  38. data/spec/test_app/spec/models/mail_manager/bounce_spec.rb +31 -0
  39. data/spec/test_app/spec/models/mail_manager/engine_spec.rb +25 -0
  40. data/spec/test_app/spec/models/mail_manager/mailing_list_spec.rb +39 -0
  41. data/spec/test_app/spec/models/mail_manager/mailing_spec.rb +43 -1
  42. data/spec/test_app/spec/models/mail_manager/message_spec.rb +19 -0
  43. data/spec/test_app/spec/models/mail_manager/subscription_spec.rb +17 -0
  44. data/spec/test_app/spec/support/files/bounce-400.txt +73 -0
  45. data/spec/test_app/spec/support/files/bounce-500.txt +75 -0
  46. data/spec/test_app/spec/support/files/bounce-invalid-address.txt +73 -0
  47. data/spec/test_app/spec/support/files/bounce-invalid.txt +113 -0
  48. data/spec/test_app/spec/support/files/bounce-invalid2.txt +29 -0
  49. data/spec/test_app/spec/support/files/bounce-invalid3.txt +29 -0
  50. data/spec/test_app/spec/support/files/bounce-mail-box-full.txt +1178 -0
  51. data/spec/test_app/spec/support/files/bounce-over-quota.txt +1173 -0
  52. data/spec/test_app/spec/support/files/bounce-smtp-timeout.txt +73 -0
  53. data/spec/test_app/spec/support/files/bounce-unknown_domain.txt +73 -0
  54. data/spec/test_app/spec/support/files/mail_manager_empty_table_prefix.yml +85 -0
  55. data/spec/test_app/spec/support/files/mail_manager_use_generic_mailables.yml +86 -0
  56. metadata +36 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccad22ae4d5ef09bb078ef6918c254a617d4d9aa
4
- data.tar.gz: ce3cf0ed13df2688280109f5405d9087e57e9c53
3
+ metadata.gz: d5b18070eb704e09c4abee8c914aaa548deb43e6
4
+ data.tar.gz: 9b29f0f717833d1a4c3b8fa0d2858592b4823195
5
5
  SHA512:
6
- metadata.gz: f446fef7c05a8c08a88d0f3130c9f3350119ec00318a08b67ed4deeeed3a2f149e54b67b86b6265d5ec3c308f8871e204804d64390722be1c89f9689069e008a
7
- data.tar.gz: b6335b6e69e8092181034cbf16a227260aa43eadac08a9c827f8d8d2b87fd99b4aca2538c7ec6bb528ccd9f9552e3bee1acdb7da4c2de0444f7af07f7337f22f
6
+ metadata.gz: 18a71c74071f945dcfd0cf5590395f72648e82a13222abb83205702c32446de593dbe9a69d9d310dc8b2ae8e021aee3d6a61d850f050d2c4c6efb7829f16926e
7
+ data.tar.gz: 751c9ef49582c67528776bf9e0e573316e539a38382df09fd59e7a0ac272b98d661aded4c3bbab1ccfb4e4e1dbd5bd550bf1ed105ef0aca10a4ea9cdee4ac8e3
data/README.md CHANGED
@@ -5,7 +5,10 @@ The gem provides an interface to manage mailing lists, scheduling of email maili
5
5
 
6
6
  Also available as a stand alone application called [iReach](https://github.com/LoneStarInternet/iReach/releases) including the newsletter manager (newsletter template and elements manager, simple wysiwyg interface to create newsletters, and newsletter archive) and user access management. There is also the i_reach gem that ties mail_manager and newsletter together into one gem.
7
7
 
8
- See the latest docs at the [Homepage](http://ireachnews.com/mail_manager_documentation.html)
8
+ Online Documentation
9
+ --------------------
10
+ * [Homepage](http://ireachnews.com/mail_manager_documentation.html)
11
+ * [Changelog](http://www.ireachnews.com/index.html#changelog)
9
12
 
10
13
  Requirements
11
14
  ------------
@@ -9,11 +9,23 @@ module MailManager
9
9
  @bounces = Bounce.scoped
10
10
  @bounces = @bounces.by_mailing_id(@mailing.id) if @mailing.present?
11
11
  @bounces = @bounces.by_status(status) if status.present?
12
- @bounces = @bounces.paginate(:page => params[:page])
12
+ @bounces = @bounces.order("created_at desc").paginate(
13
+ :page => (params[:page] || 1)
14
+ )
13
15
  end
14
16
 
15
17
  def show
16
18
  end
19
+
20
+ def dismiss
21
+ @bounce.dismiss
22
+ redirect_to @bounce
23
+ end
24
+
25
+ def fail_address
26
+ @bounce.fail_address
27
+ redirect_to @bounce
28
+ end
17
29
 
18
30
  protected
19
31
 
@@ -1,8 +1,6 @@
1
1
  module MailManager
2
2
  class ContactsController < ::MailManager::ApplicationController
3
3
 
4
- skip_before_filter :authorize, only: [:subscribe,:double_opt_in,:thank_you]
5
-
6
4
  include DeleteableActions
7
5
 
8
6
  def subscribe
@@ -19,6 +17,7 @@ module MailManager
19
17
  end
20
18
 
21
19
  def thank_you
20
+ render layout: MailManager.public_layout
22
21
  end
23
22
 
24
23
  def double_opt_in
@@ -92,10 +92,8 @@ module MailManager
92
92
  end
93
93
 
94
94
  def get_mailables_for_select
95
- #@mailables_for_select = [['Choose Mailable', @mailable.is_a?(Mailable) ?
96
- # 'Mailable_new' : '']]+@mailables.collect{|mailable|
97
- # [mailable.name,"#{mailable.class.name}_#{mailable.id}"]}
98
- @mailables_for_select = @mailables.collect{|mailable|
95
+ @mailables_for_select = @mailables.sort{|a,b| b.created_at <=> a.created_at}.
96
+ collect{|mailable|
99
97
  [mailable.name,"#{mailable.class.name}_#{mailable.id}"]}
100
98
  end
101
99
  end
@@ -1,7 +1,5 @@
1
1
  module MailManager
2
2
  class SubscriptionsController < ::MailManager::ApplicationController
3
- skip_before_filter :authorize_resource
4
- skip_before_filter :load_resource
5
3
 
6
4
  # unsubscribes an email adress by a message's guid(sent in the link)
7
5
  def unsubscribe
@@ -22,7 +22,7 @@ module MailManager
22
22
  belongs_to :message, :class_name => 'MailManager::Message'
23
23
  belongs_to :mailing, :class_name => 'MailManager::Mailing', counter_cache: true
24
24
  include StatusHistory
25
- override_statuses(['needs_manual_intervention','unprocessed','dismissed','resolved','invalid'],'unprocessed')
25
+ override_statuses(['needs_manual_intervention','unprocessed','dismissed','resolved','invalid','removed','deferred'],'unprocessed')
26
26
  before_create :set_default_status
27
27
  #default_scope :order => "#{MailManager.table_prefix}contacts.last_name, #{MailManager.table_prefix}contacts.first_name, #{MailManager.table_prefix}contacts.email_address",
28
28
  # :joins =>
@@ -47,11 +47,11 @@ module MailManager
47
47
  change_status(:invalid)
48
48
  elsif delivery_error_code =~ /4\.\d\.\d/ || delivery_error_message.to_s =~ /quota/i
49
49
  update_attribute(:comments, delivery_error_message)
50
- change_status(:resolved)
50
+ change_status(:deferred)
51
51
  elsif delivery_error_code =~ /5\.\d\.\d/ && delivery_error_message.present?
52
52
  transaction do
53
53
  update_attribute(:comments, delivery_error_message)
54
- change_status(:resolved)
54
+ change_status(:removed)
55
55
  message.change_status(:failed)
56
56
  message.update_attribute(:result,"Failure Message from Bounce: #{delivery_error_message}")
57
57
  Subscription.fail_by_email_address(contact_email_address)
@@ -82,10 +82,12 @@ module MailManager
82
82
  raise "Status cannot be manually changed unless it needs manual intervention!" unless
83
83
  status.eql?('needs_manual_intervention')
84
84
  transaction do
85
- Subscription.fail_by_email_address(contact_email_address)
86
- message.result = message.result.to_s + "Failed by Administrator: (bounced, not auto resolved) "
87
- message.change_status(:failed)
88
- change_status(:resolved)
85
+ Subscription.fail_by_email_address(contact_email_address) if contact.present?
86
+ if message.present?
87
+ message.result = message.result.to_s + "Failed by Administrator: (bounced, not auto resolved) "
88
+ message.change_status(:failed)
89
+ end
90
+ change_status(:removed)
89
91
  end
90
92
  end
91
93
 
@@ -96,7 +96,8 @@ module MailManager
96
96
  end
97
97
 
98
98
  def subscribe(mailing_list, status='active')
99
- set_contactable_data && MailManager::Subscription.subscribe(contact,mailing_list, status)
99
+ set_contactable_data
100
+ MailManager::Subscription.subscribe(contact,mailing_list, status)
100
101
  end
101
102
 
102
103
  def unsubscribe(mailing_list)
@@ -1,14 +1,16 @@
1
1
  class MailManager::Mailable < ActiveRecord::Base
2
+ self.table_name = "#{MailManager.table_prefix}mailables"
2
3
  attr_accessible :name, :email_text, :email_html
3
4
  default_scope where(reusable: true)
4
5
  include MailManager::MailableRegistry::Mailable
5
6
  end
6
-
7
- MailManager::MailableRegistry.register('MailManager::Mailable',{
8
- :find_mailables => :all,
9
- :name => :name,
10
- :parts => [
11
- ['text/plain', :email_text],
12
- ['text/html', :email_html]
13
- ]
14
- })
7
+ if MailManager.register_generic_mailable
8
+ MailManager::MailableRegistry.register('MailManager::Mailable',{
9
+ :find_mailables => :all,
10
+ :name => :name,
11
+ :parts => [
12
+ ['text/plain', :email_text],
13
+ ['text/html', :email_html]
14
+ ]
15
+ })
16
+ end
@@ -202,26 +202,34 @@ module MailManager
202
202
  if(index % 4 == 2)
203
203
  image = Hash.new()
204
204
  image[:cid] = Base64.encode64(data).gsub(/\s*/,'').reverse[0..59]
205
- final_html << "cid:#{image[:cid]}"
205
+ if images.detect{|this_image| this_image[:cid].eql?(image[:cid])}
206
+ final_html << "cid:#{image[:cid]}"
207
+ next
208
+ end
206
209
  #only attach new images!
207
- next if images.detect{|this_image| this_image[:cid].eql?(image[:cid])}
208
210
  begin
209
211
  image[:content] = fetch(data)
210
212
  rescue => e
211
- image_errors += "Couldn't fetch url '#{data}'<!--, #{e.message} - #{e.backtrace.join("\n")}-->\n"
213
+ image_errors += "\n Couldn't fetch url '#{data}'<!--, #{e.message} - #{e.backtrace.join("\n")}-->\n"
214
+ end
215
+ if image[:content].blank?
216
+ final_html << data
217
+ next
212
218
  end
213
219
  image[:filename] = filename = File.basename(data)
214
220
  extension = filename.gsub(/^.*\./,'').downcase
215
221
  Rails.logger.debug "Fetching Image for: #{filename} #{image[:content].to_s[0..30]}"
216
222
  extension = get_extension_from_data(image[:content]) if image_mime_types(extension).blank?
217
- image_errors += "Couldn't find mime type for #{extension} on #{data}" if image_mime_types(extension).blank?
223
+ image_errors += "\n Couldn't find mime type for #{extension} on #{data}" if image_mime_types(extension).blank?
218
224
  image[:content_type] = image_mime_types(extension)
225
+ final_html << "cid:#{image[:cid]}"
219
226
  images << image
220
227
  else
221
228
  final_html << data
222
229
  end
223
230
  end
224
- raise image_errors unless image_errors.eql?('')
231
+ # FIXME: add warnings for missing images email or on the newsletter/mailing page
232
+ # raise image_errors unless image_errors.eql?('')
225
233
  [final_html,images]
226
234
  end
227
235
 
@@ -149,31 +149,19 @@ module MailManager
149
149
 
150
150
  # creates all of the Messages that will be sent for this mailing
151
151
  def initialize_messages
152
- unless messages.length > 0
153
- Rails.logger.info "Building mailing messages for mailing(#{id})"
154
- transaction do
155
- emails_hash = messages.select{|m| m.type.eql?('MailManager::Message')}.inject(Hash.new){|emails_hash,message| emails_hash.merge(Mailing.clean_email_address(message.email_address)=>1)}
156
- mailing_lists.each do |mailing_list|
157
- mailing_list.subscriptions.active.each do |subscription|
158
- contact = subscription.contact
159
- next if contact.nil? or contact.deleted?
160
- email_address = Mailing.clean_email_address(contact.email_address)
161
- if emails_hash.has_key?(email_address)
162
- Rails.logger.info "Skipping duplicate address: #{email_address}"
163
- else
164
- Rails.logger.info "Adding #{email_address} to mailing #{subject}"
165
- emails_hash[email_address] = 1
166
- message = Message.new
167
- message.subscription = subscription
168
- message.contact = contact
169
- message.mailing = self
170
- message.save
171
- end
172
- end
173
- end
174
- end
175
- save
176
- end
152
+ emails_hash = MailManager::Message.email_address_hash_for_mailing_id(self.id)
153
+ emails_hash.merge!(MailManager::Subscription.unsubscribed_emails_hash)
154
+ ids = self.mailing_lists.select('id').map(&:id)
155
+ active_subscriptions_hash = MailManager::MailingList.
156
+ active_email_addresses_contact_ids_subscription_ids_for_mailing_list_ids(ids)
157
+ active_subscriptions_hash.each_pair do | email, data |
158
+ next if emails_hash[email.to_s.strip.downcase].present?
159
+ message = MailManager::Message.create({
160
+ :subscription_id => data[:subscription_id],
161
+ :contact_id => data[:contact_id],
162
+ :mailing_id => self.id
163
+ })
164
+ end
177
165
  end
178
166
 
179
167
  # clean up an email address for sending FIXME - maybe do a bit more
@@ -23,6 +23,23 @@ module MailManager
23
23
  before_create :set_default_status
24
24
 
25
25
  attr_protected :id
26
+
27
+ def self.active_email_addresses_contact_ids_subscription_ids_for_mailing_list_ids(mailing_list_ids)
28
+ results = MailManager::MailingList.connection.execute(
29
+ %Q|select c.email_address as email_address, c.id as contact_id,
30
+ s.id as subscription_id from #{MailManager.table_prefix}contacts c
31
+ inner join #{MailManager.table_prefix}subscriptions s on c.id=s.contact_id
32
+ where s.status in ('active') and mailing_list_id in (#{
33
+ mailing_list_ids.join(',')})|
34
+ )
35
+ results = results.map(&:values) if results.first.is_a?(Hash)
36
+ results.inject(Hash.new){ |h,r|
37
+ h.merge!(r[0].to_s.strip.downcase => {
38
+ contact_id: r[1].to_i, subscription_id: r[2].to_i
39
+ })
40
+ }
41
+ end
42
+
26
43
 
27
44
  def active?
28
45
  deleted_at.nil?
@@ -34,6 +34,17 @@ module MailManager
34
34
 
35
35
  attr_protected :id
36
36
 
37
+ def self.email_address_hash_for_mailing_id(mailing_id)
38
+ results = MailManager::Message.connection.execute(
39
+ %Q|select distinct c.email_address
40
+ from #{MailManager.table_prefix}contacts c
41
+ inner join #{MailManager.table_prefix}messages m
42
+ on c.id=m.contact_id where m.mailing_id=#{mailing_id}|
43
+ )
44
+ results = results.map(&:values) if results.first.is_a?(Hash)
45
+ results.inject(Hash.new){|h,r|h.merge!(r[0].to_s.strip.downcase => true)}
46
+ end
47
+
37
48
  def initialize(*args)
38
49
  super
39
50
  set_type
@@ -45,7 +56,7 @@ module MailManager
45
56
  conditions[0] += " AND #{MailManager.table_prefix}messages.mailing_id=?"
46
57
  conditions << params[:mailing_id]
47
58
  end
48
- if params[:status]
59
+ if params[:status].present?
49
60
  conditions[0] += " AND #{MailManager.table_prefix}messages.status=?"
50
61
  conditions << params[:status]
51
62
  end
@@ -50,6 +50,17 @@ module MailManager
50
50
  attr_protected :id
51
51
 
52
52
  #acts_as_audited rescue Rails.logger.warn "Audit Table not defined!"
53
+ #
54
+
55
+ def self.unsubscribed_emails_hash
56
+ results = self.connection.execute(%Q|select distinct c.email_address
57
+ from #{MailManager.table_prefix}contacts c
58
+ inner join #{MailManager.table_prefix}subscriptions s on c.id=s.contact_id
59
+ where s.status in ('unsubscribed')|
60
+ )
61
+ results = results.map(&:values) if results.first.is_a?(Hash)
62
+ results.inject(Hash.new){|h,r|h.merge!(r[0].to_s.strip.downcase => true)}
63
+ end
53
64
 
54
65
  def contact_full_name
55
66
  contact.full_name
@@ -63,6 +74,7 @@ module MailManager
63
74
  subscription.contact = contact
64
75
  subscription.mailing_list = mailing_list
65
76
  subscription.change_status(status)
77
+ subscription
66
78
  end
67
79
 
68
80
  # subscribes the contact to the list
@@ -14,7 +14,9 @@
14
14
  <hr/>
15
15
  <h3>Headers</h3>
16
16
  <pre>
17
- <%= this_part.header.inspect %>
17
+ <% this_part.header.each_entry do |header| %>
18
+ <%= header.name %>: <%= header.value %>
19
+ <% end %>
18
20
  </pre>
19
21
  <% if this_part.header['content-type'].to_s =~ /text\/html/i %>
20
22
  <h3>Body Part</h3>
@@ -1,4 +1,4 @@
1
- <%= title "Listing Bounces#{"for #{@mailing.subject}" if @mailing.present?}" %>
1
+ <%= title "Listing Bounces#{" for #{@mailing.subject}" if @mailing.present?}" %>
2
2
 
3
3
 
4
4
  <%= form_tag mail_manager.bounces_path, :id => 'search_form', :method => 'GET' do %>
@@ -3,9 +3,9 @@
3
3
 
4
4
  <% if @bounce.status.eql?('needs_manual_intervention') %>
5
5
  <div>
6
- <%= link_to "Unsubscribe", mail_manager.fail_address_bounce_path(@bounce), :class => 'button' %>
6
+ <%= link_to "Remove Related Email/Subscriptions", mail_manager.fail_address_bounce_path(@bounce), :class => 'button', method: :put %>
7
7
  &nbsp;
8
- <%= link_to "Dismiss", mail_manager.dismiss_bounce_path(@bounce), :class => 'button' %>
8
+ <%= link_to "Dismiss", mail_manager.dismiss_bounce_path(@bounce), :class => 'button', method: :put %>
9
9
  </div>
10
10
  <% end %>
11
11
 
@@ -6,6 +6,6 @@
6
6
  <%= f.text_field :last_name, :style => 'width: 300px;' %><br />
7
7
  <%= f.label :email_address %>
8
8
  <%= f.text_field :email_address, :style => 'width: 300px;' %><br />
9
- <%= contactable_subscriptions_selector(f) %>
9
+ <%= contactable_subscriptions_selector(f, 'admin_unsubscribed') %>
10
10
  <div class="submit_button"><%= f.submit "Submit", :class => 'button' %></div>
11
11
  <% end %>
@@ -16,7 +16,7 @@
16
16
  <td><%=l(mailing.scheduled_at) rescue '' %></td>
17
17
  <td><b><%=h mailing.status %></b></td>
18
18
  <td align="center"><nobr><%= link_to 'Send Test', mail_manager.test_mailing_path(mailing), :id => 'Send_Test', :class => 'button' %></nobr></td>
19
- <td>
19
+ <td><div class="mailing_buttons">
20
20
  <% if mailing.can_edit? %>
21
21
  <%= link_to 'Edit', mail_manager.edit_mailing_path(mailing), :class => 'button' %>
22
22
  <% if mailing.can_schedule? %>
@@ -33,7 +33,7 @@
33
33
  <%= link_to 'Bounces', mail_manager.bounces_path(:mailing_id => mailing.id), :class => 'button' %>
34
34
  <% end %>
35
35
  <%= link_to 'Delete', mail_manager.mailing_path(mailing), :method => :delete, :confirm => "Are you sure?", :class => 'button' %>
36
- </td>
36
+ </div></td>
37
37
  </tr>
38
38
  <% end %>
39
39
  </table>
@@ -43,7 +43,7 @@ No mailings exist.<br /><br />
43
43
 
44
44
  <%= content_for :page_navigation do %>
45
45
  <div>
46
- <%= will_paginate @mailings %>
46
+ <%= will_paginate @mailings %><br /><br />
47
47
  <%= link_to "New Mailing", mail_manager.new_mailing_path, :class => 'button' %>
48
48
  </div>
49
49
  <% end %>
@@ -20,7 +20,7 @@
20
20
  <td>Status</td>
21
21
  <td>Status changed at</td>
22
22
  -->
23
- <td>Result</td>
23
+ <td>Errors</td>
24
24
  </tr>
25
25
 
26
26
  <% @messages.each do |message| %>
@@ -1,9 +1,12 @@
1
1
  <% unsubscribed_status ||= 'unsubscribed' %>
2
2
  <%= contactable_form.fields_for :subscriptions do |subscription_fields| %>
3
3
  <% subscription = subscription_fields.object %>
4
- <div class="field">
4
+ <div class="field subscription_status_<%= subscription.status %>">
5
5
  <%= subscription_fields.label :status, subscription.mailing_list.try(:name) %>
6
- <%= subscription_fields.check_box :status, {}, 'active', subscription.status.eql?('active') ? unsubscribed_status : subscription.status %><br />
7
- <%= subscription_fields.hidden_field :mailing_list_id %>
6
+ <%= subscription_fields.check_box :status, {}, 'active', subscription.status.eql?('active') ? unsubscribed_status : subscription.status %>
7
+ <%= subscription_fields.hidden_field :mailing_list_id %>
8
+ <% unless ['pending','active'].include?(subscription.status) %>
9
+ <%= subscription.status.humanize %>
10
+ <% end %><br />
8
11
  </div>
9
12
  <% end %>
@@ -11,8 +11,8 @@ MailManager::Engine.routes.draw do
11
11
 
12
12
  resources :bounces, only: [:index, :show] do
13
13
  member do
14
- get :dismiss
15
- get :fail_address
14
+ put :dismiss
15
+ put :fail_address
16
16
  end
17
17
  end
18
18
 
@@ -3,15 +3,18 @@ module ::Delayed
3
3
  end
4
4
  class Status
5
5
  def self.ok?(overdue=15.minutes)
6
- job = ::Delayed::StatusJob.first || ::Delayed::StatusJob.enqueue(::Delayed::StatusJob.new)
7
6
  failed_count = Delayed::Job.where('failed_at is not null').count
8
7
  raise(::Delayed::StatusException, "There are #{failed_count} failed jobs!"
9
8
  ) if failed_count > 0
10
- elapsed_time = (Time.now - job.updated_at).to_i
9
+ elapsed_time = (Time.now - status_job.updated_at).to_i
11
10
  raise(::Delayed::StatusException,
12
11
  "Rails3 Status job hasn't run for #{elapsed_time} seconds"
13
12
  ) if elapsed_time > overdue
14
13
  true
15
14
  end
15
+ def self.status_job
16
+ status_job = Job.where("handler like '%StatusJob%'").first
17
+ status_job ||= Job.enqueue StatusJob.new(1.minute.from_now)
18
+ end
16
19
  end
17
20
  end