mailboxer 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/conversation.rb +102 -0
- data/app/models/{mailboxer_mailbox.rb → mailbox.rb} +18 -21
- data/app/models/{mailboxer_message.rb → message.rb} +6 -14
- data/app/models/{mailboxer_mail.rb → receipt.rb} +6 -14
- data/lib/generators/mailboxer/templates/migration.rb +8 -8
- data/lib/mailboxer/models/messageable.rb +90 -92
- data/mailboxer.gemspec +1 -1
- data/spec/dummy/db/migrate/{20110321231559_create_mailboxer.rb → 20110322000127_create_mailboxer.rb} +8 -8
- data/spec/integration/{mailboxer_message_and_mail_spec.rb → message_and_receipt_spec.rb} +29 -29
- data/spec/models/{mailboxer_conversation_spec.rb → conversation_spec.rb} +1 -1
- data/spec/models/mailbox_spec.rb +100 -0
- data/spec/models/mailboxer_models_messageable_spec.rb +42 -42
- data/spec/models/{mailboxer_mail_spec.rb → receipt_spec.rb} +1 -1
- metadata +12 -12
- data/app/models/mailboxer_conversation.rb +0 -106
- data/spec/models/mailboxer_mailbox_spec.rb +0 -99
data/mailboxer.gemspec
CHANGED
data/spec/dummy/db/migrate/{20110321231559_create_mailboxer.rb → 20110322000127_create_mailboxer.rb}
RENAMED
@@ -1,13 +1,13 @@
|
|
1
1
|
class CreateMailboxer < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
create_table :
|
3
|
+
create_table :conversations do |t|
|
4
4
|
t.column :subject, :string, :default => ""
|
5
5
|
t.column :created_at, :datetime, :null => false
|
6
6
|
t.column :updated_at, :datetime, :null => false
|
7
7
|
end
|
8
|
-
create_table :
|
8
|
+
create_table :receipts do |t|
|
9
9
|
t.references :receiver, :polymorphic => true
|
10
|
-
t.column :
|
10
|
+
t.column :message_id, :integer, :null => false
|
11
11
|
t.column :read, :boolean, :default => false
|
12
12
|
t.column :trashed, :boolean, :default => false
|
13
13
|
t.column :deleted, :boolean, :default => false
|
@@ -15,12 +15,12 @@ class CreateMailboxer < ActiveRecord::Migration
|
|
15
15
|
t.column :created_at, :datetime, :null => false
|
16
16
|
t.column :updated_at, :datetime, :null => false
|
17
17
|
end
|
18
|
-
create_table :
|
18
|
+
create_table :messages do |t|
|
19
19
|
t.column :body, :text
|
20
20
|
t.column :subject, :string, :default => ""
|
21
21
|
t.column :headers, :text
|
22
22
|
t.references :sender, :polymorphic => true
|
23
|
-
t.column :
|
23
|
+
t.column :conversation_id, :integer
|
24
24
|
t.column :sent, :boolean, :default => false
|
25
25
|
t.column :draft, :boolean, :default => false
|
26
26
|
t.column :system, :boolean, :default => false
|
@@ -30,8 +30,8 @@ class CreateMailboxer < ActiveRecord::Migration
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.down
|
33
|
-
drop_table :
|
34
|
-
drop_table :
|
35
|
-
drop_table :
|
33
|
+
drop_table :receipts
|
34
|
+
drop_table :conversations
|
35
|
+
drop_table :messages
|
36
36
|
end
|
37
37
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "Messages And Receipts" do
|
4
4
|
|
5
5
|
describe "two equal entities" do
|
6
6
|
before do
|
@@ -24,7 +24,7 @@ describe "Mailboxer Messages And Mails" do
|
|
24
24
|
|
25
25
|
it "should create proper mails" do
|
26
26
|
#Sender Mail
|
27
|
-
mail =
|
27
|
+
mail = Receipt.receiver(@entity1).message(@message1).first
|
28
28
|
assert mail
|
29
29
|
if mail
|
30
30
|
mail.read.should==true
|
@@ -32,7 +32,7 @@ describe "Mailboxer Messages And Mails" do
|
|
32
32
|
mail.mailbox_type.should=="sentbox"
|
33
33
|
end
|
34
34
|
#Receiver Mail
|
35
|
-
mail =
|
35
|
+
mail = Receipt.receiver(@entity2).message(@message1).first
|
36
36
|
assert mail
|
37
37
|
if mail
|
38
38
|
mail.read.should==false
|
@@ -67,7 +67,7 @@ describe "Mailboxer Messages And Mails" do
|
|
67
67
|
|
68
68
|
it "should create proper mails" do
|
69
69
|
#Sender Mail
|
70
|
-
mail =
|
70
|
+
mail = Receipt.receiver(@entity2).message(@message2).first
|
71
71
|
assert mail
|
72
72
|
if mail
|
73
73
|
mail.read.should==true
|
@@ -75,7 +75,7 @@ describe "Mailboxer Messages And Mails" do
|
|
75
75
|
mail.mailbox_type.should=="sentbox"
|
76
76
|
end
|
77
77
|
#Receiver Mail
|
78
|
-
mail =
|
78
|
+
mail = Receipt.receiver(@entity1).message(@message2).first
|
79
79
|
assert mail
|
80
80
|
if mail
|
81
81
|
mail.read.should==false
|
@@ -113,7 +113,7 @@ describe "Mailboxer Messages And Mails" do
|
|
113
113
|
|
114
114
|
it "should create proper mails" do
|
115
115
|
#Sender Mail
|
116
|
-
mail =
|
116
|
+
mail = Receipt.receiver(@entity2).message(@message2).first
|
117
117
|
assert mail
|
118
118
|
if mail
|
119
119
|
mail.read.should==true
|
@@ -121,7 +121,7 @@ describe "Mailboxer Messages And Mails" do
|
|
121
121
|
mail.mailbox_type.should=="sentbox"
|
122
122
|
end
|
123
123
|
#Receiver Mail
|
124
|
-
mail =
|
124
|
+
mail = Receipt.receiver(@entity1).message(@message2).first
|
125
125
|
assert mail
|
126
126
|
if mail
|
127
127
|
mail.read.should==false
|
@@ -158,7 +158,7 @@ describe "Mailboxer Messages And Mails" do
|
|
158
158
|
|
159
159
|
it "should create proper mails" do
|
160
160
|
#Sender Mail
|
161
|
-
mail =
|
161
|
+
mail = Receipt.receiver(@entity2).message(@message2).first
|
162
162
|
assert mail
|
163
163
|
if mail
|
164
164
|
mail.read.should==true
|
@@ -166,7 +166,7 @@ describe "Mailboxer Messages And Mails" do
|
|
166
166
|
mail.mailbox_type.should=="sentbox"
|
167
167
|
end
|
168
168
|
#Receiver Mail
|
169
|
-
mail =
|
169
|
+
mail = Receipt.receiver(@entity1).message(@message2).first
|
170
170
|
assert mail
|
171
171
|
if mail
|
172
172
|
mail.read.should==false
|
@@ -210,7 +210,7 @@ describe "Mailboxer Messages And Mails" do
|
|
210
210
|
|
211
211
|
it "should create proper mails" do
|
212
212
|
#Sender Mail
|
213
|
-
mail =
|
213
|
+
mail = Receipt.receiver(@entity1).message(@message1).first
|
214
214
|
assert mail
|
215
215
|
if mail
|
216
216
|
mail.read.should==true
|
@@ -218,7 +218,7 @@ describe "Mailboxer Messages And Mails" do
|
|
218
218
|
mail.mailbox_type.should=="sentbox"
|
219
219
|
end
|
220
220
|
#Receiver Mail
|
221
|
-
mail =
|
221
|
+
mail = Receipt.receiver(@entity2).message(@message1).first
|
222
222
|
assert mail
|
223
223
|
if mail
|
224
224
|
mail.read.should==false
|
@@ -253,7 +253,7 @@ describe "Mailboxer Messages And Mails" do
|
|
253
253
|
|
254
254
|
it "should create proper mails" do
|
255
255
|
#Sender Mail
|
256
|
-
mail =
|
256
|
+
mail = Receipt.receiver(@entity2).message(@message2).first
|
257
257
|
assert mail
|
258
258
|
if mail
|
259
259
|
mail.read.should==true
|
@@ -261,7 +261,7 @@ describe "Mailboxer Messages And Mails" do
|
|
261
261
|
mail.mailbox_type.should=="sentbox"
|
262
262
|
end
|
263
263
|
#Receiver Mail
|
264
|
-
mail =
|
264
|
+
mail = Receipt.receiver(@entity1).message(@message2).first
|
265
265
|
assert mail
|
266
266
|
if mail
|
267
267
|
mail.read.should==false
|
@@ -299,7 +299,7 @@ describe "Mailboxer Messages And Mails" do
|
|
299
299
|
|
300
300
|
it "should create proper mails" do
|
301
301
|
#Sender Mail
|
302
|
-
mail =
|
302
|
+
mail = Receipt.receiver(@entity2).message(@message2).first
|
303
303
|
assert mail
|
304
304
|
if mail
|
305
305
|
mail.read.should==true
|
@@ -307,7 +307,7 @@ describe "Mailboxer Messages And Mails" do
|
|
307
307
|
mail.mailbox_type.should=="sentbox"
|
308
308
|
end
|
309
309
|
#Receiver Mail
|
310
|
-
mail =
|
310
|
+
mail = Receipt.receiver(@entity1).message(@message2).first
|
311
311
|
assert mail
|
312
312
|
if mail
|
313
313
|
mail.read.should==false
|
@@ -376,7 +376,7 @@ describe "Mailboxer Messages And Mails" do
|
|
376
376
|
|
377
377
|
it "should create proper mails" do
|
378
378
|
#Sender Mail
|
379
|
-
mail =
|
379
|
+
mail = Receipt.receiver(@entity1).message(@message1).first
|
380
380
|
assert mail
|
381
381
|
if mail
|
382
382
|
mail.read.should==true
|
@@ -385,7 +385,7 @@ describe "Mailboxer Messages And Mails" do
|
|
385
385
|
end
|
386
386
|
#Receiver Mails
|
387
387
|
@recipients.each do |receiver|
|
388
|
-
mail =
|
388
|
+
mail = Receipt.receiver(receiver).message(@message1).first
|
389
389
|
assert mail
|
390
390
|
if mail
|
391
391
|
mail.read.should==false
|
@@ -422,7 +422,7 @@ describe "Mailboxer Messages And Mails" do
|
|
422
422
|
|
423
423
|
it "should create proper mails" do
|
424
424
|
#Sender Mail
|
425
|
-
mail =
|
425
|
+
mail = Receipt.receiver(@entity2).message(@message2).first
|
426
426
|
assert mail
|
427
427
|
if mail
|
428
428
|
mail.read.should==true
|
@@ -430,7 +430,7 @@ describe "Mailboxer Messages And Mails" do
|
|
430
430
|
mail.mailbox_type.should=="sentbox"
|
431
431
|
end
|
432
432
|
#Receiver Mail
|
433
|
-
mail =
|
433
|
+
mail = Receipt.receiver(@entity1).message(@message2).first
|
434
434
|
assert mail
|
435
435
|
if mail
|
436
436
|
mail.read.should==false
|
@@ -439,7 +439,7 @@ describe "Mailboxer Messages And Mails" do
|
|
439
439
|
end
|
440
440
|
|
441
441
|
#No Receiver, No Mail
|
442
|
-
mail =
|
442
|
+
mail = Receipt.receiver(@entity3).message(@message2).first
|
443
443
|
assert mail.nil?
|
444
444
|
|
445
445
|
end
|
@@ -478,7 +478,7 @@ describe "Mailboxer Messages And Mails" do
|
|
478
478
|
|
479
479
|
it "should create proper mails" do
|
480
480
|
#Sender Mail
|
481
|
-
mail =
|
481
|
+
mail = Receipt.receiver(@entity2).message(@message2).first
|
482
482
|
assert mail
|
483
483
|
if mail
|
484
484
|
mail.read.should==true
|
@@ -487,7 +487,7 @@ describe "Mailboxer Messages And Mails" do
|
|
487
487
|
end
|
488
488
|
#Receiver Mails
|
489
489
|
@recipients2.each do |receiver|
|
490
|
-
mail =
|
490
|
+
mail = Receipt.receiver(receiver).message(@message2).first
|
491
491
|
assert mail
|
492
492
|
if mail
|
493
493
|
mail.read.should==false
|
@@ -558,7 +558,7 @@ describe "Mailboxer Messages And Mails" do
|
|
558
558
|
|
559
559
|
it "should create proper mails" do
|
560
560
|
#Sender Mail
|
561
|
-
mail =
|
561
|
+
mail = Receipt.receiver(@entity1).message(@message1).first
|
562
562
|
assert mail
|
563
563
|
if mail
|
564
564
|
mail.read.should==true
|
@@ -567,7 +567,7 @@ describe "Mailboxer Messages And Mails" do
|
|
567
567
|
end
|
568
568
|
#Receiver Mails
|
569
569
|
@recipients.each do |receiver|
|
570
|
-
mail =
|
570
|
+
mail = Receipt.receiver(receiver).message(@message1).first
|
571
571
|
assert mail
|
572
572
|
if mail
|
573
573
|
mail.read.should==false
|
@@ -604,7 +604,7 @@ describe "Mailboxer Messages And Mails" do
|
|
604
604
|
|
605
605
|
it "should create proper mails" do
|
606
606
|
#Sender Mail
|
607
|
-
mail =
|
607
|
+
mail = Receipt.receiver(@entity2).message(@message2).first
|
608
608
|
assert mail
|
609
609
|
if mail
|
610
610
|
mail.read.should==true
|
@@ -612,7 +612,7 @@ describe "Mailboxer Messages And Mails" do
|
|
612
612
|
mail.mailbox_type.should=="sentbox"
|
613
613
|
end
|
614
614
|
#Receiver Mail
|
615
|
-
mail =
|
615
|
+
mail = Receipt.receiver(@entity1).message(@message2).first
|
616
616
|
assert mail
|
617
617
|
if mail
|
618
618
|
mail.read.should==false
|
@@ -621,7 +621,7 @@ describe "Mailboxer Messages And Mails" do
|
|
621
621
|
end
|
622
622
|
|
623
623
|
#No Receiver, No Mail
|
624
|
-
mail =
|
624
|
+
mail = Receipt.receiver(@entity3).message(@message2).first
|
625
625
|
assert mail.nil?
|
626
626
|
|
627
627
|
end
|
@@ -660,7 +660,7 @@ describe "Mailboxer Messages And Mails" do
|
|
660
660
|
|
661
661
|
it "should create proper mails" do
|
662
662
|
#Sender Mail
|
663
|
-
mail =
|
663
|
+
mail = Receipt.receiver(@entity2).message(@message2).first
|
664
664
|
assert mail
|
665
665
|
if mail
|
666
666
|
mail.read.should==true
|
@@ -669,7 +669,7 @@ describe "Mailboxer Messages And Mails" do
|
|
669
669
|
end
|
670
670
|
#Receiver Mails
|
671
671
|
@recipients2.each do |receiver|
|
672
|
-
mail =
|
672
|
+
mail = Receipt.receiver(receiver).message(@message2).first
|
673
673
|
assert mail
|
674
674
|
if mail
|
675
675
|
mail.read.should==false
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Mailbox do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@entity1 = Factory(:user)
|
7
|
+
@entity2 = Factory(: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.message
|
13
|
+
@message4 = @receipt4.message
|
14
|
+
@conversation = @message1.conversation
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return all conversations" do
|
18
|
+
@conv2 = @entity1.send_message(@entity2,"Body","Subject").conversation
|
19
|
+
@conv3 = @entity2.send_message(@entity1,"Body","Subject").conversation
|
20
|
+
@conv4 = @entity1.send_message(@entity2,"Body","Subject").conversation
|
21
|
+
|
22
|
+
assert @entity1.mailbox.conversations
|
23
|
+
|
24
|
+
@entity1.mailbox.conversations.to_a.count.should==4
|
25
|
+
@entity1.mailbox.conversations.to_a.count(@conversation).should==1
|
26
|
+
@entity1.mailbox.conversations.to_a.count(@conv2).should==1
|
27
|
+
@entity1.mailbox.conversations.to_a.count(@conv3).should==1
|
28
|
+
@entity1.mailbox.conversations.to_a.count(@conv4).should==1
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return all mail" do
|
32
|
+
assert @entity1.mailbox.receipts
|
33
|
+
@entity1.mailbox.receipts.count.should==4
|
34
|
+
@entity1.mailbox.receipts[0].should==Receipt.receiver(@entity1).conversation(@conversation)[0]
|
35
|
+
@entity1.mailbox.receipts[1].should==Receipt.receiver(@entity1).conversation(@conversation)[1]
|
36
|
+
@entity1.mailbox.receipts[2].should==Receipt.receiver(@entity1).conversation(@conversation)[2]
|
37
|
+
@entity1.mailbox.receipts[3].should==Receipt.receiver(@entity1).conversation(@conversation)[3]
|
38
|
+
|
39
|
+
assert @entity2.mailbox.receipts
|
40
|
+
@entity2.mailbox.receipts.count.should==4
|
41
|
+
@entity2.mailbox.receipts[0].should==Receipt.receiver(@entity2).conversation(@conversation)[0]
|
42
|
+
@entity2.mailbox.receipts[1].should==Receipt.receiver(@entity2).conversation(@conversation)[1]
|
43
|
+
@entity2.mailbox.receipts[2].should==Receipt.receiver(@entity2).conversation(@conversation)[2]
|
44
|
+
@entity2.mailbox.receipts[3].should==Receipt.receiver(@entity2).conversation(@conversation)[3]
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should return sentbox" do
|
48
|
+
assert @entity1.mailbox.receipts.inbox
|
49
|
+
@entity1.mailbox.receipts.sentbox.count.should==2
|
50
|
+
@entity1.mailbox.receipts.sentbox[0].should==@receipt1
|
51
|
+
@entity1.mailbox.receipts.sentbox[1].should==@receipt3
|
52
|
+
|
53
|
+
assert @entity2.mailbox.receipts.inbox
|
54
|
+
@entity2.mailbox.receipts.sentbox.count.should==2
|
55
|
+
@entity2.mailbox.receipts.sentbox[0].should==@receipt2
|
56
|
+
@entity2.mailbox.receipts.sentbox[1].should==@receipt4
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return inbox" do
|
60
|
+
assert @entity1.mailbox.receipts.inbox
|
61
|
+
@entity1.mailbox.receipts.inbox.count.should==2
|
62
|
+
@entity1.mailbox.receipts.inbox[0].should==Receipt.receiver(@entity1).inbox.conversation(@conversation)[0]
|
63
|
+
@entity1.mailbox.receipts.inbox[1].should==Receipt.receiver(@entity1).inbox.conversation(@conversation)[1]
|
64
|
+
|
65
|
+
assert @entity2.mailbox.receipts.inbox
|
66
|
+
@entity2.mailbox.receipts.inbox.count.should==2
|
67
|
+
@entity2.mailbox.receipts.inbox[0].should==Receipt.receiver(@entity2).inbox.conversation(@conversation)[0]
|
68
|
+
@entity2.mailbox.receipts.inbox[1].should==Receipt.receiver(@entity2).inbox.conversation(@conversation)[1]
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return trashed mails" do
|
72
|
+
@entity1.mailbox.receipts.move_to_trash
|
73
|
+
|
74
|
+
assert @entity1.mailbox.receipts.trash
|
75
|
+
@entity1.mailbox.receipts.trash.count.should==4
|
76
|
+
@entity1.mailbox.receipts.trash[0].should==Receipt.receiver(@entity1).conversation(@conversation)[0]
|
77
|
+
@entity1.mailbox.receipts.trash[1].should==Receipt.receiver(@entity1).conversation(@conversation)[1]
|
78
|
+
@entity1.mailbox.receipts.trash[2].should==Receipt.receiver(@entity1).conversation(@conversation)[2]
|
79
|
+
@entity1.mailbox.receipts.trash[3].should==Receipt.receiver(@entity1).conversation(@conversation)[3]
|
80
|
+
|
81
|
+
assert @entity2.mailbox.receipts.trash
|
82
|
+
@entity2.mailbox.receipts.trash.count.should==0
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should delete trashed mails (TODO)" do
|
86
|
+
@entity1.mailbox.receipts.move_to_trash
|
87
|
+
#TODO
|
88
|
+
#@entity1.mailbox.empty_trash
|
89
|
+
|
90
|
+
assert @entity1.mailbox.receipts.trash
|
91
|
+
#@entity1.mailbox.receipts.trash.count.should==0
|
92
|
+
|
93
|
+
assert @entity2.mailbox.receipts
|
94
|
+
@entity2.mailbox.receipts.count.should==4
|
95
|
+
|
96
|
+
assert @entity2.mailbox.receipts.trash
|
97
|
+
@entity2.mailbox.receipts.trash.count.should==0
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -16,13 +16,13 @@ describe "Mailboxer::Models::Messageable through User" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be able to reply to sender" do
|
19
|
-
@
|
20
|
-
assert @entity2.reply_to_sender(@
|
19
|
+
@receipt = @entity1.send_message(@entity2,"Body","Subject")
|
20
|
+
assert @entity2.reply_to_sender(@receipt,"Reply body")
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should be able to reply to all" do
|
24
|
-
@
|
25
|
-
assert @entity2.reply_to_all(@
|
24
|
+
@receipt = @entity1.send_message(@entity2,"Body","Subject")
|
25
|
+
assert @entity2.reply_to_all(@receipt,"Reply body")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should be able to reply to conversation (TODO)" do
|
@@ -30,69 +30,69 @@ describe "Mailboxer::Models::Messageable through User" do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should be able to unread an owned mail (mark as unread)" do
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@entity1.
|
36
|
-
@
|
33
|
+
@receipt = @entity1.send_message(@entity2,"Body","Subject")
|
34
|
+
@receipt.read.should==true
|
35
|
+
@entity1.unread_message(@receipt)
|
36
|
+
@receipt.read.should==false
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should be able to read an owned mail (mark as read)" do
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@entity1.
|
43
|
-
@entity1.
|
44
|
-
@
|
40
|
+
@receipt = @entity1.send_message(@entity2,"Body","Subject")
|
41
|
+
@receipt.read.should==true
|
42
|
+
@entity1.unread_message(@receipt)
|
43
|
+
@entity1.read_message(@receipt)
|
44
|
+
@receipt.read.should==true
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should be able to unread anot owned mail (mark as unread)" do
|
48
|
-
@
|
49
|
-
@
|
50
|
-
@entity2.
|
51
|
-
@
|
48
|
+
@receipt = @entity1.send_message(@entity2,"Body","Subject")
|
49
|
+
@receipt.read.should==true
|
50
|
+
@entity2.unread_message(@receipt) #Should not change
|
51
|
+
@receipt.read.should==true
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should be able to read a not owned mail (mark as read)" do
|
55
|
-
@
|
56
|
-
@
|
57
|
-
@entity1.
|
58
|
-
@entity2.
|
59
|
-
@
|
55
|
+
@receipt = @entity1.send_message(@entity2,"Body","Subject")
|
56
|
+
@receipt.read.should==true
|
57
|
+
@entity1.unread_message(@receipt) #From read to unread
|
58
|
+
@entity2.read_message(@receipt) #Should not change
|
59
|
+
@receipt.read.should==false
|
60
60
|
end
|
61
61
|
|
62
|
+
=begin
|
62
63
|
it "should be able to read owned mails of a conversation" do
|
63
|
-
@
|
64
|
-
@
|
65
|
-
@
|
66
|
-
@
|
67
|
-
@message1 = @
|
64
|
+
@receipt1 = @entity1.send_message(@entity2,"Body","Subject")
|
65
|
+
@receipt2 = @entity2.reply_to_all(@receipt1,"Reply body 1")
|
66
|
+
@receipt3 = @entity1.reply_to_all(@receipt2,"Reply body 2")
|
67
|
+
@receipt4 = @entity2.reply_to_all(@receipt3,"Reply body 3")
|
68
|
+
@message1 = @receipt1.message
|
68
69
|
@conversation = @message1.conversation
|
69
70
|
|
70
|
-
@
|
71
|
+
@conversation.mark_as_read(@entity1)
|
71
72
|
|
72
|
-
@
|
73
|
+
@receipts = @conversation.receipts(@entity1)
|
73
74
|
|
74
|
-
@
|
75
|
+
@receipts.each do |mail|
|
75
76
|
mail.read.should==true
|
76
|
-
end
|
77
|
-
|
77
|
+
end
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should not be able to read not owned mails of a conversation" do
|
81
|
-
@
|
82
|
-
@
|
83
|
-
@
|
84
|
-
@
|
85
|
-
@message1 = @
|
81
|
+
@receipt1 = @entity1.send_message(@entity2,"Body","Subject")
|
82
|
+
@receipt2 = @entity2.reply_to_all(@receipt1,"Reply body 1")
|
83
|
+
@receipt3 = @entity1.reply_to_all(@receipt2,"Reply body 2")
|
84
|
+
@receipt4 = @entity2.reply_to_all(@receipt3,"Reply body 3")
|
85
|
+
@message1 = @receipt1.message
|
86
86
|
@conversation = @message1.conversation
|
87
87
|
|
88
|
-
@
|
88
|
+
@conversation.mark_as_read(@entity2)
|
89
89
|
|
90
|
-
@
|
91
|
-
@
|
90
|
+
@receipts = @conversation.receipts(@entity1)
|
91
|
+
@receipts_total = @conversation.receipts
|
92
92
|
|
93
93
|
unread_mails = 0
|
94
94
|
|
95
|
-
@
|
95
|
+
@receipts.each do |mail|
|
96
96
|
unread_mails+=1 if !mail.read
|
97
97
|
end
|
98
98
|
|
@@ -101,7 +101,7 @@ describe "Mailboxer::Models::Messageable through User" do
|
|
101
101
|
|
102
102
|
|
103
103
|
end
|
104
|
-
|
104
|
+
=end
|
105
105
|
|
106
106
|
|
107
107
|
end
|