mailboxer 0.11.0 → 0.12.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +4 -3
  4. data/Appraisals +6 -14
  5. data/Gemfile +1 -1
  6. data/README.md +2 -2
  7. data/app/mailers/mailboxer/base_mailer.rb +14 -0
  8. data/app/mailers/{message_mailer.rb → mailboxer/message_mailer.rb} +9 -14
  9. data/app/mailers/mailboxer/notification_mailer.rb +17 -0
  10. data/app/models/mailboxer/conversation.rb +196 -0
  11. data/app/models/mailboxer/conversation/opt_out.rb +15 -0
  12. data/app/models/{mailbox.rb → mailboxer/mailbox.rb} +10 -10
  13. data/app/models/mailboxer/message.rb +49 -0
  14. data/app/models/{notification.rb → mailboxer/notification.rb} +44 -40
  15. data/app/models/{receipt.rb → mailboxer/receipt.rb} +12 -11
  16. data/app/views/{message_mailer → mailboxer/message_mailer}/new_message_email.html.erb +3 -3
  17. data/app/views/{message_mailer → mailboxer/message_mailer}/new_message_email.text.erb +2 -2
  18. data/app/views/{message_mailer → mailboxer/message_mailer}/reply_message_email.html.erb +3 -3
  19. data/app/views/{message_mailer → mailboxer/message_mailer}/reply_message_email.text.erb +2 -2
  20. data/app/views/{notification_mailer → mailboxer/notification_mailer}/new_notification_email.html.erb +0 -0
  21. data/app/views/{notification_mailer → mailboxer/notification_mailer}/new_notification_email.text.erb +0 -0
  22. data/db/migrate/20110511145103_create_mailboxer.rb +18 -14
  23. data/db/migrate/20131206080416_add_conversation_optout.rb +14 -0
  24. data/gemfiles/rails3.2.gemfile +2 -3
  25. data/gemfiles/rails4.0.gemfile +3 -4
  26. data/gemfiles/rails4.1.gemfile +7 -0
  27. data/lib/generators/mailboxer/install_generator.rb +1 -4
  28. data/lib/generators/mailboxer/namespacing_compatibility_generator.rb +22 -0
  29. data/lib/generators/mailboxer/templates/initializer.rb +8 -4
  30. data/lib/generators/mailboxer/templates/mailboxer_namespacing_compatibility.rb +24 -0
  31. data/lib/mailboxer.rb +7 -1
  32. data/lib/mailboxer/cleaner.rb +9 -0
  33. data/lib/mailboxer/engine.rb +1 -1
  34. data/lib/mailboxer/mail_dispatcher.rb +48 -0
  35. data/lib/mailboxer/models/messageable.rb +21 -20
  36. data/lib/mailboxer/version.rb +3 -0
  37. data/mailboxer.gemspec +16 -8
  38. data/spec/dummy/Gemfile +1 -1
  39. data/spec/dummy/app/models/duck.rb +2 -2
  40. data/spec/dummy/config/initializers/mailboxer.rb +4 -0
  41. data/spec/dummy/db/migrate/20120305103200_create_mailboxer.rb +18 -14
  42. data/spec/dummy/db/migrate/20131206080416_add_conversation_optout.rb +14 -0
  43. data/spec/dummy/db/schema.rb +30 -21
  44. data/spec/integration/message_and_receipt_spec.rb +212 -212
  45. data/spec/mailboxer/mail_dispatcher_spec.rb +114 -0
  46. data/spec/mailers/message_mailer_spec.rb +4 -4
  47. data/spec/mailers/notification_mailer_spec.rb +2 -2
  48. data/spec/models/conversation_spec.rb +148 -47
  49. data/spec/models/mailbox_spec.rb +50 -50
  50. data/spec/models/mailboxer_models_messageable_spec.rb +52 -52
  51. data/spec/models/message_spec.rb +1 -1
  52. data/spec/models/notification_spec.rb +50 -18
  53. data/spec/models/receipt_spec.rb +1 -1
  54. data/spec/spec_helper.rb +3 -0
  55. metadata +68 -57
  56. data/app/mailers/notification_mailer.rb +0 -21
  57. data/app/models/conversation.rb +0 -166
  58. data/app/models/message.rb +0 -68
  59. data/db/migrate/20110719110700_add_notified_object.rb +0 -17
  60. data/db/migrate/20110912163911_add_notification_code.rb +0 -13
  61. data/db/migrate/20111204163911_add_attachments.rb +0 -9
  62. data/db/migrate/20120813110712_rename_receipts_read.rb +0 -9
  63. data/db/migrate/20130305144212_add_global_notification_support.rb +0 -9
  64. data/gemfiles/rails3.0.gemfile +0 -8
  65. data/gemfiles/rails3.1.gemfile +0 -8
  66. data/lib/mailboxer/concerns/configurable_mailer.rb +0 -13
  67. data/spec/dummy/db/migrate/20120305103201_add_notified_object.rb +0 -17
  68. data/spec/dummy/db/migrate/20120305103202_add_notification_code.rb +0 -13
  69. data/spec/dummy/db/migrate/20120305103203_add_attachments.rb +0 -5
  70. data/spec/dummy/db/migrate/20120813110712_rename_receipts_read.rb +0 -9
  71. data/spec/dummy/db/migrate/20130305144212_add_global_notification_support.rb +0 -11
  72. data/spec/mailboxer/concerns/configurable_mailer_spec.rb +0 -27
