<commit_before>require 'spec_helper'

describe DebitInvoice do
  it { should belong_to(:customer) }
  it { should belong_to(:company) }

  it { should validate_presence_of(:customer) }
  it { should validate_presence_of(:company) }
  it { should validate_presence_of(:title) }
  it { should validate_presence_of(:state) }

  describe "as class" do
    subject {DebitInvoice}

    context "without the accounts" do
      its(:direct_account) {should be_nil}
      its(:available_debit_accounts) {should be_empty}
      its(:default_debit_account) {should be_nil}
      its(:available_credit_accounts) {should be_empty}
      its(:default_credit_account) {should be_nil}
    end

    context "with correct accounts loaded" do
      before(:all) do
        [:debit_account, :credit_account, :service_account].each do |name|
          Factory.create(name)
        end
      end

      its(:direct_account) {should == Account.find_by_code('1100')}
      its(:available_debit_accounts) {should_not be_empty}
      its(:default_debit_account) {should == Account.find_by_code('3200')}
      its(:available_credit_accounts) {should_not be_empty}
      its(:default_credit_account) {should == Account.find_by_code('1100')}
    end
  end

  describe "as an instance" do
    subject { Factory.create(:debit_invoice, :due_date => Date.yesterday,<commit_msg>No need to check inherited associations and validations in DebitInvoice.<commit_after>require 'spec_helper'

describe DebitInvoice do
  describe "as class" do
    subject {DebitInvoice}

    context "without the accounts" do
      its(:direct_account) {should be_nil}
      its(:available_debit_accounts) {should be_empty}
      its(:default_debit_account) {should be_nil}
      its(:available_credit_accounts) {should be_empty}
      its(:default_credit_account) {should be_nil}
    end

    context "with correct accounts loaded" do
      before(:all) do
        [:debit_account, :credit_account, :service_account].each do |name|
          Factory.create(name)
        end
      end

      its(:direct_account) {should == Account.find_by_code('1100')}
      its(:available_debit_accounts) {should_not be_empty}
      its(:default_debit_account) {should == Account.find_by_code('3200')}
      its(:available_credit_accounts) {should_not be_empty}
      its(:default_credit_account) {should == Account.find_by_code('1100')}
    end
  end

  describe "as an instance" do
    subject { Factory.create(:debit_invoice, :due_date => Date.yesterday,
{'fraction_non_alphanumeric': 0.10253317249698432, 'fraction_numerical': 0.009650180940892641, 'mean_word_length': 4.067209775967413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4648840', 'n_tokens_mistral': 816, 'n_tokens_neox': 773, 'n_words': 174}