mailboxer 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe MailboxerMail do
3
+ describe Receipt do
4
4
 
5
5
  before do
6
6
  @entity1 = Factory(:user)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailboxer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eduardo Casanova Cuesta
@@ -193,10 +193,10 @@ files:
193
193
  - README.rdoc
194
194
  - Rakefile
195
195
  - VERSION
196
- - app/models/mailboxer_conversation.rb
197
- - app/models/mailboxer_mail.rb
198
- - app/models/mailboxer_mailbox.rb
199
- - app/models/mailboxer_message.rb
196
+ - app/models/conversation.rb
197
+ - app/models/mailbox.rb
198
+ - app/models/message.rb
199
+ - app/models/receipt.rb
200
200
  - lib/generators/mailboxer/install_generator.rb
201
201
  - lib/generators/mailboxer/templates/migration.rb
202
202
  - lib/mailboxer.rb
@@ -231,7 +231,7 @@ files:
231
231
  - spec/dummy/db/migrate/20110228120600_create_users.rb
232
232
  - spec/dummy/db/migrate/20110306002940_create_ducks.rb
233
233
  - spec/dummy/db/migrate/20110306015107_create_cylons.rb
234
- - spec/dummy/db/migrate/20110321231559_create_mailboxer.rb
234
+ - spec/dummy/db/migrate/20110322000127_create_mailboxer.rb
235
235
  - spec/dummy/db/schema.rb
236
236
  - spec/dummy/public/404.html
237
237
  - spec/dummy/public/422.html
@@ -249,13 +249,13 @@ files:
249
249
  - spec/factories/cylon.rb
250
250
  - spec/factories/duck.rb
251
251
  - spec/factories/user.rb
252
- - spec/integration/mailboxer_message_and_mail_spec.rb
252
+ - spec/integration/message_and_receipt_spec.rb
253
253
  - spec/integration/navigation_spec.rb
254
254
  - spec/mailboxer_spec.rb
255
- - spec/models/mailboxer_conversation_spec.rb
256
- - spec/models/mailboxer_mail_spec.rb
257
- - spec/models/mailboxer_mailbox_spec.rb
255
+ - spec/models/conversation_spec.rb
256
+ - spec/models/mailbox_spec.rb
258
257
  - spec/models/mailboxer_models_messageable_spec.rb
258
+ - spec/models/receipt_spec.rb
259
259
  - spec/spec_helper.rb
260
260
  has_rdoc: true
261
261
  homepage: http://github.com/ging/mailboxer
