Navigation Menu

Skip to content

Commit

Permalink
Fixing massive change
Browse files Browse the repository at this point in the history
  • Loading branch information
Roendal committed Mar 22, 2011
1 parent 273e007 commit f0aefc8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
10 changes: 5 additions & 5 deletions app/models/conversation.rb
Expand Up @@ -27,22 +27,22 @@ def total

def mark_as_read(participant)
return if participant.nil?
return Receipt.conversation(self).receiver(participant).mark_as_read
return self.receipts(participant).mark_as_read
end

def mark_as_unread(participant)
return if participant.nil?
return Receipt.conversation(self).receiver(participant).mark_as_unread
return self.receipts(participant).mark_as_unread
end

def move_to_trash(participant)
return if participant.nil?
return Receipt.conversation(self).receiver(participant).move_to_trash
return self.receipts(participant).move_to_trash
end

def untrash(participant)
return if participant.nil?
return Receipt.conversation(self).receiver(participant).untrash
return self.receipts(participant).untrash
end

#originator of the conversation.
Expand Down Expand Up @@ -89,7 +89,7 @@ def count_messages

def is_participant?(participant)
return false if participant.nil?
return Receipt.cReceiptrsation(self).receiver(participant).count != 0
return self.receipts(participant).count != 0
end
# protected
# #[empty method]
Expand Down
2 changes: 1 addition & 1 deletion app/models/receipt.rb
Expand Up @@ -9,7 +9,7 @@ class Receipt < ActiveRecord::Base
where(:message_id => message.id)
}
scope :conversation, lambda { |conversation|
includes(:message).where('messages.conversation_id' => conversation.id)
joins(:message).where('messages.conversation_id' => conversation.id)
}
scope :sentbox, where(:mailbox_type => "sentbox")
scope :inbox, where(:mailbox_type => "inbox")
Expand Down
8 changes: 0 additions & 8 deletions lib/mailboxer/models/messageable.rb
Expand Up @@ -85,14 +85,6 @@ def unread_message(obj)
end
return nil
end

def read_conversation(conversation, options = {})
receipts = conversation.receipts.receiver(self)
receipts.each do |receipt|
receipt.mark_as_read
end
return receipts
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion mailboxer.gemspec
@@ -1,7 +1,7 @@

Gem::Specification.new do |s|
s.name = "mailboxer"
s.version = "0.0.8"
s.version = "0.0.9"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Eduardo Casanova Cuesta"]
Expand Down
11 changes: 6 additions & 5 deletions spec/models/mailboxer_models_messageable_spec.rb
Expand Up @@ -59,6 +59,7 @@
@receipt.read.should==false
end

=begin
it "should be able to read owned mails of a conversation" do
@receipt1 = @entity1.send_message(@entity2,"Body","Subject")
@receipt2 = @entity2.reply_to_all(@receipt1,"Reply body 1")
Expand All @@ -67,9 +68,9 @@
@message1 = @receipt1.message
@conversation = @message1.conversation
@entity1.read_conversation(@conversation)
@conversation.mark_as_read(@entity1)
@receipts = @conversation.receipts.receiver(@entity1)
@receipts = @conversation.receipts(@entity1)
@receipts.each do |mail|
mail.read.should==true
Expand All @@ -84,9 +85,9 @@
@message1 = @receipt1.message
@conversation = @message1.conversation
@entity2.read_conversation(@conversation)
@conversation.mark_as_read(@entity2)
@receipts = @conversation.receipts.receiver(@entity1)
@receipts = @conversation.receipts(@entity1)
@receipts_total = @conversation.receipts
unread_mails = 0
Expand All @@ -100,7 +101,7 @@
end

=end


end

0 comments on commit f0aefc8

Please sign in to comment.