mailboxer 0.11.0 → 0.12.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +4 -3
- data/Appraisals +6 -14
- data/Gemfile +1 -1
- data/README.md +2 -2
- data/app/mailers/mailboxer/base_mailer.rb +14 -0
- data/app/mailers/{message_mailer.rb → mailboxer/message_mailer.rb} +9 -14
- data/app/mailers/mailboxer/notification_mailer.rb +17 -0
- data/app/models/mailboxer/conversation.rb +196 -0
- data/app/models/mailboxer/conversation/opt_out.rb +15 -0
- data/app/models/{mailbox.rb → mailboxer/mailbox.rb} +10 -10
- data/app/models/mailboxer/message.rb +49 -0
- data/app/models/{notification.rb → mailboxer/notification.rb} +44 -40
- data/app/models/{receipt.rb → mailboxer/receipt.rb} +12 -11
- data/app/views/{message_mailer → mailboxer/message_mailer}/new_message_email.html.erb +3 -3
- data/app/views/{message_mailer → mailboxer/message_mailer}/new_message_email.text.erb +2 -2
- data/app/views/{message_mailer → mailboxer/message_mailer}/reply_message_email.html.erb +3 -3
- data/app/views/{message_mailer → mailboxer/message_mailer}/reply_message_email.text.erb +2 -2
- data/app/views/{notification_mailer → mailboxer/notification_mailer}/new_notification_email.html.erb +0 -0
- data/app/views/{notification_mailer → mailboxer/notification_mailer}/new_notification_email.text.erb +0 -0
- data/db/migrate/20110511145103_create_mailboxer.rb +18 -14
- data/db/migrate/20131206080416_add_conversation_optout.rb +14 -0
- data/gemfiles/rails3.2.gemfile +2 -3
- data/gemfiles/rails4.0.gemfile +3 -4
- data/gemfiles/rails4.1.gemfile +7 -0
- data/lib/generators/mailboxer/install_generator.rb +1 -4
- data/lib/generators/mailboxer/namespacing_compatibility_generator.rb +22 -0
- data/lib/generators/mailboxer/templates/initializer.rb +8 -4
- data/lib/generators/mailboxer/templates/mailboxer_namespacing_compatibility.rb +24 -0
- data/lib/mailboxer.rb +7 -1
- data/lib/mailboxer/cleaner.rb +9 -0
- data/lib/mailboxer/engine.rb +1 -1
- data/lib/mailboxer/mail_dispatcher.rb +48 -0
- data/lib/mailboxer/models/messageable.rb +21 -20
- data/lib/mailboxer/version.rb +3 -0
- data/mailboxer.gemspec +16 -8
- data/spec/dummy/Gemfile +1 -1
- data/spec/dummy/app/models/duck.rb +2 -2
- data/spec/dummy/config/initializers/mailboxer.rb +4 -0
- data/spec/dummy/db/migrate/20120305103200_create_mailboxer.rb +18 -14
- data/spec/dummy/db/migrate/20131206080416_add_conversation_optout.rb +14 -0
- data/spec/dummy/db/schema.rb +30 -21
- data/spec/integration/message_and_receipt_spec.rb +212 -212
- data/spec/mailboxer/mail_dispatcher_spec.rb +114 -0
- data/spec/mailers/message_mailer_spec.rb +4 -4
- data/spec/mailers/notification_mailer_spec.rb +2 -2
- data/spec/models/conversation_spec.rb +148 -47
- data/spec/models/mailbox_spec.rb +50 -50
- data/spec/models/mailboxer_models_messageable_spec.rb +52 -52
- data/spec/models/message_spec.rb +1 -1
- data/spec/models/notification_spec.rb +50 -18
- data/spec/models/receipt_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +68 -57
- data/app/mailers/notification_mailer.rb +0 -21
- data/app/models/conversation.rb +0 -166
- data/app/models/message.rb +0 -68
- data/db/migrate/20110719110700_add_notified_object.rb +0 -17
- data/db/migrate/20110912163911_add_notification_code.rb +0 -13
- data/db/migrate/20111204163911_add_attachments.rb +0 -9
- data/db/migrate/20120813110712_rename_receipts_read.rb +0 -9
- data/db/migrate/20130305144212_add_global_notification_support.rb +0 -9
- data/gemfiles/rails3.0.gemfile +0 -8
- data/gemfiles/rails3.1.gemfile +0 -8
- data/lib/mailboxer/concerns/configurable_mailer.rb +0 -13
- data/spec/dummy/db/migrate/20120305103201_add_notified_object.rb +0 -17
- data/spec/dummy/db/migrate/20120305103202_add_notification_code.rb +0 -13
- data/spec/dummy/db/migrate/20120305103203_add_attachments.rb +0 -5
- data/spec/dummy/db/migrate/20120813110712_rename_receipts_read.rb +0 -9
- data/spec/dummy/db/migrate/20130305144212_add_global_notification_support.rb +0 -11
- data/spec/mailboxer/concerns/configurable_mailer_spec.rb +0 -27
data/app/models/message.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
class Message < Notification
|
2
|
-
attr_accessible :attachment if Mailboxer.protected_attributes?
|
3
|
-
|
4
|
-
belongs_to :conversation, :validate => true, :autosave => true
|
5
|
-
validates_presence_of :sender
|
6
|
-
|
7
|
-
class_attribute :on_deliver_callback
|
8
|
-
protected :on_deliver_callback
|
9
|
-
scope :conversation, lambda { |conversation|
|
10
|
-
where(:conversation_id => conversation.id)
|
11
|
-
}
|
12
|
-
|
13
|
-
mount_uploader :attachment, AttachmentUploader
|
14
|
-
|
15
|
-
include Concerns::ConfigurableMailer
|
16
|
-
|
17
|
-
class << self
|
18
|
-
#Sets the on deliver callback method.
|
19
|
-
def on_deliver(callback_method)
|
20
|
-
self.on_deliver_callback = callback_method
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
#Delivers a Message. USE NOT RECOMENDED.
|
25
|
-
#Use Mailboxer::Models::Message.send_message instead.
|
26
|
-
def deliver(reply = false, should_clean = true)
|
27
|
-
self.clean if should_clean
|
28
|
-
|
29
|
-
#Receiver receipts
|
30
|
-
temp_receipts = recipients.map { |r| build_receipt(r, 'inbox') }
|
31
|
-
|
32
|
-
#Sender receipt
|
33
|
-
sender_receipt = build_receipt(sender, 'sentbox', true)
|
34
|
-
temp_receipts << sender_receipt
|
35
|
-
|
36
|
-
temp_receipts.each(&:valid?)
|
37
|
-
if temp_receipts.all? { |t| t.errors.empty? }
|
38
|
-
temp_receipts.each(&:save!) #Save receipts
|
39
|
-
#Should send an email?
|
40
|
-
if Mailboxer.uses_emails
|
41
|
-
if Mailboxer.mailer_wants_array
|
42
|
-
get_mailer.send_email(self, recipients).deliver
|
43
|
-
else
|
44
|
-
recipients.each do |recipient|
|
45
|
-
email_to = recipient.send(Mailboxer.email_method, self)
|
46
|
-
get_mailer.send_email(self, recipient).deliver if email_to.present?
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
if reply
|
51
|
-
self.conversation.touch
|
52
|
-
end
|
53
|
-
self.recipients=nil
|
54
|
-
self.on_deliver_callback.call(self) unless self.on_deliver_callback.nil?
|
55
|
-
end
|
56
|
-
sender_receipt
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
def build_receipt(receiver, mailbox_type, is_read = false)
|
61
|
-
Receipt.new.tap do |receipt|
|
62
|
-
receipt.notification = self
|
63
|
-
receipt.is_read = is_read
|
64
|
-
receipt.receiver = receiver
|
65
|
-
receipt.mailbox_type = mailbox_type
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class AddNotifiedObject < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
change_table :notifications do |t|
|
4
|
-
t.references :notified_object, :polymorphic => true
|
5
|
-
t.remove :object_id
|
6
|
-
t.remove :object_type
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.down
|
11
|
-
change_table :notifications do |t|
|
12
|
-
t.remove :notified_object_id
|
13
|
-
t.remove :notified_object_type
|
14
|
-
t.references :object, :polymorphic => true
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class AddNotificationCode < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
change_table :notifications do |t|
|
4
|
-
t.string :notification_code, :default => nil
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.down
|
9
|
-
change_table :notifications do |t|
|
10
|
-
t.remove :notification_code
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/gemfiles/rails3.0.gemfile
DELETED
data/gemfiles/rails3.1.gemfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'active_support/inflections'
|
2
|
-
|
3
|
-
module Concerns
|
4
|
-
module ConfigurableMailer
|
5
|
-
|
6
|
-
def get_mailer
|
7
|
-
return @mailer if @mailer
|
8
|
-
method = "#{self.class.to_s.downcase}_mailer".to_sym
|
9
|
-
@mailer = Mailboxer.send(method) || "#{self.class}Mailer".constantize
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class AddNotifiedObject < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
change_table :notifications do |t|
|
4
|
-
t.references :notified_object, :polymorphic => true
|
5
|
-
t.remove :object_id
|
6
|
-
t.remove :object_type
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.down
|
11
|
-
change_table :notifications do |t|
|
12
|
-
t.remove :notified_object_id
|
13
|
-
t.remove :notified_object_type
|
14
|
-
t.references :object, :polymorphic => true
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class AddNotificationCode < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
change_table :notifications do |t|
|
4
|
-
t.string :notification_code, :default => nil
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.down
|
9
|
-
change_table :notifications do |t|
|
10
|
-
t.remove :notification_code
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
describe Concerns::ConfigurableMailer do
|
3
|
-
|
4
|
-
describe "Notification instance#get_mailer" do
|
5
|
-
before { @obj = Notification.new }
|
6
|
-
it "returns default_mailer" do
|
7
|
-
@obj.get_mailer.should eq NotificationMailer
|
8
|
-
end
|
9
|
-
it "returns 'foo' from Mailerbox.notification_mailer" do
|
10
|
-
Mailboxer.notification_mailer = 'foo'
|
11
|
-
@obj.get_mailer.should eq 'foo'
|
12
|
-
end
|
13
|
-
after { Mailboxer.notification_mailer = nil }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "Message instance#get_mailer" do
|
17
|
-
before { @obj = Message.new }
|
18
|
-
it "returns default_mailer" do
|
19
|
-
@obj.get_mailer.should eq MessageMailer
|
20
|
-
end
|
21
|
-
it "returns 'foo' from Mailerbox.message_mailer" do
|
22
|
-
Mailboxer.message_mailer = 'foo'
|
23
|
-
@obj.get_mailer.should eq 'foo'
|
24
|
-
end
|
25
|
-
after { Mailboxer.message_mailer = nil }
|
26
|
-
end
|
27
|
-
end
|