Skip to content

Commit

Permalink
Small fixes. Closes #1. Still crashes in update_all actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roendal committed Jun 20, 2011
1 parent aa6c39a commit e57bf68
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/models/conversation.rb
Expand Up @@ -87,7 +87,7 @@ def last_message

#Returns the receipts of the conversation for one participants
def receipts_for(participant)
return Receipt.conversation(self).receiver(participant)
return Receipt.conversation(self).receiver(participant)
end

#Returns the number of messages of the conversation
Expand Down
2 changes: 1 addition & 1 deletion app/models/message.rb
Expand Up @@ -3,7 +3,7 @@ class Message < Notification
belongs_to :conversation, :validate => true, :autosave => true
validates_presence_of :sender

class_inheritable_accessor :on_deliver_callback
class_attribute :on_deliver_callback
protected :on_deliver_callback
scope :conversation, lambda { |conversation|
where(:conversation_id => conversation.id)
Expand Down
2 changes: 1 addition & 1 deletion app/models/receipt.rb
Expand Up @@ -16,7 +16,7 @@ class Receipt < ActiveRecord::Base
where(:notification_id => notification.id)
}
scope :conversation, lambda { |conversation|
joins(:notification).where('notifications.conversation_id' => conversation.id)
joins(:message).where('notifications.conversation_id' => conversation.id)
}
scope :sentbox, where(:mailbox_type => "sentbox")
scope :inbox, where(:mailbox_type => "inbox")
Expand Down
6 changes: 3 additions & 3 deletions lib/mailboxer/models/messageable.rb
Expand Up @@ -20,21 +20,21 @@ module InstanceMethods
#Returning any kind of indentification you want for the model
def name
super
rescue
rescue NameError
return "You should add method :name in your Messageable model"
end

#Returning the email address of the model
def email
super
rescue
rescue NameError
return "define_email@on_your.model"
end

#Returning whether an email should be sent for this object (Message or Notification)
def should_email?(object)
super
rescue
rescue NameError
return true
end

Expand Down
5 changes: 2 additions & 3 deletions mailboxer.gemspec
Expand Up @@ -16,21 +16,20 @@ Gem::Specification.new do |s|

# Development Gem dependencies
#
s.add_development_dependency('rails', '~> 3.0.5')
s.add_runtime_dependency('rails', '3.1.0.rc4')
# Testing database
s.add_development_dependency('sqlite3-ruby')
# Debugging
if RUBY_VERSION < '1.9'
s.add_development_dependency('ruby-debug', '~> 0.10.3')
end
# Specs
s.add_development_dependency('rspec-rails', '~> 2.5.0')
s.add_development_dependency('rspec-rails', '~> 2.6.1')
# Fixtures
s.add_development_dependency('factory_girl', '~> 1.3.2')
# Population
s.add_development_dependency('forgery', '~> 0.3.6')
# Integration testing
s.add_development_dependency('capybara', '~> 0.3.9')

end

9 changes: 9 additions & 0 deletions spec/models/conversation_spec.rb
Expand Up @@ -37,4 +37,13 @@
@conversation.recipients.count(@entity2).should==1
end

it "should be able to be marked as read" do
@conversation.move_to_trash(@entity1)
end

it "should be able to be marked as unread" do
@conversation.move_to_trash(@entity1)
@conversation.untrash(@entity1)
end

end

0 comments on commit e57bf68

Please sign in to comment.