<commit_before>require 'rails_helper'
require 'spec_helper'

describe API::Entities::SearchResult do
  subject(:search_result) { described_class.represent(claim) }

  describe 'filters' do
    subject(:filter) { JSON.parse(search_result.to_json)['filter'] }

    context 'when passed a redetermination case with a graduated fee ' do
      let(:claim) { OpenStruct.new('id'=>'19932', 'uuid'=>'aec3900f-3e82-4c4f-a7cd-498ad45f11f8', 'scheme'=>'agfs', 'scheme_type'=>'Advocate', 'case_number'=>'T20160427', 'state'=>'redetermination', 'court_name'=>'Newcastle', 'case_type'=>'Contempt', 'total'=>'426.36', 'disk_evidence'=>'f', 'external_user'=>'<NAME>', 'maat_references'=>'2320144', 'defendants'=>'<NAME>', 'fees'=>'0.0~Daily attendance fee (3 to 40)~Fee::BasicFeeType, 0.0~Daily attendance fee (41 to 50)~Fee::BasicFeeType, 0.0~Daily attendance fee (51+)~Fee::BasicFeeType, 0.0~Standard appearance fee~Fee::BasicFeeType, 0.0~Plea and case management hearing~Fee::BasicFeeType, 0.0~Conferences and views~Fee::BasicFeeType, 0.0~Number of defendants uplift~Fee::BasicFeeType, 0.0~Number of cases uplift~Fee::BasicFeeType, 0.0~Number of prosecution witnesses~Fee::BasicFeeType, 1.0~Basic fee~Fee::BasicFeeType, 34.0~Pages of prosecution evidence~Fee::BasicFeeType', 'last_submitted_at'=>'2017-07-06 09:33:30.932017', 'class_letter'=>'F', 'is_fixed_fee'=>'f', 'fee_type_code'=>'GRRAK', 'graduated_fee_types'=>'GRTRL,GRRTR,GRGLT,GRDIS,GRRAK,GRCBR') }
      let(:result) { {'disk_evidence'=>false, 'redetermination'=>true, 'fixed_fee'=>false, 'awaiting_written_reasons'=>false, 'cracked'=>false, 'trial'=>false, 'guilty_plea'=>false, 'graduated_fees'=>true, 'interim_fees'=>false, 'warrants'=>false, 'interim_disbursements'=>false, 'risk_based_bills'=>false} }

      it { is_expected.to eql result }
    end

    context 'when passed a litigator case with a risk based bill' do
      let(:claim) {OpenStruct.new('id'=>'113336', 'uuid'=>'446fd8db-4441-4726-857c-3e80e440f5a2', 'scheme'=>'lgfs', 'scheme_type'=>'Final', 'case_number'=>'T20170329', 'state'=>'submitted', 'court_name'=>'Chester', 'case_type'=>'Guilty plea', 'total'=>'556.11', 'disk_evidence'=>'f', 'external_user'=>'<NAME>', 'maat_references'=>'5782148', 'defendants'=>'<NAME>', 'fees'=>'30.0~Guilty plea~Fee::GraduatedFeeType', 'last_submitted_at'=>'2017-07-18 09:19:42.860977', 'class_letter'=>'H', 'is_fixed_fee'=>'f', 'fee_type_code'=>'GRGLT', 'graduated_fee_types'=>'GRTRL,GRRTR,GRGLT,GRDIS,GRRAK,GRCBR') }
      let(:result) { {'disk_evidence'=>false, 'redetermination'=>false, 'fixed_fee'=>false, 'awaiting_written_reasons'=>false, 'cracked'=>false, 'trial'=>false, 'guilty_plea'=>true, 'graduated_fees'=>true, 'interim_fees'=>false, 'warrants'=>false, 'interim_disbursements'=>false, 'risk_based_bills'=>true} }

      it { is_expected.to eql result }
    end
  end
end
<commit_msg>Create search result entity<commit_after>require 'rails_helper'
require 'spec_helper'

