Sha256: e433bc33c748fb51922b4035570e3515641448ab5addb0678d28399c77a61bae

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe Transaction do

  it "should create a transaction" do
    transaction = Factory(:transaction)
  end
  
  it "should not be valid without a credit account" do
    transaction = Factory.build(:transaction, :credit_account => nil)
    transaction.should_not be_valid
  end
  
  it "should not be valid without a valid credit account" do
    bad_account = Factory.build(:asset, :name => nil)
    transaction = Factory.build(:transaction, :credit_account => bad_account)
    transaction.should_not be_valid
  end  

  it "should not be valid without a debit account" do
    transaction = Factory.build(:transaction, :debit_account => nil)
    transaction.should_not be_valid
  end
  
  it "should not be valid without a valid credit account" do
    bad_account = Factory.build(:asset, :name => nil)
    transaction = Factory.build(:transaction, :debit_account => bad_account)
    transaction.should_not be_valid
  end  
  
  it "should not be valid without an amount" do
    transaction = Factory.build(:transaction, :amount => nil)
    transaction.should_not be_valid
  end

  it "should not be valid without a description" do
    transaction = Factory.build(:transaction, :description => nil)
    transaction.should_not be_valid
  end
  
  it "should have a polymorphic commercial document associations" do
    mock_document = Factory(:transaction) # one would never do this, but it allows us to not require a migration for the test
    transaction = Factory(:transaction, :commercial_document => mock_document)
    saved_transaction = Transaction.find(transaction.id)
    saved_transaction.commercial_document.should == mock_document
  end
 
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
blawzoo-plutus-0.5.3 spec/models/transaction_spec.rb
plutus-0.5.2 spec/models/transaction_spec.rb
plutus-0.5.1 spec/models/transaction_spec.rb
plutus-0.4.2 spec/models/transaction_spec.rb