@@ -1,106 +0,0 @@
1
- class MailboxerConversation < ActiveRecord::Base
2
- attr_reader :originator, :original_message, :last_sender, :last_message, :users
3
- has_many :mailboxer_messages
4
- has_many :mailboxer_mails, :through => :mailboxer_messages
5
- # before_create :clean
6
- scope :participant, lambda {|participant|
7
- joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s).order("mailboxer_conversations.updated_at DESC")
8
- }
9
- scope :inbox, lambda {|participant|
10
- joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s, 'mailboxer_mails.mailbox_type' => 'inbox','mailboxer_mails.trashed' => false).order("mailboxer_conversations.updated_at DESC")
11
- }
12
- scope :sentbox, lambda {|participant|
13
- joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s, 'mailboxer_mails.mailbox_type' => 'sentbox','mailboxer_mails.trashed' => false).order("mailboxer_conversations.updated_at DESC")
14
- }
15
- scope :trash, lambda {|participant|
16
- joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s,'mailboxer_mails.trashed' => true).order("mailboxer_conversations.updated_at DESC")
17
- }
18
- scope :unread, lambda {|participant|
19
- joins(:mailboxer_mails).select('DISTINCT mailboxer_conversations.*').where('mailboxer_mails.receiver_id' => participant.id,'mailboxer_mails.receiver_type' => participant.class.to_s,'mailboxer_mails.read' => false).order("mailboxer_conversations.updated_at DESC")
20
- }
21
-
22
- class << self
23
- def total
24
- count('DISTINCT mailboxer_conversations.id')
25
- end
26
- end
27
-
28
- def mark_as_read(participant)
29
- return if participant.nil?
30
- return MailboxerMail.conversation(self).receiver(participant).mark_as_read
31
- end
32
-
33
- def mark_as_unread(participant)
34
- return if participant.nil?
35
- return MailboxerMail.conversation(self).receiver(participant).mark_as_unread
36
- end
37
-
38
- def move_to_trash(participant)
39
- return if participant.nil?
40
- return MailboxerMail.conversation(self).receiver(participant).move_to_trash
41
- end
42
-
43
- def untrash(participant)
44
- return if participant.nil?
45
- return MailboxerMail.conversation(self).receiver(participant).untrash
46
- end
47
-
48
- #originator of the conversation.
49
- def originator
50
- @orignator = self.original_message.sender if @originator.nil?
51
- return @orignator
52
- end
53
-
54
- #first message of the conversation.
55
- def original_message
56
- @original_message = self.mailboxer_messages.find(:first, :order => 'created_at') if @original_message.nil?
57
- return @original_message
58
- end
59
-
60
- #sender of the last message.
61
- def last_sender
62
- @last_sender = self.last_message.sender if @last_sender.nil?
63
- return @last_sender
64
- end
65
-
66
- #last message in the conversation.
67
- def last_message
68
- @last_message = self.mailboxer_messages.find(:first, :order => 'created_at DESC') if @last_message.nil?
69
- return @last_message
70
- end
71
-
72
- def mails(participant=nil)
73
- return MailboxerMail.conversation(self).receiver(participant) if participant
74
- return MailboxerMail.conversation(self)
75
- end
76
-
77
- #all users involved in the conversation.
78
- def recipients
79
- return last_message.get_recipients
80
- end
81
-
82
- def get_recipients
83
- return self.recipients
84
- end
85
-
86
- def messages
87
- self.mailboxer_messages
88
- end
89
-
90
- def count_messages
91
- return MailboxerMessage.conversation(self).count
92
- end
93
-
94
- def is_participant?(participant)
95
- return false if participant.nil?
96
- return MailboxerMail.conversation(self).receiver(participant).count != 0
97
- end
98
- # protected
99
- # #[empty method]
100
- # #
101
- # #this gets called before_create. Implement this if you wish to clean out illegal content such as scripts or anything that will break layout. This is left empty because what is considered illegal content varies.
102
- # def clean
103
- # return if subject.nil?
104
- # #strip all illegal content here. (scripts, shit that will break layout, etc.)
105
- # end
106
- end
@@ -1,99 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe MailboxerMailbox do
4
-
5
- before do
6
- @entity1 = Factory(:user)
7
- @entity2 = Factory(:user)
8
- @mail1 = @entity1.send_message(@entity2,"Body","Subject")
9
- @mail2 = @entity2.reply_to_all(@mail1,"Reply body 1")
10
- @mail3 = @entity1.reply_to_all(@mail2,"Reply body 2")
11
- @mail4 = @entity2.reply_to_all(@mail3,"Reply body 3")
12
- @message1 = @mail1.message
13
- @message4 = @mail4.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.mail
33
- @entity1.mailbox.mail.count.should==4
34
- @entity1.mailbox.mail[0].should==MailboxerMail.receiver(@entity1).conversation(@conversation)[0]
35
- @entity1.mailbox.mail[1].should==MailboxerMail.receiver(@entity1).conversation(@conversation)[1]
36
- @entity1.mailbox.mail[2].should==MailboxerMail.receiver(@entity1).conversation(@conversation)[2]
37
- @entity1.mailbox.mail[3].should==MailboxerMail.receiver(@entity1).conversation(@conversation)[3]
38
-
39
- assert @entity2.mailbox.mail
40
- @entity2.mailbox.mail.count.should==4
41
- @entity2.mailbox.mail[0].should==MailboxerMail.receiver(@entity2).conversation(@conversation)[0]
42
- @entity2.mailbox.mail[1].should==MailboxerMail.receiver(@entity2).conversation(@conversation)[1]
43
- @entity2.mailbox.mail[2].should==MailboxerMail.receiver(@entity2).conversation(@conversation)[2]
44
- @entity2.mailbox.mail[3].should==MailboxerMail.receiver(@entity2).conversation(@conversation)[3]
45
- end
46
-
47
- it "should return sentbox" do
48
- assert @entity1.mailbox.mail.inbox
49
- @entity1.mailbox.mail.sentbox.count.should==2
50
- @entity1.mailbox.mail.sentbox[0].should==@mail1
51
- @entity1.mailbox.mail.sentbox[1].should==@mail3
52
-
53
- assert @entity2.mailbox.mail.inbox
54
- @entity2.mailbox.mail.sentbox.count.should==2
55
- @entity2.mailbox.mail.sentbox[0].should==@mail2
56
- @entity2.mailbox.mail.sentbox[1].should==@mail4
57
- end
58
-
59
- it "should return inbox" do
60
- assert @entity1.mailbox.mail.inbox
61
- @entity1.mailbox.mail.inbox.count.should==2
62
- @entity1.mailbox.mail.inbox[0].should==MailboxerMail.receiver(@entity1).inbox.conversation(@conversation)[0]
63
- @entity1.mailbox.mail.inbox[1].should==MailboxerMail.receiver(@entity1).inbox.conversation(@conversation)[1]
64
-
65
- assert @entity2.mailbox.mail.inbox
66
- @entity2.mailbox.mail.inbox.count.should==2
67
- @entity2.mailbox.mail.inbox[0].should==MailboxerMail.receiver(@entity2).inbox.conversation(@conversation)[0]
68
- @entity2.mailbox.mail.inbox[1].should==MailboxerMail.receiver(@entity2).inbox.conversation(@conversation)[1]
69
- end
70
-
71
- it "should return trashed mails" do
72
- @entity1.mailbox.mail.move_to_trash
73
-
74
- assert @entity1.mailbox.mail.trash
75
- @entity1.mailbox.mail.trash.count.should==4
76
- @entity1.mailbox.mail.trash[0].should==MailboxerMail.receiver(@entity1).conversation(@conversation)[0]
77
- @entity1.mailbox.mail.trash[1].should==MailboxerMail.receiver(@entity1).conversation(@conversation)[1]
78
- @entity1.mailbox.mail.trash[2].should==MailboxerMail.receiver(@entity1).conversation(@conversation)[2]
79
- @entity1.mailbox.mail.trash[3].should==MailboxerMail.receiver(@entity1).conversation(@conversation)[3]
80
-
81
- assert @entity2.mailbox.mail.trash
82
- @entity2.mailbox.mail.trash.count.should==0
83
- end
84
-
85
- it "should delete trashed mails" do
86
- @entity1.mailbox.mail.move_to_trash
87
- @entity1.mailbox.empty_trash
88
-
89
- assert @entity1.mailbox.mail.trash
90
- @entity1.mailbox.mail.trash.count.should==0
91
-
92
- assert @entity2.mailbox.mail
93
- @entity2.mailbox.mail.count.should==4
94
-
95
- assert @entity2.mailbox.mail.trash
96
- @entity2.mailbox.mail.trash.count.should==0
97
- end
98
-
99
- end