describe API::Entities::SearchResult do
  subject(:search_result) { described_class.represent(claim) }

  describe 'filters' do
    subject(:filter) { JSON.parse(search_result.to_json)['filter'] }

    context 'when passed a redetermination case with a graduated fee ' do
      let(:claim) { OpenStruct.new('id'=>'19932', 'uuid'=>'aec3900f-3e82-4c4f-a7cd-498ad45f11f8', 'scheme'=>'agfs', 'scheme_type'=>'Advocate', 'case_number'=>'T20160427', 'state'=>'redetermination', 'court_name'=>'Newcastle', 'case_type'=>'Contempt', 'total'=>'426.36', 'disk_evidence'=>'f', 'external_user'=>'<NAME>', 'maat_references'=>'2320144', 'defendants'=>'<NAME>', 'fees'=>'0.0~Daily attendance fee (3 to 40)~Fee::BasicFeeType, 0.0~Daily attendance fee (41 to 50)~Fee::BasicFeeType, 0.0~Daily attendance fee (51+)~Fee::BasicFeeType, 0.0~Standard appearance fee~Fee::BasicFeeType, 0.0~Plea and case management hearing~Fee::BasicFeeType, 0.0~Conferences and views~Fee::BasicFeeType, 0.0~Number of defendants uplift~Fee::BasicFeeType, 0.0~Number of cases uplift~Fee::BasicFeeType, 0.0~Number of prosecution witnesses~Fee::BasicFeeType, 1.0~Basic fee~Fee::BasicFeeType, 34.0~Pages of prosecution evidence~Fee::BasicFeeType', 'last_submitted_at'=>'2017-07-06 09:33:30.932017', 'class_letter'=>'F', 'is_fixed_fee'=>'f', 'fee_type_code'=>'GRRAK', 'graduated_fee_types'=>'GRTRL,GRRTR,GRGLT,GRDIS,GRRAK,GRCBR') }
      let(:result) { {'disk_evidence'=>false, 'redetermination'=>true, 'fixed_fee'=>false, 'awaiting_written_reasons'=>false, 'cracked'=>false, 'trial'=>false, 'guilty_plea'=>false, 'graduated_fees'=>true, 'interim_fees'=>false, 'warrants'=>false, 'interim_disbursements'=>false, 'risk_based_bills'=>false} }

      it { is_expected.to eql result }
    end

    context 'when passed a litigator case with a risk based bill' do
      let(:claim) {OpenStruct.new('id'=>'113336', 'uuid'=>'446fd8db-4441-4726-857c-3e80e440f5a2', 'scheme'=>'lgfs', 'scheme_type'=>'Final', 'case_number'=>'T20170329', 'state'=>'submitted', 'court_name'=>'Chester', 'case_type'=>'Guilty plea', 'total'=>'556.11', 'disk_evidence'=>'f', 'external_user'=>'<NAME>', 'maat_references'=>'5782148', 'defendants'=>'<NAME>', 'fees'=>'30.0~Guilty plea~Fee::GraduatedFeeType', 'last_submitted_at'=>'2017-07-18 09:19:42.860977', 'class_letter'=>'H', 'is_fixed_fee'=>'f', 'fee_type_code'=>'GRGLT', 'graduated_fee_types'=>'GRTRL,GRRTR,GRGLT,GRDIS,GRRAK,GRCBR') }
      let(:result) { {'disk_evidence'=>false, 'redetermination'=>false, 'fixed_fee'=>false, 'awaiting_written_reasons'=>false, 'cracked'=>false, 'trial'=>false, 'guilty_plea'=>true, 'graduated_fees'=>true, 'interim_fees'=>false, 'warrants'=>false, 'interim_disbursements'=>false, 'risk_based_bills'=>true} }
      it { is_expected.to eql result }
    end
  end
end

{'fraction_non_alphanumeric': 0.2000350324049746, 'fraction_numerical': 0.058504116307584515, 'mean_word_length': 9.070546737213403, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 135, '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': '4655454', 'n_tokens_mistral': 2281, 'n_tokens_neox': 2117, 'n_words': 329}