@@ -0,0 +1,114 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mailboxer::MailDispatcher do
4
+
5
+ subject(:instance) { described_class.new(mailable, recipients) }
6
+
7
+ let(:mailable) { Mailboxer::Notification.new }
8
+ let(:recipient1) { double 'recipient1', mailboxer_email: '' }
9
+ let(:recipient2) { double 'recipient2', mailboxer_email: 'foo@bar.com' }
10
+ let(:recipients) { [ recipient1, recipient2 ] }
11
+
12
+ describe "call" do
13
+ context "no emails" do
14
+ before { Mailboxer.uses_emails = false }
15
+ after { Mailboxer.uses_emails = true }
16
+ its(:call) { should be_false }
17
+ end
18
+
19
+ context "mailer wants array" do
20
+ before { Mailboxer.mailer_wants_array = true }
21
+ after { Mailboxer.mailer_wants_array = false }
22
+ it 'sends collection' do
23
+ subject.should_receive(:send_email).with(recipients)
24
+ subject.call
25
+ end
26
+ end
27
+
28
+ context "mailer doesnt want array" do
29
+ it 'sends collection' do
30
+ subject.should_not_receive(:send_email).with(recipient1) #email is blank
31
+ subject.should_receive(:send_email).with(recipient2)
32
+ subject.call
33
+ end
34
+ end
35
+ end
36
+
37
+ describe "send_email" do
38
+
39
+ let(:mailer) { double 'mailer' }
40
+
41
+ before(:each) do
42
+ subject.stub(:mailer).and_return mailer
43
+ end
44
+
45
+ context "with custom_deliver_proc" do
46
+ let(:my_proc) { double 'proc' }
47
+
48
+ before { Mailboxer.custom_deliver_proc = my_proc }
49
+ after { Mailboxer.custom_deliver_proc = nil }
50
+ it "triggers proc" do
51
+ my_proc.should_receive(:call).with(mailer, mailable, recipient1)
52
+ subject.send :send_email, recipient1
53
+ end
54
+ end
55
+
56
+ context "without custom_deliver_proc" do
57
+ let(:email) { double :email }
58
+
59
+ it "triggers standard deliver chain" do
60
+ mailer.should_receive(:send_email).with(mailable, recipient1).and_return email
61
+ email.should_receive :deliver
62
+
63
+ subject.send :send_email, recipient1
64
+ end
65
+ end
66
+ end
67
+
68
+ describe "mailer" do
69
+ let(:recipients) { [] }
70
+
71
+ context "mailable is a Message" do
72
+ let(:mailable) { Mailboxer::Notification.new }
73
+
74
+ its(:mailer) { should be Mailboxer::NotificationMailer }
75
+
76
+ context "with custom mailer" do
77
+ before { Mailboxer.notification_mailer = 'foo' }
78
+ after { Mailboxer.notification_mailer = nil }
79
+
80
+ its(:mailer) { should eq 'foo' }
81
+ end
82
+ end
83
+
84
+ context "mailable is a Notification" do
85
+ let(:mailable) { Mailboxer::Message.new }
86
+ its(:mailer) { should be Mailboxer::MessageMailer }
87
+
88
+ context "with custom mailer" do
89
+ before { Mailboxer.message_mailer = 'foo' }
90
+ after { Mailboxer.message_mailer = nil }
91
+
92
+ its(:mailer) { should eq 'foo' }
93
+ end
94
+ end
95
+ end
96
+
97
+ describe "filtered_recipients" do
98
+ context "responds to conversation" do
99
+ let(:conversation) { double 'conversation' }
100
+ let(:mailable) { double 'mailable', :conversation => conversation }
101
+ before(:each) do
102
+ conversation.should_receive(:has_subscriber?).with(recipient1).and_return false
103
+ conversation.should_receive(:has_subscriber?).with(recipient2).and_return true
104
+ end
105
+
106
+ its(:filtered_recipients){ should eq [recipient2] }
107
+ end
108
+
109
+ context 'doesnt respond to conversation' do
110
+ let(:mailable) { double 'mailable' }
111
+ its(:filtered_recipients){ should eq recipients }
112
+ end
113
+ end
114
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MessageMailer do
3
+ describe Mailboxer::MessageMailer do
4
4
  shared_examples 'message_mailer' do
