<commit_before>require 'spec_helper'

describe Statement do
  it "can be created with valid attributes" do
    @facility  = Factory.create(:facility)
    @statement = Statement.create({:facility => @facility, :created_by => 1, :invoice_date => Time.zone.now + 7.days})
    @statement.should be_valid
  end

  it "requires created_by" do
    @statement = Statement.new({:created_by => nil})
    @statement.should_not be_valid
    @statement.errors.on(:created_by).should_not be_nil
    
    @statement = Statement.new({:created_by => 1})
    @statement.valid?
    @statement.errors.on(:created_by).should be_nil
  end
  
  it "requires a facility" do
    @statement = Statement.new({:facility_id => nil})
    @statement.should_not be_valid
    @statement.errors.on(:facility_id).should_not be_nil
    
    @statement = Statement.new({:facility_id => 1})
    @statement.valid?
    @statement.errors.on(:facility_id).should be_nil
  end
end<commit_msg>Task #30441: test new changes<commit_after>require 'spec_helper'

describe Statement do
  it "can be created with valid attributes" do
    @facility  = Factory.create(:facility)
    @statement = Statement.create({:facility => @facility, :created_by => 1, :invoice_date => Time.zone.now + 7.days})
    @statement.should be_valid
  end

  context "finalized_at" do
    before :each do
      @facility  = Factory.create(:facility)
      @statement = Statement.create({:facility => @facility, :created_by => 1, :invoice_date => Time.zone.now + 7.days})
    end

    it { should allow_value(nil).for(:finalized_at) }
    it { should allow_value(Time.zone.now).for(:finalized_at) }
  end

  it "requires created_by" do
    @statement = Statement.new({:created_by => nil})
    @statement.should_not be_valid
    @statement.errors.on(:created_by).should_not be_nil
    
    @statement = Statement.new({:created_by => 1})
    @statement.valid?
    @statement.errors.on(:created_by).should be_nil
  end
  
  it "requires a facility" do
    @statement = Statement.new({:facility_id => nil})
    @statement.should_not be_valid
    @statement.errors.on(:facility_id).should_not be_nil
    
    @statement = Statement.new({:facility_id => 1})
    @statement.valid?
    @statement.errors.on(:facility_id).should be_nil
  end
end
{'fraction_non_alphanumeric': 0.1290893015030946, 'fraction_numerical': 0.006631299734748011, 'mean_word_length': 3.8666666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '4985616', 'n_tokens_mistral': 761, 'n_tokens_neox': 737, 'n_words': 155}