Sha256: 06c8a47cd7a92a8456783e7df909aeaf6bb272de4d684e5b4e7915a4f614efcc

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

require 'rails_helper'

describe Message do
  fixtures :all

  before(:each) do
    @message = FactoryGirl.create(:message)
  end

  it "should require body" do
    @message.errors[:body].should be_truthy
  end

  it "should require recipient" do
    @message.errors[:recipient].should be_truthy
  end

  it "should require subject" do
    @message.errors[:subject].should be_truthy
  end
  
  it "should return sender_name" do
    @message.sender.username.should be_truthy
  end

  it "should return receiver_name" do
    @message.receiver = users(:user1)
    @message.receiver.username.should be_truthy
  end
  
  it "should set read_at" do
    message = messages(:user2_to_user1_1)
    message.transition_to!(:read)
    message.read_at.should be_truthy
    message.read?.should be_truthy
    message.current_state.should eq 'read'
  end

  it "should require valid recipient" do
    @message.recipient = 'invalidusername'
    @message.save.should be_falsy
  end
end

# == Schema Information
#
# Table name: messages
#
#  id                 :integer          not null, primary key
#  read_at            :datetime
#  receiver_id        :integer
#  sender_id          :integer
#  subject            :string           not null
#  body               :text
#  message_request_id :integer
#  parent_id          :integer
#  created_at         :datetime
#  updated_at         :datetime
#  lft                :integer
#  rgt                :integer
#  depth              :integer
#

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
enju_message-0.2.0 spec/models/message_spec.rb
enju_message-0.2.0.beta.5 spec/models/message_spec.rb
enju_message-0.2.0.beta.4 spec/models/message_spec.rb