5
5
  let(:sender) { FactoryGirl.create(:user) }
6
6
  let(:entity1) { FactoryGirl.create(:user) }
@@ -66,8 +66,8 @@ describe MessageMailer do
66
66
  end
67
67
 
68
68
  context "mailer_wants_array is true" do
69
- class ArrayMailer < MessageMailer
70
- default template_path: 'message_mailer'
69
+ class ArrayMailer < Mailboxer::MessageMailer
70
+ default template_path: 'mailboxer/message_mailer'
71
71
 
72
72
  def new_message_email(message, receivers)
73
73
  receivers.each { |receiver| super(message, receiver) if receiver.mailboxer_email(message).present? }
@@ -85,7 +85,7 @@ describe MessageMailer do
85
85
 
86
86
  after :all do
87
87
  Mailboxer.mailer_wants_array = false
88
- Mailboxer.message_mailer = MessageMailer
88
+ Mailboxer.message_mailer = Mailboxer::MessageMailer
89
89
  end
90
90
 
91
91
  it_behaves_like 'message_mailer'
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe NotificationMailer do
3
+ describe Mailboxer::NotificationMailer do
4
4
  before do
5
5
  @entity1 = FactoryGirl.create(:user)
6
6
  @entity2 = FactoryGirl.create(:duck)
7
7
  @entity3 = FactoryGirl.create(:cylon)
8
- @receipt1 = Notification.notify_all([@entity1,@entity2,@entity3],"Subject", "Body Body Body Body Body Body Body Body Body Body Body Body")
8
+ @receipt1 = Mailboxer::Notification.notify_all([@entity1,@entity2,@entity3],"Subject", "Body Body Body Body Body Body Body Body Body Body Body Body")
9
9
  end
10
10
 
11
11
  it "should send emails when should_email? is true (2 out of 3)" do
@@ -1,123 +1,224 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Conversation do
3
+ describe Mailboxer::Conversation do
4
4
 
5
- before do
6
- @entity1 = FactoryGirl.create(:user)
7
- @entity2 = FactoryGirl.create(:user)
8
- @receipt1 = @entity1.send_message(@entity2,"Body","Subject")
9
- @receipt2 = @entity2.reply_to_all(@receipt1,"Reply body 1")
10
- @receipt3 = @entity1.reply_to_all(@receipt2,"Reply body 2")
11
- @receipt4 = @entity2.reply_to_all(@receipt3,"Reply body 3")
12
- @message1 = @receipt1.notification
13
- @message4 = @receipt4.notification
14
- @conversation = @message1.conversation
15
- end
5
+ let!(:entity1) { FactoryGirl.create(:user) }
6
+ let!(:entity2) { FactoryGirl.create(:user) }
7
+ let!(:receipt1) { entity1.send_message(entity2,"Body","Subject") }
8
+ let!(:receipt2) { entity2.reply_to_all(receipt1,"Reply body 1") }
9
+ let!(:receipt3) { entity1.reply_to_all(receipt2,"Reply body 2") }
10
+ let!(:receipt4) { entity2.reply_to_all(receipt3,"Reply body 3") }
11
+ let!(:message1) { receipt1.notification }
12
+ let!(:message4) { receipt4.notification }
13
+ let!(:conversation) { message1.conversation }
14
+
15
+ it { should validate_presence_of :subject }
16
+ it { should ensure_length_of(:subject).is_at_most(Mailboxer.subject_max_length) }
16
17
 
