This commit is contained in:
albert
2013-03-02 22:45:15 -05:00
parent ed182f4cac
commit 68ac05e31c
2 changed files with 8 additions and 1 deletions

View File

@@ -154,7 +154,7 @@ class Dmail < ActiveRecord::Base
end
def send_dmail
if to.receive_email_notifications? && to.email.include?("@")
if to.receive_email_notifications? && to.email.include?("@") && owner_id == CurrentUser.id
UserMailer.dmail_notice(self).deliver
end
end

View File

@@ -62,6 +62,13 @@ class DmailTest < ActiveSupport::TestCase
FactoryGirl.create(:dmail, :to => user, :owner => @user)
end
end
should "create only one message for a split response" do
user = FactoryGirl.create(:user, :receive_email_notifications => true)
assert_difference("ActionMailer::Base.deliveries.size", 1) do
Dmail.create_split(:to_id => user.id, :title => "foo", :body => "foo")
end
end
should "be marked as read after the user reads it" do
dmail = FactoryGirl.create(:dmail, :owner => @user)