<commit_before># == Schema Information
#
# Table name: determinations
#
#  id            :integer          not null, primary key
#  claim_id      :integer
#  type          :string
#  fees          :decimal(, )      default(0.0)
#  expenses      :decimal(, )      default(0.0)
#  total         :decimal(, )
#  created_at    :datetime
#  updated_at    :datetime
#  vat_amount    :float            default(0.0)
#  disbursements :decimal(, )      default(0.0)
#

require 'rails_helper'


describe Redetermination do

  let(:claim)         { FactoryGirl.create :claim }

 
  context 'automatic calculation of total' do
    it 'should calculate the total on save' do
      rd = FactoryGirl.create :redetermination
      expect(rd.total).to eq(rd.fees + rd.expenses + rd.disbursements)
    end
  end

  context 'default scope' do
    it 'should return the redeterminations in order of creation date' do
      date_1 = 2.months.ago
      date_2 = 1.month.ago
      date_3 = 1.week.ago

      # Given a number of redeterminations written at various times
      [date_3, date_1, date_2].each do |date|
        Timecop.freeze(date) do
          FactoryGirl.create :redetermination, claim: claim
        end
      end
      # when I call claim.redeterminations
      rds = claim.redeterminations

      # it should return them in created_at order - con vert to integer to remove precesion pproblems on travis
      expect(rds.map(&:created_at).map(&:to_i)).to eq( [ date_1.to_i, date_2.to_i, date_3.to_i ])
    end
  end


  describe '#to_s' do
    it 'outputs the totals' do
      rd = FactoryGirl.create :redetermination, fees: 123.22, expenses: 301.55, disbursements: 44.33
      expected  = "  id:            2\n" +
                  "  type           Redetermination\n" +
                  "  claim_id:      1\n" +
                  "  expenses:      301.55\n" +
                  "  fees:          123.22\n" +
                  "  disbursements: 44.33\n" +
                  "  vat_amount:    82.09\n" +
                  "  total:         469.1\n\n"
       expect(rd.to_s).to eq expected
    end
  end

end<commit_msg>Fix issue in spec to cater for varying record ids<commit_after># == Schema Information
#
# Table name: determinations
#
#  id            :integer          not null, primary key
#  claim_id      :integer
#  type          :string
#  fees          :decimal(, )      default(0.0)
#  expenses      :decimal(, )      default(0.0)
#  total         :decimal(, )
#  created_at    :datetime
#  updated_at    :datetime
#  vat_amount    :float            default(0.0)
#  disbursements :decimal(, )      default(0.0)
#

require 'rails_helper'


describe Redetermination do

  let(:claim)         { FactoryGirl.create :claim }

 
  context 'automatic calculation of total' do
    it 'should calculate the total on save' do
      rd = FactoryGirl.create :redetermination
      expect(rd.total).to eq(rd.fees + rd.expenses + rd.disbursements)
    end
  end

  context 'default scope' do
    it 'should return the redeterminations in order of creation date' do
      date_1 = 2.months.ago
      date_2 = 1.month.ago
      date_3 = 1.week.ago

      # Given a number of redeterminations written at various times
      [date_3, date_1, date_2].each do |date|
        Timecop.freeze(date) do
          FactoryGirl.create :redetermination, claim: claim
        end
      end
      # when I call claim.redeterminations
      rds = claim.redeterminations

      # it should return them in created_at order - con vert to integer to remove precesion pproblems on travis
      expect(rds.map(&:created_at).map(&:to_i)).to eq( [ date_1.to_i, date_2.to_i, date_3.to_i ])
    end
  end


  describe '#to_s' do
    it 'outputs the totals' do
      rd = FactoryGirl.create :redetermination, fees: 123.22, expenses: 301.55, disbursements: 44.33
      expected  = "  id:            #{rd.id}\n" +
                  "  type           Redetermination\n" +
                  "  claim_id:      #{rd.claim.id}\n" +
                  "  expenses:      301.55\n" +
                  "  fees:          123.22\n" +
                  "  disbursements: 44.33\n" +
                  "  vat_amount:    82.09\n" +
                  "  total:         469.1\n\n"
       expect(rd.to_s).to eq expected
    end
  end

end
{'fraction_non_alphanumeric': 0.09785147127510509, 'fraction_numerical': 0.026623073330219522, 'mean_word_length': 1.868720696584059, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3728739', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1369, 'n_words': 364}