17
18
  it "should have proper original message" do
18
- @conversation.original_message.should==@message1
19
+ conversation.original_message.should == message1
19
20
  end
20
21
 
21
22
  it "should have proper originator (first sender)" do
22
- @conversation.originator.should==@entity1
23
+ conversation.originator.should == entity1
23
24
  end
24
25
 
25
26
  it "should have proper last message" do
26
- @conversation.last_message.should==@message4
27
+ conversation.last_message.should == message4
27
28
  end
28
29
 
29
30
  it "should have proper last sender" do
30
- @conversation.last_sender.should==@entity2
31
+ conversation.last_sender.should == entity2
31
32
  end
32
33
 
33
34
  it "should have all conversation users" do
34
- @conversation.recipients.count.should==2
35
- @conversation.recipients.count.should==2
36
- @conversation.recipients.count(@entity1).should==1
37
- @conversation.recipients.count(@entity2).should==1
35
+ conversation.recipients.count.should == 2
36
+ conversation.recipients.count.should == 2
37
+ conversation.recipients.count(entity1).should == 1
38
+ conversation.recipients.count(entity2).should == 1
38
39
  end
39
40
 
40
41
  it "should be able to be marked as deleted" do
41
- @conversation.move_to_trash(@entity1)
42
- @conversation.mark_as_deleted(@entity1)
43
- @conversation.should be_is_deleted(@entity1)
42
+ conversation.move_to_trash(entity1)
43
+ conversation.mark_as_deleted(entity1)
44
+ conversation.should be_is_deleted(entity1)
45
+ end
46
+
47
+ it "should be removed from the database once deleted by all participants" do
48
+ conversation.mark_as_deleted(entity1)
49
+ conversation.mark_as_deleted(entity2)
50
+ Mailboxer::Conversation.exists?(conversation.id).should be_false
44
51
  end
45
52
 
46
53
  it "should be able to be marked as read" do
47
- #@conversation.move_to_trash(@entity1)
48
- @conversation.mark_as_read(@entity1)
49
- @conversation.should be_is_read(@entity)
54
+ conversation.mark_as_read(entity1)
55
+ conversation.should be_is_read(entity1)
50
56
  end
51
57
 
52
58
  it "should be able to be marked as unread" do
53
- @conversation.mark_as_read(@entity1)
54
- @conversation.mark_as_unread(@entity1)
55
- @conversation.should be_is_unread(@entity1)
59
+ conversation.mark_as_read(entity1)
60
+ conversation.mark_as_unread(entity1)
61
+ conversation.should be_is_unread(entity1)
56
62
  end
57
63
 
58
64
  it "should be able to add a new participant" do
59
65
  new_user = FactoryGirl.create(:user)
60
- @conversation.add_participant(new_user)
61
- @conversation.participants.count.should == 3
62
- @conversation.participants.should include(new_user, @entity1, @entity2)
63
- @conversation.receipts_for(new_user).count.should == @conversation.receipts_for(@entity1).count
66
+ conversation.add_participant(new_user)
67
+ conversation.participants.count.should == 3
68
+ conversation.participants.should include(new_user, entity1, entity2)
69
+ conversation.receipts_for(new_user).count.should == conversation.receipts_for(entity1).count
64
70
  end
65
71
 
66
72
  it "should deliver messages to new participants" do
67
73
  new_user = FactoryGirl.create(:user)
68
- @conversation.add_participant(new_user)
74
+ conversation.add_participant(new_user)
69
75
  expect{
70
- receipt5 = @entity1.reply_to_all(@receipt4,"Reply body 4")
71
- }.to change{ @conversation.receipts_for(new_user).count }.by 1
76
+ receipt5 = entity1.reply_to_all(receipt4,"Reply body 4")
77
+ }.to change{ conversation.receipts_for(new_user).count }.by 1
72
78
  end
