Sha256: e0bf695dc3d046ffb386add7f80cd1a55b5444553eef31047292ee1df1bf5edb

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

require 'test_helper'

class InvoiceBar::AccountTest < ActiveSupport::TestCase
  should allow_mass_assignment_of :name
  should allow_mass_assignment_of :bank_account_number
  should allow_mass_assignment_of :iban
  should allow_mass_assignment_of :swift
  should allow_mass_assignment_of :amount
  should validate_presence_of :name
  should validate_presence_of :amount
  should validate_presence_of :user_id
  should validate_presence_of :currency_id
  should validate_length_of(:iban).is_at_least(15).is_at_most(34)
  should validate_length_of(:swift).is_at_least(8).is_at_most(11)
  should belong_to :currency
  should belong_to :user

  test "account should validate uniqueness of name" do
    user = FactoryGirl.create(:invoice_bar_user)
    account = FactoryGirl.create(:invoice_bar_account, name: 'name', user: user)
    new_account = FactoryGirl.build(:invoice_bar_account, name: 'name', user: user)

    assert_equal false, new_account.valid?

    new_account = FactoryGirl.build(:invoice_bar_account, user: user)

    assert_equal true, new_account.valid?
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
invoice_bar-0.0.11 test/unit/invoice_bar/account_test.rb
invoice_bar-0.0.10 test/unit/invoice_bar/account_test.rb
invoice_bar-0.0.9 test/unit/invoice_bar/account_test.rb
invoice_bar-0.0.8 test/unit/invoice_bar/account_test.rb
invoice_bar-0.0.7 test/unit/invoice_bar/account_test.rb