mailboxer 0.12.4 → 0.12.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -3
- data/app/models/mailboxer/receipt.rb +4 -11
- data/gemfiles/rails4.2.gemfile +7 -0
- data/lib/generators/mailboxer/views_generator.rb +2 -2
- data/lib/mailboxer/mail_dispatcher.rb +2 -2
- data/lib/mailboxer/version.rb +1 -1
- data/mailboxer.gemspec +3 -1
- data/spec/dummy/config/application.rb +5 -0
- data/spec/integration/message_and_receipt_spec.rb +208 -208
- data/spec/integration/navigation_spec.rb +2 -3
- data/spec/mailboxer/mail_dispatcher_spec.rb +10 -10
- data/spec/mailboxer_spec.rb +1 -1
- data/spec/mailers/message_mailer_spec.rb +10 -10
- data/spec/mailers/notification_mailer_spec.rb +4 -5
- data/spec/models/conversation_spec.rb +27 -27
- data/spec/models/mailbox_spec.rb +56 -56
- data/spec/models/mailboxer_models_messageable_spec.rb +73 -73
- data/spec/models/message_spec.rb +10 -10
- data/spec/models/notification_spec.rb +60 -60
- data/spec/models/receipt_spec.rb +16 -17
- data/spec/spec_helper.rb +8 -0
- metadata +59 -30
@@ -13,22 +13,22 @@ describe Mailboxer::MailDispatcher do
|
|
13
13
|
context "no emails" do
|
14
14
|
before { Mailboxer.uses_emails = false }
|
15
15
|
after { Mailboxer.uses_emails = true }
|
16
|
-
its(:call) { should
|
16
|
+
its(:call) { should be false }
|
17
17
|
end
|
18
18
|
|
19
19
|
context "mailer wants array" do
|
20
20
|
before { Mailboxer.mailer_wants_array = true }
|
21
21
|
after { Mailboxer.mailer_wants_array = false }
|
22
22
|
it 'sends collection' do
|
23
|
-
subject.
|
23
|
+
expect(subject).to receive(:send_email).with(recipients)
|
24
24
|
subject.call
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
context "mailer doesnt want array" do
|
29
29
|
it 'sends collection' do
|
30
|
-
subject.
|
31
|
-
subject.
|
30
|
+
expect(subject).not_to receive(:send_email).with(recipient1) #email is blank
|
31
|
+
expect(subject).to receive(:send_email).with(recipient2)
|
32
32
|
subject.call
|
33
33
|
end
|
34
34
|
end
|
@@ -39,7 +39,7 @@ describe Mailboxer::MailDispatcher do
|
|
39
39
|
let(:mailer) { double 'mailer' }
|
40
40
|
|
41
41
|
before(:each) do
|
42
|
-
subject.
|
42
|
+
allow(subject).to receive(:mailer).and_return mailer
|
43
43
|
end
|
44
44
|
|
45
45
|
context "with custom_deliver_proc" do
|
@@ -48,7 +48,7 @@ describe Mailboxer::MailDispatcher do
|
|
48
48
|
before { Mailboxer.custom_deliver_proc = my_proc }
|
49
49
|
after { Mailboxer.custom_deliver_proc = nil }
|
50
50
|
it "triggers proc" do
|
51
|
-
my_proc.
|
51
|
+
expect(my_proc).to receive(:call).with(mailer, mailable, recipient1)
|
52
52
|
subject.send :send_email, recipient1
|
53
53
|
end
|
54
54
|
end
|
@@ -57,8 +57,8 @@ describe Mailboxer::MailDispatcher do
|
|
57
57
|
let(:email) { double :email }
|
58
58
|
|
59
59
|
it "triggers standard deliver chain" do
|
60
|
-
mailer.
|
61
|
-
email.
|
60
|
+
expect(mailer).to receive(:send_email).with(mailable, recipient1).and_return email
|
61
|
+
expect(email).to receive :deliver
|
62
62
|
|
63
63
|
subject.send :send_email, recipient1
|
64
64
|
end
|
@@ -99,8 +99,8 @@ describe Mailboxer::MailDispatcher do
|
|
99
99
|
let(:conversation) { double 'conversation' }
|
100
100
|
let(:mailable) { double 'mailable', :conversation => conversation }
|
101
101
|
before(:each) do
|
102
|
-
conversation.
|
103
|
-
conversation.
|
102
|
+
expect(conversation).to receive(:has_subscriber?).with(recipient1).and_return false
|
103
|
+
expect(conversation).to receive(:has_subscriber?).with(recipient2).and_return true
|
104
104
|
end
|
105
105
|
|
106
106
|
its(:filtered_recipients){ should eq [recipient2] }
|
data/spec/mailboxer_spec.rb
CHANGED
@@ -19,20 +19,20 @@ describe Mailboxer::MessageMailer do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should send emails when should_email? is true (1 out of 3)" do
|
22
|
-
ActionMailer::Base.deliveries.
|
23
|
-
ActionMailer::Base.deliveries.
|
22
|
+
expect(ActionMailer::Base.deliveries).not_to be_empty
|
23
|
+
expect(ActionMailer::Base.deliveries).to have(1).item
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should send an email to user entity" do
|
27
|
-
sent_to?(entity1).
|
27
|
+
expect(sent_to?(entity1)).to be true
|
28
28
|
end
|
29
29
|
|
30
30
|
it "shouldn't send an email to duck entity" do
|
31
|
-
sent_to?(entity2).
|
31
|
+
expect(sent_to?(entity2)).to be false
|
32
32
|
end
|
33
33
|
|
34
34
|
it "shouldn't send an email to cylon entity" do
|
35
|
-
sent_to?(entity3).
|
35
|
+
expect(sent_to?(entity3)).to be false
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -43,20 +43,20 @@ describe Mailboxer::MessageMailer do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should send emails when should_email? is true (1 out of 3)" do
|
46
|
-
ActionMailer::Base.deliveries.
|
47
|
-
ActionMailer::Base.deliveries.
|
46
|
+
expect(ActionMailer::Base.deliveries).not_to be_empty
|
47
|
+
expect(ActionMailer::Base.deliveries).to have(2).items
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should send an email to user entity" do
|
51
|
-
sent_to?(entity1).
|
51
|
+
expect(sent_to?(entity1)).to be true
|
52
52
|
end
|
53
53
|
|
54
54
|
it "shouldn't send an email to duck entity" do
|
55
|
-
sent_to?(entity2).
|
55
|
+
expect(sent_to?(entity2)).to be false
|
56
56
|
end
|
57
57
|
|
58
58
|
it "shouldn't send an email to cylon entity" do
|
59
|
-
sent_to?(entity3).
|
59
|
+
expect(sent_to?(entity3)).to be false
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -9,8 +9,7 @@ describe Mailboxer::NotificationMailer do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should send emails when should_email? is true (2 out of 3)" do
|
12
|
-
ActionMailer::Base.deliveries.
|
13
|
-
ActionMailer::Base.deliveries.size.should==2
|
12
|
+
expect(ActionMailer::Base.deliveries.size).to eq 2
|
14
13
|
end
|
15
14
|
|
16
15
|
it "should send an email to user entity" do
|
@@ -20,7 +19,7 @@ describe Mailboxer::NotificationMailer do
|
|
20
19
|
temp = true
|
21
20
|
end
|
22
21
|
end
|
23
|
-
temp.
|
22
|
+
expect(temp).to be true
|
24
23
|
end
|
25
24
|
|
26
25
|
it "should send an email to duck entity" do
|
@@ -30,7 +29,7 @@ describe Mailboxer::NotificationMailer do
|
|
30
29
|
temp = true
|
31
30
|
end
|
32
31
|
end
|
33
|
-
temp.
|
32
|
+
expect(temp).to be true
|
34
33
|
end
|
35
34
|
|
36
35
|
it "shouldn't send an email to cylon entity" do
|
@@ -40,7 +39,7 @@ describe Mailboxer::NotificationMailer do
|
|
40
39
|
temp = true
|
41
40
|
end
|
42
41
|
end
|
43
|
-
temp.
|
42
|
+
expect(temp).to be false
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
@@ -16,57 +16,57 @@ describe Mailboxer::Conversation do
|
|
16
16
|
it { should ensure_length_of(:subject).is_at_most(Mailboxer.subject_max_length) }
|
17
17
|
|
18
18
|
it "should have proper original message" do
|
19
|
-
conversation.original_message.
|
19
|
+
expect(conversation.original_message).to eq message1
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should have proper originator (first sender)" do
|
23
|
-
conversation.originator.
|
23
|
+
expect(conversation.originator).to eq entity1
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should have proper last message" do
|
27
|
-
conversation.last_message.
|
27
|
+
expect(conversation.last_message).to eq message4
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should have proper last sender" do
|
31
|
-
conversation.last_sender.
|
31
|
+
expect(conversation.last_sender).to eq entity2
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should have all conversation users" do
|
35
|
-
conversation.recipients.count.
|
36
|
-
conversation.recipients.count.
|
37
|
-
conversation.recipients.count(entity1).
|
38
|
-
conversation.recipients.count(entity2).
|
35
|
+
expect(conversation.recipients.count).to eq 2
|
36
|
+
expect(conversation.recipients.count).to eq 2
|
37
|
+
expect(conversation.recipients.count(entity1)).to eq 1
|
38
|
+
expect(conversation.recipients.count(entity2)).to eq 1
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should be able to be marked as deleted" do
|
42
42
|
conversation.move_to_trash(entity1)
|
43
43
|
conversation.mark_as_deleted(entity1)
|
44
|
-
conversation.
|
44
|
+
expect(conversation).to be_is_deleted(entity1)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should be removed from the database once deleted by all participants" do
|
48
48
|
conversation.mark_as_deleted(entity1)
|
49
49
|
conversation.mark_as_deleted(entity2)
|
50
|
-
Mailboxer::Conversation.exists?(conversation.id).
|
50
|
+
expect(Mailboxer::Conversation.exists?(conversation.id)).to be false
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should be able to be marked as read" do
|
54
54
|
conversation.mark_as_read(entity1)
|
55
|
-
conversation.
|
55
|
+
expect(conversation).to be_is_read(entity1)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should be able to be marked as unread" do
|
59
59
|
conversation.mark_as_read(entity1)
|
60
60
|
conversation.mark_as_unread(entity1)
|
61
|
-
conversation.
|
61
|
+
expect(conversation).to be_is_unread(entity1)
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should be able to add a new participant" do
|
65
65
|
new_user = FactoryGirl.create(:user)
|
66
66
|
conversation.add_participant(new_user)
|
67
|
-
conversation.participants.count.
|
68
|
-
conversation.participants.
|
69
|
-
conversation.receipts_for(new_user).count.
|
67
|
+
expect(conversation.participants.count).to eq 3
|
68
|
+
expect(conversation.participants).to include(new_user, entity1, entity2)
|
69
|
+
expect(conversation.receipts_for(new_user).count).to eq conversation.receipts_for(entity1).count
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should deliver messages to new participants" do
|
@@ -85,19 +85,19 @@ describe Mailboxer::Conversation do
|
|
85
85
|
|
86
86
|
describe ".participant" do
|
87
87
|
it "finds conversations with receipts for participant" do
|
88
|
-
Mailboxer::Conversation.participant(participant).
|
88
|
+
expect(Mailboxer::Conversation.participant(participant)).to eq [sentbox_conversation, inbox_conversation]
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe ".inbox" do
|
93
93
|
it "finds inbox conversations with receipts for participant" do
|
94
|
-
Mailboxer::Conversation.inbox(participant).
|
94
|
+
expect(Mailboxer::Conversation.inbox(participant)).to eq [inbox_conversation]
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
describe ".sentbox" do
|
99
99
|
it "finds sentbox conversations with receipts for participant" do
|
100
|
-
Mailboxer::Conversation.sentbox(participant).
|
100
|
+
expect(Mailboxer::Conversation.sentbox(participant)).to eq [sentbox_conversation]
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -106,7 +106,7 @@ describe Mailboxer::Conversation do
|
|
106
106
|
trashed_conversation = entity1.send_message(participant, "Body", "Subject").notification.conversation
|
107
107
|
trashed_conversation.move_to_trash(participant)
|
108
108
|
|
109
|
-
Mailboxer::Conversation.trash(participant).
|
109
|
+
expect(Mailboxer::Conversation.trash(participant)).to eq [trashed_conversation]
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -115,7 +115,7 @@ describe Mailboxer::Conversation do
|
|
115
115
|
[sentbox_conversation, inbox_conversation].each {|c| c.mark_as_read(participant) }
|
116
116
|
unread_conversation = entity1.send_message(participant, "Body", "Subject").notification.conversation
|
117
117
|
|
118
|
-
Mailboxer::Conversation.unread(participant).
|
118
|
+
expect(Mailboxer::Conversation.unread(participant)).to eq [unread_conversation]
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -123,18 +123,18 @@ describe Mailboxer::Conversation do
|
|
123
123
|
describe "#is_completely_trashed?" do
|
124
124
|
it "returns true if all receipts in conversation are trashed for participant" do
|
125
125
|
conversation.move_to_trash(entity1)
|
126
|
-
conversation.is_completely_trashed?(entity1).
|
126
|
+
expect(conversation.is_completely_trashed?(entity1)).to be true
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
describe "#is_deleted?" do
|
131
131
|
it "returns false if a recipient has not deleted the conversation" do
|
132
|
-
conversation.is_deleted?(entity1).
|
132
|
+
expect(conversation.is_deleted?(entity1)).to be false
|
133
133
|
end
|
134
134
|
|
135
135
|
it "returns true if a recipient has deleted the conversation" do
|
136
136
|
conversation.mark_as_deleted(entity1)
|
137
|
-
conversation.is_deleted?(entity1).
|
137
|
+
expect(conversation.is_deleted?(entity1)).to be true
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
@@ -142,12 +142,12 @@ describe Mailboxer::Conversation do
|
|
142
142
|
it "returns true if both participants have deleted the conversation" do
|
143
143
|
conversation.mark_as_deleted(entity1)
|
144
144
|
conversation.mark_as_deleted(entity2)
|
145
|
-
conversation.is_orphaned
|
145
|
+
expect(conversation.is_orphaned?).to be true
|
146
146
|
end
|
147
147
|
|
148
148
|
it "returns false if one has not deleted the conversation" do
|
149
149
|
conversation.mark_as_deleted(entity1)
|
150
|
-
conversation.is_orphaned
|
150
|
+
expect(conversation.is_orphaned?).to be false
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
@@ -207,7 +207,7 @@ describe Mailboxer::Conversation do
|
|
207
207
|
|
208
208
|
context 'participant opted in' do
|
209
209
|
it "returns true" do
|
210
|
-
expect(action).to
|
210
|
+
expect(action).to be true
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
@@ -216,7 +216,7 @@ describe Mailboxer::Conversation do
|
|
216
216
|
conversation.opt_out(entity1)
|
217
217
|
end
|
218
218
|
it 'returns false' do
|
219
|
-
expect(action).to
|
219
|
+
expect(action).to be false
|
220
220
|
end
|
221
221
|
end
|
222
222
|
end
|
data/spec/models/mailbox_spec.rb
CHANGED
@@ -21,71 +21,71 @@ describe Mailboxer::Mailbox do
|
|
21
21
|
|
22
22
|
assert @entity1.mailbox.conversations
|
23
23
|
|
24
|
-
@entity1.mailbox.conversations.to_a.count.
|
25
|
-
@entity1.mailbox.conversations.to_a.count(@conversation).
|
26
|
-
@entity1.mailbox.conversations.to_a.count(@conv2).
|
27
|
-
@entity1.mailbox.conversations.to_a.count(@conv3).
|
28
|
-
@entity1.mailbox.conversations.to_a.count(@conv4).
|
24
|
+
expect(@entity1.mailbox.conversations.to_a.count).to eq 4
|
25
|
+
expect(@entity1.mailbox.conversations.to_a.count(@conversation)).to eq 1
|
26
|
+
expect(@entity1.mailbox.conversations.to_a.count(@conv2)).to eq 1
|
27
|
+
expect(@entity1.mailbox.conversations.to_a.count(@conv3)).to eq 1
|
28
|
+
expect(@entity1.mailbox.conversations.to_a.count(@conv4)).to eq 1
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should return all mail" do
|
32
32
|
assert @entity1.mailbox.receipts
|
33
|
-
@entity1.mailbox.receipts.count.
|
34
|
-
@entity1.mailbox.receipts[0].
|
35
|
-
@entity1.mailbox.receipts[1].
|
36
|
-
@entity1.mailbox.receipts[2].
|
37
|
-
@entity1.mailbox.receipts[3].
|
33
|
+
expect(@entity1.mailbox.receipts.count).to eq 4
|
34
|
+
expect(@entity1.mailbox.receipts[0]).to eq Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[0]
|
35
|
+
expect(@entity1.mailbox.receipts[1]).to eq Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[1]
|
36
|
+
expect(@entity1.mailbox.receipts[2]).to eq Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[2]
|
37
|
+
expect(@entity1.mailbox.receipts[3]).to eq Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[3]
|
38
38
|
|
39
39
|
assert @entity2.mailbox.receipts
|
40
|
-
@entity2.mailbox.receipts.count.
|
41
|
-
@entity2.mailbox.receipts[0].
|
42
|
-
@entity2.mailbox.receipts[1].
|
43
|
-
@entity2.mailbox.receipts[2].
|
44
|
-
@entity2.mailbox.receipts[3].
|
40
|
+
expect(@entity2.mailbox.receipts.count).to eq 4
|
41
|
+
expect(@entity2.mailbox.receipts[0]).to eq Mailboxer::Receipt.recipient(@entity2).conversation(@conversation)[0]
|
42
|
+
expect(@entity2.mailbox.receipts[1]).to eq Mailboxer::Receipt.recipient(@entity2).conversation(@conversation)[1]
|
43
|
+
expect(@entity2.mailbox.receipts[2]).to eq Mailboxer::Receipt.recipient(@entity2).conversation(@conversation)[2]
|
44
|
+
expect(@entity2.mailbox.receipts[3]).to eq 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
|
-
@entity1.mailbox.receipts.sentbox.count.
|
50
|
-
@entity1.mailbox.receipts.sentbox[0].
|
51
|
-
@entity1.mailbox.receipts.sentbox[1].
|
49
|
+
expect(@entity1.mailbox.receipts.sentbox.count).to eq 2
|
50
|
+
expect(@entity1.mailbox.receipts.sentbox[0]).to eq @receipt1
|
51
|
+
expect(@entity1.mailbox.receipts.sentbox[1]).to eq @receipt3
|
52
52
|
|
53
53
|
assert @entity2.mailbox.receipts.inbox
|
54
|
-
@entity2.mailbox.receipts.sentbox.count.
|
55
|
-
@entity2.mailbox.receipts.sentbox[0].
|
56
|
-
@entity2.mailbox.receipts.sentbox[1].
|
54
|
+
expect(@entity2.mailbox.receipts.sentbox.count).to eq 2
|
55
|
+
expect(@entity2.mailbox.receipts.sentbox[0]).to eq @receipt2
|
56
|
+
expect(@entity2.mailbox.receipts.sentbox[1]).to eq @receipt4
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should return inbox" do
|
60
60
|
assert @entity1.mailbox.receipts.inbox
|
61
|
-
@entity1.mailbox.receipts.inbox.count.
|
62
|
-
@entity1.mailbox.receipts.inbox[0].
|
63
|
-
@entity1.mailbox.receipts.inbox[1].
|
61
|
+
expect(@entity1.mailbox.receipts.inbox.count).to eq 2
|
62
|
+
expect(@entity1.mailbox.receipts.inbox[0]).to eq Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[0]
|
63
|
+
expect(@entity1.mailbox.receipts.inbox[1]).to eq Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[1]
|
64
64
|
|
65
65
|
assert @entity2.mailbox.receipts.inbox
|
66
|
-
@entity2.mailbox.receipts.inbox.count.
|
67
|
-
@entity2.mailbox.receipts.inbox[0].
|
68
|
-
@entity2.mailbox.receipts.inbox[1].
|
66
|
+
expect(@entity2.mailbox.receipts.inbox.count).to eq 2
|
67
|
+
expect(@entity2.mailbox.receipts.inbox[0]).to eq Mailboxer::Receipt.recipient(@entity2).inbox.conversation(@conversation)[0]
|
68
|
+
expect(@entity2.mailbox.receipts.inbox[1]).to eq Mailboxer::Receipt.recipient(@entity2).inbox.conversation(@conversation)[1]
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should understand the read option" do
|
72
|
-
@entity1.mailbox.inbox({:read => false}).count.
|
72
|
+
expect(@entity1.mailbox.inbox({:read => false}).count).not_to eq 0
|
73
73
|
@conversation.mark_as_read(@entity1)
|
74
|
-
@entity1.mailbox.inbox({:read => false}).count.
|
74
|
+
expect(@entity1.mailbox.inbox({:read => false}).count).to eq 0
|
75
75
|
end
|
76
76
|
|
77
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
|
-
@entity1.mailbox.receipts.trash.count.
|
82
|
-
@entity1.mailbox.receipts.trash[0].
|
83
|
-
@entity1.mailbox.receipts.trash[1].
|
84
|
-
@entity1.mailbox.receipts.trash[2].
|
85
|
-
@entity1.mailbox.receipts.trash[3].
|
81
|
+
expect(@entity1.mailbox.receipts.trash.count).to eq 4
|
82
|
+
expect(@entity1.mailbox.receipts.trash[0]).to eq Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[0]
|
83
|
+
expect(@entity1.mailbox.receipts.trash[1]).to eq Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[1]
|
84
|
+
expect(@entity1.mailbox.receipts.trash[2]).to eq Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[2]
|
85
|
+
expect(@entity1.mailbox.receipts.trash[3]).to eq Mailboxer::Receipt.recipient(@entity1).conversation(@conversation)[3]
|
86
86
|
|
87
87
|
assert @entity2.mailbox.receipts.trash
|
88
|
-
@entity2.mailbox.receipts.trash.count.
|
88
|
+
expect(@entity2.mailbox.receipts.trash.count).to eq 0
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should delete trashed mails" do
|
@@ -93,49 +93,49 @@ describe Mailboxer::Mailbox do
|
|
93
93
|
@entity1.mailbox.empty_trash
|
94
94
|
|
95
95
|
assert @entity1.mailbox.receipts.trash
|
96
|
-
@entity1.mailbox.receipts.trash.count.
|
96
|
+
expect(@entity1.mailbox.receipts.trash.count).to eq 0
|
97
97
|
|
98
98
|
assert @entity2.mailbox.receipts
|
99
|
-
@entity2.mailbox.receipts.count.
|
99
|
+
expect(@entity2.mailbox.receipts.count).to eq 4
|
100
100
|
|
101
101
|
assert @entity2.mailbox.receipts.trash
|
102
|
-
@entity2.mailbox.receipts.trash.count.
|
102
|
+
expect(@entity2.mailbox.receipts.trash.count).to eq 0
|
103
103
|
end
|
104
104
|
|
105
105
|
it "should deleted messages are not shown in inbox" do
|
106
106
|
assert @entity1.mailbox.receipts.inbox
|
107
|
-
@entity1.mailbox.inbox.count.
|
108
|
-
@entity1.mailbox.receipts.inbox[0].
|
109
|
-
@entity1.mailbox.receipts.inbox[1].
|
107
|
+
expect(@entity1.mailbox.inbox.count).to eq 1
|
108
|
+
expect(@entity1.mailbox.receipts.inbox[0]).to eq Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[0]
|
109
|
+
expect(@entity1.mailbox.receipts.inbox[1]).to eq Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[1]
|
110
110
|
|
111
111
|
assert @entity1.mailbox.receipts.inbox.mark_as_deleted
|
112
|
-
@entity1.mailbox.inbox.count.
|
112
|
+
expect(@entity1.mailbox.inbox.count).to eq 0
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should deleted messages are not shown in sentbox" do
|
116
116
|
assert @entity1.mailbox.receipts.inbox
|
117
|
-
@entity1.mailbox.receipts.sentbox.count.
|
118
|
-
@entity1.mailbox.receipts.sentbox[0].
|
119
|
-
@entity1.mailbox.receipts.sentbox[1].
|
117
|
+
expect(@entity1.mailbox.receipts.sentbox.count).to eq 2
|
118
|
+
expect(@entity1.mailbox.receipts.sentbox[0]).to eq @receipt1
|
119
|
+
expect(@entity1.mailbox.receipts.sentbox[1]).to eq @receipt3
|
120
120
|
|
121
121
|
assert @entity1.mailbox.receipts.sentbox.mark_as_deleted
|
122
|
-
@entity1.mailbox.sentbox.count.
|
122
|
+
expect(@entity1.mailbox.sentbox.count).to eq 0
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should reply for deleted messages return to inbox" do
|
126
126
|
assert @entity1.mailbox.receipts.inbox
|
127
|
-
@entity1.mailbox.inbox.count.
|
128
|
-
@entity1.mailbox.receipts.inbox[0].
|
129
|
-
@entity1.mailbox.receipts.inbox[1].
|
127
|
+
expect(@entity1.mailbox.inbox.count).to eq 1
|
128
|
+
expect(@entity1.mailbox.receipts.inbox[0]).to eq Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[0]
|
129
|
+
expect(@entity1.mailbox.receipts.inbox[1]).to eq Mailboxer::Receipt.recipient(@entity1).inbox.conversation(@conversation)[1]
|
130
130
|
|
131
131
|
assert @entity1.mailbox.receipts.inbox.mark_as_deleted
|
132
|
-
@entity1.mailbox.inbox.count.
|
132
|
+
expect(@entity1.mailbox.inbox.count).to eq 0
|
133
133
|
|
134
134
|
@entity2.reply_to_all(@receipt1,"Reply body 1")
|
135
|
-
@entity1.mailbox.inbox.count.
|
135
|
+
expect(@entity1.mailbox.inbox.count).to eq 1
|
136
136
|
|
137
137
|
@entity2.reply_to_all(@receipt3,"Reply body 3")
|
138
|
-
@entity1.mailbox.inbox.count.
|
138
|
+
expect(@entity1.mailbox.inbox.count).to eq 1
|
139
139
|
end
|
140
140
|
|
141
141
|
context "STI models" do
|
@@ -146,13 +146,13 @@ describe Mailboxer::Mailbox do
|
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should add one to senders sentbox" do
|
149
|
-
@sti_entity1.mailbox.sentbox.count.
|
150
|
-
@sti_entity1.mailbox.sentbox.
|
149
|
+
expect(@sti_entity1.mailbox.sentbox.count).to eq 1
|
150
|
+
expect(@sti_entity1.mailbox.sentbox).to include(@sti_mail.conversation)
|
151
151
|
end
|
152
152
|
|
153
153
|
it "should add one to recievers inbox" do
|
154
|
-
@sti_entity2.mailbox.inbox.count.
|
155
|
-
@sti_entity2.mailbox.inbox.
|
154
|
+
expect(@sti_entity2.mailbox.inbox.count).to eq 1
|
155
|
+
expect(@sti_entity2.mailbox.inbox).to include(@sti_mail.conversation)
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|