73
79
 
74
80
  describe "scopes" do
75
81
  let(:participant) { FactoryGirl.create(:user) }
76
- let!(:inbox_conversation) { @entity1.send_message(participant, "Body", "Subject").notification.conversation }
77
- let!(:sentbox_conversation) { participant.send_message(@entity1, "Body", "Subject").notification.conversation }
82
+ let!(:inbox_conversation) { entity1.send_message(participant, "Body", "Subject").notification.conversation }
83
+ let!(:sentbox_conversation) { participant.send_message(entity1, "Body", "Subject").notification.conversation }
78
84
 
79
85
 
80
86
  describe ".participant" do
81
87
  it "finds conversations with receipts for participant" do
82
- Conversation.participant(participant).should == [sentbox_conversation, inbox_conversation]
88
+ Mailboxer::Conversation.participant(participant).should == [sentbox_conversation, inbox_conversation]
83
89
  end
84
90
  end
85
91
 
86
92
  describe ".inbox" do
87
93
  it "finds inbox conversations with receipts for participant" do
88
- Conversation.inbox(participant).should == [inbox_conversation]
94
+ Mailboxer::Conversation.inbox(participant).should == [inbox_conversation]
89
95
  end
90
96
  end
91
97
 
92
98
  describe ".sentbox" do
93
99
  it "finds sentbox conversations with receipts for participant" do
94
- Conversation.sentbox(participant).should == [sentbox_conversation]
100
+ Mailboxer::Conversation.sentbox(participant).should == [sentbox_conversation]
95
101
  end
96
102
  end
97
103
 
98
104
  describe ".trash" do
99
105
  it "finds trash conversations with receipts for participant" do
100
- trashed_conversation = @entity1.send_message(participant, "Body", "Subject").notification.conversation
106
+ trashed_conversation = entity1.send_message(participant, "Body", "Subject").notification.conversation
101
107
  trashed_conversation.move_to_trash(participant)
102
108
 
103
- Conversation.trash(participant).should == [trashed_conversation]
109
+ Mailboxer::Conversation.trash(participant).should == [trashed_conversation]
104
110
  end
105
111
  end
106
112
 
107
113
  describe ".unread" do
108
114
  it "finds unread conversations with receipts for participant" do
109
115
  [sentbox_conversation, inbox_conversation].each {|c| c.mark_as_read(participant) }
110
- unread_conversation = @entity1.send_message(participant, "Body", "Subject").notification.conversation
116
+ unread_conversation = entity1.send_message(participant, "Body", "Subject").notification.conversation
111
117
 
112
- Conversation.unread(participant).should == [unread_conversation]
118
+ Mailboxer::Conversation.unread(participant).should == [unread_conversation]
113
119
  end
114
120
  end
115
121
  end
116
122
 
117
123
  describe "#is_completely_trashed?" do
118
124
  it "returns true if all receipts in conversation are trashed for participant" do
