curationexperts-mailboxer 0.10.3.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/.travis.yml +10 -0
- data/.yardopts +2 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +20 -0
- data/README.md +273 -0
- data/Rakefile +7 -0
- data/app/mailers/message_mailer.rb +37 -0
- data/app/mailers/notification_mailer.rb +21 -0
- data/app/models/conversation.rb +143 -0
- data/app/models/mailbox.rb +121 -0
- data/app/models/message.rb +66 -0
- data/app/models/notification.rb +184 -0
- data/app/models/receipt.rb +151 -0
- data/app/uploaders/attachment_uploader.rb +3 -0
- data/app/views/message_mailer/new_message_email.html.erb +20 -0
- data/app/views/message_mailer/new_message_email.text.erb +10 -0
- data/app/views/message_mailer/reply_message_email.html.erb +20 -0
- data/app/views/message_mailer/reply_message_email.text.erb +10 -0
- data/app/views/notification_mailer/new_notification_email.html.erb +20 -0
- data/app/views/notification_mailer/new_notification_email.text.erb +10 -0
- data/config/locales/en.yml +7 -0
- data/db/migrate/20110511145103_create_mailboxer.rb +61 -0
- data/db/migrate/20110719110700_add_notified_object.rb +17 -0
- data/db/migrate/20110912163911_add_notification_code.rb +13 -0
- data/db/migrate/20111204163911_add_attachments.rb +9 -0
- data/db/migrate/20120813110712_rename_receipts_read.rb +9 -0
- data/db/migrate/20130305144212_add_global_notification_support.rb +9 -0
- data/lib/generators/mailboxer/install_generator.rb +35 -0
- data/lib/generators/mailboxer/templates/initializer.rb +17 -0
- data/lib/generators/mailboxer/views_generator.rb +9 -0
- data/lib/mailboxer.rb +31 -0
- data/lib/mailboxer/concerns/configurable_mailer.rb +13 -0
- data/lib/mailboxer/engine.rb +18 -0
- data/lib/mailboxer/models/messageable.rb +208 -0
- data/mailboxer.gemspec +47 -0
- data/spec/dummy/.gitignore +5 -0
- data/spec/dummy/Gemfile +33 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/home_controller.rb +4 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/cylon.rb +7 -0
- data/spec/dummy/app/models/duck.rb +11 -0
- data/spec/dummy/app/models/user.rb +6 -0
- data/spec/dummy/app/views/home/index.html.haml +7 -0
- data/spec/dummy/app/views/layouts/application.html.haml +11 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +42 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +24 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +33 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mailboxer.rb +17 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/config/sunspot.yml +17 -0
- data/spec/dummy/db/migrate/20110228120600_create_users.rb +14 -0
- data/spec/dummy/db/migrate/20110306002940_create_ducks.rb +14 -0
- data/spec/dummy/db/migrate/20110306015107_create_cylons.rb +14 -0
- data/spec/dummy/db/migrate/20120305103200_create_mailboxer.rb +61 -0
- data/spec/dummy/db/migrate/20120305103201_add_notified_object.rb +17 -0
- data/spec/dummy/db/migrate/20120305103202_add_notification_code.rb +13 -0
- data/spec/dummy/db/migrate/20120305103203_add_attachments.rb +5 -0
- data/spec/dummy/db/migrate/20120813110712_rename_receipts_read.rb +9 -0
- data/spec/dummy/db/migrate/20130305144212_add_global_notification_support.rb +11 -0
- data/spec/dummy/db/schema.rb +74 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/index.html +239 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/public/uploads/testfile.txt +1 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/cylon.rb +10 -0
- data/spec/factories/duck.rb +10 -0
- data/spec/factories/user.rb +10 -0
- data/spec/integration/message_and_receipt_spec.rb +903 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/mailboxer/concerns/configurable_mailer_spec.rb +27 -0
- data/spec/mailboxer_spec.rb +7 -0
- data/spec/mailers/message_mailer_spec.rb +110 -0
- data/spec/mailers/notification_mailer_spec.rb +61 -0
- data/spec/models/conversation_spec.rb +101 -0
- data/spec/models/mailbox_spec.rb +124 -0
- data/spec/models/mailboxer_models_messageable_spec.rb +315 -0
- data/spec/models/message_spec.rb +24 -0
- data/spec/models/notification_spec.rb +200 -0
- data/spec/models/receipt_spec.rb +44 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/testfile.txt +1 -0
- metadata +263 -0
@@ -0,0 +1,27 @@
|
|
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
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MessageMailer do
|
4
|
+
describe "when sending new message" do
|
5
|
+
before do
|
6
|
+
@sender = FactoryGirl.create(:user)
|
7
|
+
@entity1 = FactoryGirl.create(:user)
|
8
|
+
@entity2 = FactoryGirl.create(:duck)
|
9
|
+
@entity3 = FactoryGirl.create(:cylon)
|
10
|
+
@receipt1 = @sender.send_message([@entity1,@entity2,@entity3], "Body Body Body Body Body Body Body Body Body Body Body Body","Subject")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should send emails when should_email? is true (1 out of 3)" do
|
14
|
+
ActionMailer::Base.deliveries.empty?.should==false
|
15
|
+
ActionMailer::Base.deliveries.size.should==1
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should send an email to user entity" do
|
19
|
+
temp = false
|
20
|
+
ActionMailer::Base.deliveries.each do |email|
|
21
|
+
if email.to.first.to_s.eql? @entity1.email
|
22
|
+
temp = true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
temp.should==true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "shouldn't send an email to duck entity" do
|
29
|
+
temp = false
|
30
|
+
ActionMailer::Base.deliveries.each do |email|
|
31
|
+
if email.to.first.to_s.eql? @entity2.email
|
32
|
+
temp = true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
temp.should==false
|
36
|
+
end
|
37
|
+
|
38
|
+
it "shouldn't send an email to cylon entity" do
|
39
|
+
temp = false
|
40
|
+
ActionMailer::Base.deliveries.each do |email|
|
41
|
+
if email.to.first.to_s.eql? @entity3.email
|
42
|
+
temp = true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
temp.should==false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "when replying" do
|
50
|
+
before do
|
51
|
+
@sender = FactoryGirl.create(:user)
|
52
|
+
@entity1 = FactoryGirl.create(:user)
|
53
|
+
@entity2 = FactoryGirl.create(:duck)
|
54
|
+
@entity3 = FactoryGirl.create(:cylon)
|
55
|
+
@receipt1 = @sender.send_message([@entity1,@entity2,@entity3], "Body","Subject")
|
56
|
+
@receipt2 = @sender.reply_to_all(@receipt1, "Body")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should send emails when should_email? is true (1 out of 3)" do
|
60
|
+
ActionMailer::Base.deliveries.empty?.should==false
|
61
|
+
ActionMailer::Base.deliveries.size.should==2
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should send an email to user entity" do
|
65
|
+
temp = false
|
66
|
+
ActionMailer::Base.deliveries.each do |email|
|
67
|
+
if email.to.first.to_s.eql? @entity1.email
|
68
|
+
temp = true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
temp.should==true
|
72
|
+
end
|
73
|
+
|
74
|
+
it "shouldn't send an email to duck entity" do
|
75
|
+
temp = false
|
76
|
+
ActionMailer::Base.deliveries.each do |email|
|
77
|
+
if email.to.first.to_s.eql? @entity2.email
|
78
|
+
temp = true
|
79
|
+
end
|
80
|
+
end
|
81
|
+
temp.should==false
|
82
|
+
end
|
83
|
+
|
84
|
+
it "shouldn't send an email to cylon entity" do
|
85
|
+
temp = false
|
86
|
+
ActionMailer::Base.deliveries.each do |email|
|
87
|
+
if email.to.first.to_s.eql? @entity3.email
|
88
|
+
temp = true
|
89
|
+
end
|
90
|
+
end
|
91
|
+
temp.should==false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def print_emails
|
97
|
+
ActionMailer::Base.deliveries.each do |email|
|
98
|
+
puts "----------------------------------------------------"
|
99
|
+
puts email.to
|
100
|
+
puts "---"
|
101
|
+
puts email.from
|
102
|
+
puts "---"
|
103
|
+
puts email.subject
|
104
|
+
puts "---"
|
105
|
+
puts email.body
|
106
|
+
puts "---"
|
107
|
+
puts email.encoded
|
108
|
+
puts "----------------------------------------------------"
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NotificationMailer do
|
4
|
+
before do
|
5
|
+
@entity1 = FactoryGirl.create(:user)
|
6
|
+
@entity2 = FactoryGirl.create(:duck)
|
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")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should send emails when should_email? is true (2 out of 3)" do
|
12
|
+
ActionMailer::Base.deliveries.empty?.should==false
|
13
|
+
ActionMailer::Base.deliveries.size.should==2
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should send an email to user entity" do
|
17
|
+
temp = false
|
18
|
+
ActionMailer::Base.deliveries.each do |email|
|
19
|
+
if email.to.first.to_s.eql? @entity1.email
|
20
|
+
temp = true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
temp.should==true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should send an email to duck entity" do
|
27
|
+
temp = false
|
28
|
+
ActionMailer::Base.deliveries.each do |email|
|
29
|
+
if email.to.first.to_s.eql? @entity2.email
|
30
|
+
temp = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
temp.should==true
|
34
|
+
end
|
35
|
+
|
36
|
+
it "shouldn't send an email to cylon entity" do
|
37
|
+
temp = false
|
38
|
+
ActionMailer::Base.deliveries.each do |email|
|
39
|
+
if email.to.first.to_s.eql? @entity3.email
|
40
|
+
temp = true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
temp.should==false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def print_emails
|
48
|
+
ActionMailer::Base.deliveries.each do |email|
|
49
|
+
puts "----------------------------------------------------"
|
50
|
+
puts email.to
|
51
|
+
puts "---"
|
52
|
+
puts email.from
|
53
|
+
puts "---"
|
54
|
+
puts email.subject
|
55
|
+
puts "---"
|
56
|
+
puts email.body
|
57
|
+
puts "---"
|
58
|
+
puts email.encoded
|
59
|
+
puts "----------------------------------------------------"
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Conversation do
|
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
|
16
|
+
|
17
|
+
it "should have proper original message" do
|
18
|
+
@conversation.original_message.should==@message1
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have proper originator (first sender)" do
|
22
|
+
@conversation.originator.should==@entity1
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have proper last message" do
|
26
|
+
@conversation.last_message.should==@message4
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have proper last sender" do
|
30
|
+
@conversation.last_sender.should==@entity2
|
31
|
+
end
|
32
|
+
|
33
|
+
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
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should be able to be marked as read" do
|
41
|
+
#@conversation.move_to_trash(@entity1)
|
42
|
+
@conversation.mark_as_read(@entity1)
|
43
|
+
@conversation.should be_is_read(@entity)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be able to be marked as unread" do
|
47
|
+
@conversation.mark_as_read(@entity1)
|
48
|
+
@conversation.mark_as_unread(@entity1)
|
49
|
+
@conversation.should be_is_unread(@entity1)
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "scopes" do
|
53
|
+
let(:participant) { FactoryGirl.create(:user) }
|
54
|
+
let!(:inbox_conversation) { @entity1.send_message(participant, "Body", "Subject").notification.conversation }
|
55
|
+
let!(:sentbox_conversation) { participant.send_message(@entity1, "Body", "Subject").notification.conversation }
|
56
|
+
|
57
|
+
|
58
|
+
describe ".participant" do
|
59
|
+
it "finds conversations with receipts for participant" do
|
60
|
+
Conversation.participant(participant).should == [sentbox_conversation, inbox_conversation]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe ".inbox" do
|
65
|
+
it "finds inbox conversations with receipts for participant" do
|
66
|
+
Conversation.inbox(participant).should == [inbox_conversation]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe ".sentbox" do
|
71
|
+
it "finds sentbox conversations with receipts for participant" do
|
72
|
+
Conversation.sentbox(participant).should == [sentbox_conversation]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe ".trash" do
|
77
|
+
it "finds trash conversations with receipts for participant" do
|
78
|
+
trashed_conversation = @entity1.send_message(participant, "Body", "Subject").notification.conversation
|
79
|
+
trashed_conversation.move_to_trash(participant)
|
80
|
+
|
81
|
+
Conversation.trash(participant).should == [trashed_conversation]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe ".unread" do
|
86
|
+
it "finds unread conversations with receipts for participant" do
|
87
|
+
[sentbox_conversation, inbox_conversation].each {|c| c.mark_as_read(participant) }
|
88
|
+
unread_conversation = @entity1.send_message(participant, "Body", "Subject").notification.conversation
|
89
|
+
|
90
|
+
Conversation.unread(participant).should == [unread_conversation]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#is_completely_trashed?" do
|
96
|
+
it "returns true if all receipts in conversation are trashed for participant" do
|
97
|
+
@conversation.move_to_trash(@entity1)
|
98
|
+
@conversation.is_completely_trashed?(@entity1).should be_true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mailbox do
|
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
|
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.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
|
+
|
39
|
+
assert @entity2.mailbox.receipts
|
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]
|
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.recipient(@entity1).inbox.conversation(@conversation)[0]
|
63
|
+
@entity1.mailbox.receipts.inbox[1].should==Receipt.recipient(@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.recipient(@entity2).inbox.conversation(@conversation)[0]
|
68
|
+
@entity2.mailbox.receipts.inbox[1].should==Receipt.recipient(@entity2).inbox.conversation(@conversation)[1]
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should understand the read option" do
|
72
|
+
@entity1.mailbox.inbox({:read => false}).count.should_not == 0
|
73
|
+
@conversation.mark_as_read(@entity1)
|
74
|
+
@entity1.mailbox.inbox({:read => false}).count.should == 0
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should return trashed mails" do
|
78
|
+
@entity1.mailbox.receipts.move_to_trash
|
79
|
+
|
80
|
+
assert @entity1.mailbox.receipts.trash
|
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
|
+
|
87
|
+
assert @entity2.mailbox.receipts.trash
|
88
|
+
@entity2.mailbox.receipts.trash.count.should==0
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should delete trashed mails (TODO)" do
|
92
|
+
@entity1.mailbox.receipts.move_to_trash
|
93
|
+
#TODO
|
94
|
+
#@entity1.mailbox.empty_trash
|
95
|
+
|
96
|
+
assert @entity1.mailbox.receipts.trash
|
97
|
+
#@entity1.mailbox.receipts.trash.count.should==0
|
98
|
+
|
99
|
+
assert @entity2.mailbox.receipts
|
100
|
+
@entity2.mailbox.receipts.count.should==4
|
101
|
+
|
102
|
+
assert @entity2.mailbox.receipts.trash
|
103
|
+
@entity2.mailbox.receipts.trash.count.should==0
|
104
|
+
end
|
105
|
+
|
106
|
+
context "STI models" do
|
107
|
+
before do
|
108
|
+
@sti_entity1 = FactoryGirl.create(:user)
|
109
|
+
@sti_entity2 = FactoryGirl.create(:user)
|
110
|
+
@sti_mail = @sti_entity1.send_message(@sti_entity2, "Body", "Subject")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should add one to senders sentbox" do
|
114
|
+
@sti_entity1.mailbox.sentbox.count.should==1
|
115
|
+
@sti_entity1.mailbox.sentbox.should include(@sti_mail.conversation)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should add one to recievers inbox" do
|
119
|
+
@sti_entity2.mailbox.inbox.count.should == 1
|
120
|
+
@sti_entity2.mailbox.inbox.should include(@sti_mail.conversation)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|