Sha256: fff6a039aea4f15bf76e91b76a8a316c94754f036094f6f1a5fc61a84150d027

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'test_helper'

class PrivateMessagesTest < ActiveSupport::TestCase
  
  def setup
    @jerry = create_user(:email => "jerry")
    @george = create_user(:email => "george")
    @message = create_message
  end

  def test_create_message
    @message = create_message
    
    assert_equal @message.sender, @george
    assert_equal @message.recipient, @jerry
    assert_equal @message.subject, "Frolf, Jerry!"
    assert_equal @message.body, "Frolf, Jerry! Frisbee golf!"
    assert @message.read_at.nil?
  end

  def test_read_returns_message
    assert_equal @message, Message.read_message(@message, @george)
  end


  def test_read_records_timestamp
    assert !@message.nil?
  end
 
  def test_read?
    Message.read_message(@message, @jerry)
    @message.reload
    assert @message.message_read?
  end

  def test_mark_deleted_sender
    @message.mark_deleted(@george)
    @message.reload
    assert @message.sender_deleted
  end

  def test_mark_deleted_recipient
    @message.mark_deleted(@jerry)
    @message.reload
    assert @message.recipient_deleted
  end

  def test_mark_deleted_both
    id = @message.id
    @message.mark_deleted(@jerry)
    @message.mark_deleted(@george)
    assert !Message.exists?(id)
  end



end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_private_messages-0.0.2 test/private_messages_test.rb
rails_private_messages-0.0.1 test/private_messages_test.rb