119
- @conversation.move_to_trash(@entity1)
120
- @conversation.is_completely_trashed?(@entity1).should be_true
125
+ conversation.move_to_trash(entity1)
126
+ conversation.is_completely_trashed?(entity1).should be_true
127
+ end
128
+ end
129
+
130
+ describe "#is_deleted?" do
131
+ it "returns false if a recipient has not deleted the conversation" do
132
+ conversation.is_deleted?(entity1).should be_false
133
+ end
134
+
135
+ it "returns true if a recipient has deleted the conversation" do
136
+ conversation.mark_as_deleted(entity1)
137
+ conversation.is_deleted?(entity1).should be_true
138
+ end
139
+ end
140
+
141
+ describe "#is_orphaned?" do
142
+ it "returns true if both participants have deleted the conversation" do
143
+ conversation.mark_as_deleted(entity1)
144
+ conversation.mark_as_deleted(entity2)
145
+ conversation.is_orphaned?.should be_true
146
+ end
147
+
148
+ it "returns false if one has not deleted the conversation" do
149
+ conversation.mark_as_deleted(entity1)
150
+ conversation.is_orphaned?.should be_false
151
+ end
152
+ end
153
+
154
+
155
+ describe "#opt_out" do
156
+ context 'participant still opt in' do
157
+ let(:opt_out) { conversation.opt_outs.first }
158
+
159
+ it "creates an opt_out object" do
160
+ expect{
161
+ conversation.opt_out(entity1)
162
+ }.to change{ conversation.opt_outs.count}.by 1
163
+ end
164
+
165
+ it "creates opt out object linked to the proper conversation and participant" do
166
+ conversation.opt_out(entity1)
167
+ expect(opt_out.conversation).to eq conversation
168
+ expect(opt_out.unsubscriber).to eq entity1
169
+ end
170
+ end
171
+
172
+ context 'participant already opted out' do
173
+ before do
174
+ conversation.opt_out(entity1)
175
+ end
176
+ it 'does nothing' do
177
+ expect{
178
+ conversation.opt_out(entity1)
179
+ }.to_not change{ conversation.opt_outs.count}
180
+ end
181
+ end
182
+ end
183
+
184
+ describe "#opt_out" do
185
+ context 'participant already opt in' do
186
+ it "does nothing" do
187
+ expect{
188
+ conversation.opt_in(entity1)
189
+ }.to_not change{ conversation.opt_outs.count }
190
+ end
191
+ end
192
+
193
+ context 'participant opted out' do
194
+ before do
195
+ conversation.opt_out(entity1)
196
+ end
197
+ it 'destroys the opt out object' do
198
+ expect{
199
+ conversation.opt_in(entity1)
200
+ }.to change{ conversation.opt_outs.count}.by -1
201
+ end
121
202
  end
122
203
  end
204
+
205
+ describe "#subscriber?" do
206
+ let(:action) { conversation.has_subscriber?(entity1) }
207
+
208
+ context 'participant opted in' do
209
+ it "returns true" do
210
+ expect(action).to be_true
211
+ end
212
+ end
213
+
214
+ context 'participant opted out' do
215
+ before do
216
+ conversation.opt_out(entity1)
217
+ end
218
+ it 'returns false' do
219
+ expect(action).to be_false
220
+ end
221
+ end
222
+ end
223
+
123
224
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Mailbox do
4
-
3
+ describe Mailboxer::Mailbox do
4
+
5
5
  before do
6
6
  @entity1 = FactoryGirl.create(:user)
7
7
  @entity2 = FactoryGirl.create(:user)
@@ -12,60 +12,60 @@ describe Mailbox do
12
12
  @message1 = @receipt1.notification
13
13
  @message4 = @receipt4.notification
14
14
  @conversation = @message1.conversation
15
- end
16
-
15
+ end
16
+
17
17
  it "should return all conversations" do
18
18
  @conv2 = @entity1.send_message(@entity2,"Body","Subject").conversation
19
19
  @conv3 = @entity2.send_message(@entity1,"Body","Subject").conversation
20
20
  @conv4 = @entity1.send_message(@entity2,"Body","Subject").conversation
21
-
21
+
22
22
  assert @entity1.mailbox.conversations
23
-
23
+
24
24
  @entity1.mailbox.conversations.to_a.count.should==4
25
25
  @entity1.mailbox.conversations.to_a.count(@conversation).should==1
26
26
  @entity1.mailbox.conversations.to_a.count(@conv2).should==1
27
27
  @entity1.mailbox.conversations.to_a.count(@conv3).should==1
28
- @entity1.mailbox.conversations.to_a.count(@conv4).should==1
28
+ @entity1.mailbox.conversations.to_a.count(@conv4).should==1
29
29
  end
30
-
31
- it "should return all mail" do
30
+
31
+ it "should return all mail" do
32
32
  assert @entity1.mailbox.receipts
33
33
  @entity1.mailbox.receipts.count.should==4
34
- @entity1.mailbox.receipts[0].should==Receipt.recipient(@entity1).conversation(@conversation)[0]
35
- @entity1.mailbox.receipts[1].should==Receipt.recipient(@entity1).conversation(@conversation)[1]
36
- @entity1.mailbox.receipts[2].should==Receipt.recipient(@entity1).conversation(@conversation)[2]
37
- @entity1.mailbox.receipts[3].should==Receipt.recipient(@entity1).conversation(@conversation)[3]
38
-
34
+ @entity1.mailbox.receipts[0].should==Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[0]
35
+ @entity1.mailbox.receipts[1].should==Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[1]
36
+ @entity1.mailbox.receipts[2].should==Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[2]
37
+ @entity1.mailbox.receipts[3].should==Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[3]
38
+
39
39
  assert @entity2.mailbox.receipts
