mailboxer 0.10.3 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -5
- data/Appraisals +19 -0
- data/LICENSE.txt +1 -0
- data/README.md +45 -26
- data/Rakefile +4 -0
- data/app/mailers/message_mailer.rb +4 -4
- data/app/models/conversation.rb +114 -91
- data/app/models/mailbox.rb +16 -15
- data/app/models/message.rb +24 -22
- data/app/models/notification.rb +37 -24
- data/app/models/receipt.rb +37 -15
- data/gemfiles/rails3.0.gemfile +8 -0
- data/gemfiles/rails3.1.gemfile +8 -0
- data/gemfiles/rails3.2.gemfile +8 -0
- data/gemfiles/rails4.0.gemfile +8 -0
- data/lib/mailboxer.rb +13 -7
- data/lib/mailboxer/engine.rb +1 -2
- data/lib/mailboxer/models/messageable.rb +44 -22
- data/mailboxer.gemspec +9 -4
- data/spec/dummy/config/environments/test.rb +1 -3
- data/spec/mailers/message_mailer_spec.rb +69 -70
- data/spec/models/conversation_spec.rb +22 -0
- data/spec/models/mailbox_spec.rb +36 -0
- data/spec/models/mailboxer_models_messageable_spec.rb +8 -5
- data/spec/models/message_spec.rb +6 -0
- data/spec/models/receipt_spec.rb +13 -1
- metadata +25 -5
@@ -37,6 +37,12 @@ describe Conversation do
|
|
37
37
|
@conversation.recipients.count(@entity2).should==1
|
38
38
|
end
|
39
39
|
|
40
|
+
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)
|
44
|
+
end
|
45
|
+
|
40
46
|
it "should be able to be marked as read" do
|
41
47
|
#@conversation.move_to_trash(@entity1)
|
42
48
|
@conversation.mark_as_read(@entity1)
|
@@ -49,6 +55,22 @@ describe Conversation do
|
|
49
55
|
@conversation.should be_is_unread(@entity1)
|
50
56
|
end
|
51
57
|
|
58
|
+
it "should be able to add a new participant" do
|
59
|
+
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
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should deliver messages to new participants" do
|
67
|
+
new_user = FactoryGirl.create(:user)
|
68
|
+
@conversation.add_participant(new_user)
|
69
|
+
expect{
|
70
|
+
receipt5 = @entity1.reply_to_all(@receipt4,"Reply body 4")
|
71
|
+
}.to change{ @conversation.receipts_for(new_user).count }.by 1
|
72
|
+
end
|
73
|
+
|
52
74
|
describe "scopes" do
|
53
75
|
let(:participant) { FactoryGirl.create(:user) }
|
54
76
|
let!(:inbox_conversation) { @entity1.send_message(participant, "Body", "Subject").notification.conversation }
|
data/spec/models/mailbox_spec.rb
CHANGED
@@ -103,6 +103,42 @@ describe Mailbox do
|
|
103
103
|
@entity2.mailbox.receipts.trash.count.should==0
|
104
104
|
end
|
105
105
|
|
106
|
+
it "should deleted messages are not shown in inbox" do
|
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]
|
111
|
+
|
112
|
+
assert @entity1.mailbox.receipts.inbox.mark_as_deleted
|
113
|
+
@entity1.mailbox.inbox.count.should==0
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should deleted messages are not shown in sentbox" do
|
117
|
+
assert @entity1.mailbox.receipts.inbox
|
118
|
+
@entity1.mailbox.receipts.sentbox.count.should==2
|
119
|
+
@entity1.mailbox.receipts.sentbox[0].should==@receipt1
|
120
|
+
@entity1.mailbox.receipts.sentbox[1].should==@receipt3
|
121
|
+
|
122
|
+
assert @entity1.mailbox.receipts.sentbox.mark_as_deleted
|
123
|
+
@entity1.mailbox.sentbox.count.should==0
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should reply for deleted messages return to inbox" do
|
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]
|
131
|
+
|
132
|
+
assert @entity1.mailbox.receipts.inbox.mark_as_deleted
|
133
|
+
@entity1.mailbox.inbox.count.should==0
|
134
|
+
|
135
|
+
@entity2.reply_to_all(@receipt1,"Reply body 1")
|
136
|
+
@entity1.mailbox.inbox.count.should==1
|
137
|
+
|
138
|
+
@entity2.reply_to_all(@receipt3,"Reply body 3")
|
139
|
+
@entity1.mailbox.inbox.count.should==2
|
140
|
+
end
|
141
|
+
|
106
142
|
context "STI models" do
|
107
143
|
before do
|
108
144
|
@sti_entity1 = FactoryGirl.create(:user)
|
@@ -304,12 +304,15 @@ describe "Mailboxer::Models::Messageable through User" do
|
|
304
304
|
end
|
305
305
|
|
306
306
|
it "should be the same message time as passed" do
|
307
|
-
message_time = 5.days.ago
|
307
|
+
message_time = 5.days.ago
|
308
308
|
receipt = @entity1.send_message(@entity2, "Body", "Subject", nil, nil, message_time)
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
receipt.message.
|
309
|
+
# We're going to compare the string representation, because ActiveSupport::TimeWithZone
|
310
|
+
# has microsecond precision in ruby, but some databases don't support this level of precision.
|
311
|
+
expected = message_time.utc.to_s
|
312
|
+
receipt.message.created_at.utc.to_s.should == expected
|
313
|
+
receipt.message.updated_at.utc.to_s.should == expected
|
314
|
+
receipt.message.conversation.created_at.utc.to_s.should == expected
|
315
|
+
receipt.message.conversation.updated_at.utc.to_s.should == expected
|
313
316
|
end
|
314
317
|
|
315
318
|
end
|
data/spec/models/message_spec.rb
CHANGED
@@ -20,5 +20,11 @@ describe Message do
|
|
20
20
|
@receipt3.notification.recipients.count.should==2
|
21
21
|
@receipt4.notification.recipients.count.should==2
|
22
22
|
end
|
23
|
+
|
24
|
+
it "should be able to be marked as deleted" do
|
25
|
+
@receipt1.deleted.should==false
|
26
|
+
@message1.mark_as_deleted @entity1
|
27
|
+
@message1.is_deleted?(@entity1).should==true
|
28
|
+
end
|
23
29
|
|
24
30
|
end
|
data/spec/models/receipt_spec.rb
CHANGED
@@ -28,7 +28,19 @@ describe Receipt do
|
|
28
28
|
@mail1.mark_as_read
|
29
29
|
@mail1.is_read.should==true
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
|
+
it "should be able to be marked as deleted" do
|
33
|
+
@mail1.deleted.should==false
|
34
|
+
@mail1.mark_as_deleted
|
35
|
+
@mail1.deleted.should==true
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be able to be marked as not deleted" do
|
39
|
+
@mail1.deleted=true
|
40
|
+
@mail1.mark_as_not_deleted
|
41
|
+
@mail1.deleted.should==false
|
42
|
+
end
|
43
|
+
|
32
44
|
context "STI models" do
|
33
45
|
before do
|
34
46
|
@entity3 = FactoryGirl.create(:user)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailboxer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Casanova Cuesta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreigner
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.6.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: appraisal
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: factory_girl
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +123,7 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: 0.3.9
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name: sqlite3
|
126
|
+
name: sqlite3
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - '>='
|
@@ -137,6 +151,7 @@ files:
|
|
137
151
|
- .rspec
|
138
152
|
- .travis.yml
|
139
153
|
- .yardopts
|
154
|
+
- Appraisals
|
140
155
|
- Gemfile
|
141
156
|
- LICENSE.txt
|
142
157
|
- README.md
|
@@ -162,6 +177,10 @@ files:
|
|
162
177
|
- db/migrate/20111204163911_add_attachments.rb
|
163
178
|
- db/migrate/20120813110712_rename_receipts_read.rb
|
164
179
|
- db/migrate/20130305144212_add_global_notification_support.rb
|
180
|
+
- gemfiles/rails3.0.gemfile
|
181
|
+
- gemfiles/rails3.1.gemfile
|
182
|
+
- gemfiles/rails3.2.gemfile
|
183
|
+
- gemfiles/rails4.0.gemfile
|
165
184
|
- lib/generators/mailboxer/install_generator.rb
|
166
185
|
- lib/generators/mailboxer/templates/initializer.rb
|
167
186
|
- lib/generators/mailboxer/views_generator.rb
|
@@ -236,7 +255,8 @@ files:
|
|
236
255
|
- spec/spec_helper.rb
|
237
256
|
- spec/testfile.txt
|
238
257
|
homepage: https://github.com/ging/mailboxer
|
239
|
-
licenses:
|
258
|
+
licenses:
|
259
|
+
- MIT
|
240
260
|
metadata: {}
|
241
261
|
post_install_message:
|
242
262
|
rdoc_options: []
|
@@ -254,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
274
|
version: '0'
|
255
275
|
requirements: []
|
256
276
|
rubyforge_project:
|
257
|
-
rubygems_version: 2.0.
|
277
|
+
rubygems_version: 2.0.5
|
258
278
|
signing_key:
|
259
279
|
specification_version: 4
|
260
280
|
summary: Messaging system for rails apps.
|