Sha256: 1e33456eac4f29142b388ceffbf4e91c6deff1edf62704c97b748eb2abe5be5e

Contents?: true

Size: 1.44 KB

Versions: 8

Compression:

Stored size: 1.44 KB

Contents

require 'spec_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

8 entries across 8 versions & 1 rubygems

Version Path
enju_message-0.2.0.beta.3 spec/models/message_spec.rb
enju_message-0.2.0.beta.2 spec/models/message_spec.rb
enju_message-0.2.0.beta.1 spec/models/message_spec.rb
enju_message-0.1.16 spec/models/message_spec.rb
enju_message-0.1.15 spec/models/message_spec.rb
enju_message-0.1.14 spec/models/message_spec.rb
enju_message-0.1.14.pre26 spec/models/message_spec.rb
enju_message-0.1.14.pre25 spec/models/message_spec.rb