40
40
  @entity2.mailbox.receipts.count.should==4
41
- @entity2.mailbox.receipts[0].should==Receipt.recipient(@entity2).conversation(@conversation)[0]
42
- @entity2.mailbox.receipts[1].should==Receipt.recipient(@entity2).conversation(@conversation)[1]
43
- @entity2.mailbox.receipts[2].should==Receipt.recipient(@entity2).conversation(@conversation)[2]
44
- @entity2.mailbox.receipts[3].should==Receipt.recipient(@entity2).conversation(@conversation)[3]
41
+ @entity2.mailbox.receipts[0].should==Mailboxer::Receipt.recipient(@entity2).conversation(@conversation)[0]
42
+ @entity2.mailbox.receipts[1].should==Mailboxer::Receipt.recipient(@entity2).conversation(@conversation)[1]
43
+ @entity2.mailbox.receipts[2].should==Mailboxer::Receipt.recipient(@entity2).conversation(@conversation)[2]
44
+ @entity2.mailbox.receipts[3].should==Mailboxer::Receipt.recipient(@entity2).conversation(@conversation)[3]
45
45
  end
46
-
46
+
47
47
  it "should return sentbox" do
48
48
  assert @entity1.mailbox.receipts.inbox
49
49
  @entity1.mailbox.receipts.sentbox.count.should==2
50
50
  @entity1.mailbox.receipts.sentbox[0].should==@receipt1
51
51
  @entity1.mailbox.receipts.sentbox[1].should==@receipt3
52
-
52
+
53
53
  assert @entity2.mailbox.receipts.inbox
54
54
  @entity2.mailbox.receipts.sentbox.count.should==2
55
55
  @entity2.mailbox.receipts.sentbox[0].should==@receipt2
56
56
  @entity2.mailbox.receipts.sentbox[1].should==@receipt4
57
57
  end
58
-
58
+
59
59
  it "should return inbox" do
60
60
  assert @entity1.mailbox.receipts.inbox
61
61
  @entity1.mailbox.receipts.inbox.count.should==2
62
- @entity1.mailbox.receipts.inbox[0].should==Receipt.recipient(@entity1).inbox.conversation(@conversation)[0]
63
- @entity1.mailbox.receipts.inbox[1].should==Receipt.recipient(@entity1).inbox.conversation(@conversation)[1]
64
-
62
+ @entity1.mailbox.receipts.inbox[0].should==Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[0]
63
+ @entity1.mailbox.receipts.inbox[1].should==Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[1]
64
+
65
65
  assert @entity2.mailbox.receipts.inbox
66
66
  @entity2.mailbox.receipts.inbox.count.should==2
67
- @entity2.mailbox.receipts.inbox[0].should==Receipt.recipient(@entity2).inbox.conversation(@conversation)[0]
68
- @entity2.mailbox.receipts.inbox[1].should==Receipt.recipient(@entity2).inbox.conversation(@conversation)[1]
67
+ @entity2.mailbox.receipts.inbox[0].should==Mailboxer::Receipt.recipient(@entity2).inbox.conversation(@conversation)[0]
68
+ @entity2.mailbox.receipts.inbox[1].should==Mailboxer::Receipt.recipient(@entity2).inbox.conversation(@conversation)[1]
69
69
  end
70
70
 
71
71
  it "should understand the read option" do
@@ -73,41 +73,41 @@ describe Mailbox do
73
73
  @conversation.mark_as_read(@entity1)
74
74
  @entity1.mailbox.inbox({:read => false}).count.should == 0
75
75
  end
76
-
77
- it "should return trashed mails" do
76
+
77
+ it "should return trashed mails" do
78
78
  @entity1.mailbox.receipts.move_to_trash
79
-
79
+
80
80
  assert @entity1.mailbox.receipts.trash
81
81
  @entity1.mailbox.receipts.trash.count.should==4
82
- @entity1.mailbox.receipts.trash[0].should==Receipt.recipient(@entity1).conversation(@conversation)[0]
83
- @entity1.mailbox.receipts.trash[1].should==Receipt.recipient(@entity1).conversation(@conversation)[1]
84
- @entity1.mailbox.receipts.trash[2].should==Receipt.recipient(@entity1).conversation(@conversation)[2]
85
- @entity1.mailbox.receipts.trash[3].should==Receipt.recipient(@entity1).conversation(@conversation)[3]
86
-
82
+ @entity1.mailbox.receipts.trash[0].should==Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[0]
83
+ @entity1.mailbox.receipts.trash[1].should==Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[1]
84
+ @entity1.mailbox.receipts.trash[2].should==Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[2]
85
+ @entity1.mailbox.receipts.trash[3].should==Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[3]
86
+
87
87
  assert @entity2.mailbox.receipts.trash
88
- @entity2.mailbox.receipts.trash.count.should==0
88
+ @entity2.mailbox.receipts.trash.count.should==0
89
89
  end
90
-
91
- it "should delete trashed mails (TODO)" do
90
+
91
+ it "should delete trashed mails (TODO)" do
92
92
  @entity1.mailbox.receipts.move_to_trash
93
93
  #TODO
94
94
  #@entity1.mailbox.empty_trash
95
-
95
+
96
96
  assert @entity1.mailbox.receipts.trash
97
- #@entity1.mailbox.receipts.trash.count.should==0
98
-
97
+ #@entity1.mailbox.receipts.trash.count.should==0
98
+
99
99
  assert @entity2.mailbox.receipts
100
100
  @entity2.mailbox.receipts.count.should==4
101
-
101
+
102
102
  assert @entity2.mailbox.receipts.trash
103
- @entity2.mailbox.receipts.trash.count.should==0
103
+ @entity2.mailbox.receipts.trash.count.should==0
104
104
  end
105
105
 
106
106
  it "should deleted messages are not shown in inbox" do
107
107
  assert @entity1.mailbox.receipts.inbox
108
- @entity1.mailbox.inbox.count.should==2
109
- @entity1.mailbox.receipts.inbox[0].should==Receipt.recipient(@entity1).inbox.conversation(@conversation)[0]
110
- @entity1.mailbox.receipts.inbox[1].should==Receipt.recipient(@entity1).inbox.conversation(@conversation)[1]
108
+ @entity1.mailbox.inbox.count.should==1
109
+ @entity1.mailbox.receipts.inbox[0].should==Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[0]
110
+ @entity1.mailbox.receipts.inbox[1].should==Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[1]
111
111
 
112
112
  assert @entity1.mailbox.receipts.inbox.mark_as_deleted
113
113
  @entity1.mailbox.inbox.count.should==0
@@ -125,9 +125,9 @@ describe Mailbox do
125
125
 
126
126
  it "should reply for deleted messages return to inbox" do
127
127
  assert @entity1.mailbox.receipts.inbox
128
- @entity1.mailbox.inbox.count.should==2
129
- @entity1.mailbox.receipts.inbox[0].should==Receipt.recipient(@entity1).inbox.conversation(@conversation)[0]
130
- @entity1.mailbox.receipts.inbox[1].should==Receipt.recipient(@entity1).inbox.conversation(@conversation)[1]
128
+ @entity1.mailbox.inbox.count.should==1
129
+ @entity1.mailbox.receipts.inbox[0].should==Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[0]
130
+ @entity1.mailbox.receipts.inbox[1].should==Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[1]
131
131
 
132
132
  assert @entity1.mailbox.receipts.inbox.mark_as_deleted
133
133
  @entity1.mailbox.inbox.count.should==0
@@ -136,7 +136,7 @@ describe Mailbox do
136
136
  @entity1.mailbox.inbox.count.should==1
137
137
 
138
138
  @entity2.reply_to_all(@receipt3,"Reply body 3")
139
- @entity1.mailbox.inbox.count.should==2
139
+ @entity1.mailbox.inbox.count.should==1
140
140
  end
141
141
 
142
142
  context "STI models" do
@@ -156,5 +156,5 @@ describe Mailbox do
156
156
  @sti_entity2.mailbox.inbox.should include(@sti_mail.conversation)
157
157
  end
158
158
  end
159
-
159
+
160
160
  end