diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4217cbaa9e..507e09f7af 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1000` -# on 2024-12-30 12:47:30 UTC using RuboCop version 1.69.2. +# on 2024-12-30 18:51:32 UTC using RuboCop version 1.69.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -16,7 +16,7 @@ FactoryBot/FactoryAssociationWithStrategy: - 'spec/factories/claim/transfer_details.rb' - 'spec/factories/expenses.rb' -# Offense count: 652 +# Offense count: 650 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. # URISchemes: http, https @@ -284,7 +284,7 @@ Metrics/CyclomaticComplexity: - 'lib/data_migrator/offence_unique_code_migrator.rb' - 'spec/api/v2/claim_spec.rb' -# Offense count: 60 +# Offense count: 56 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Exclude: @@ -293,7 +293,6 @@ Metrics/MethodLength: - 'app/controllers/external_users/application_controller.rb' - 'app/controllers/external_users/fees/prices_controller.rb' - 'app/controllers/external_users/registrations_controller.rb' - - 'app/controllers/pages_controller.rb' - 'app/interfaces/api/helpers/api_helper.rb' - 'app/models/ability.rb' - 'app/models/allocation.rb' @@ -305,7 +304,6 @@ Metrics/MethodLength: - 'app/presenters/fee/interim_fee_type_presenter.rb' - 'app/services/claims/case_worker_claims.rb' - 'app/services/claims/fee_calculator/graduated_price.rb' - - 'app/services/message_queue/message_template.rb' - 'app/services/reports/provisional_assessments_by_dates.rb' - 'app/services/stats/management_information_generator.rb' - 'app/validators/claim/advocate_claim_validator.rb' @@ -329,14 +327,12 @@ Metrics/MethodLength: - 'spec/factories/claim/base_claims.rb' - 'spec/factories/disbursement_types.rb' - 'spec/models/claims/cloner_spec.rb' - - 'spec/models/remote/case_type_spec.rb' - 'spec/models/timed_transitions/transitioner_spec.rb' - 'spec/presenters/fee/interim_fee_type_presenter_spec.rb' - 'spec/support/api/claims/advocate_claim_test/final.rb' - 'spec/support/api/claims/advocate_claim_test/hardship.rb' - 'spec/support/api/claims/base_claim_test.rb' - 'spec/support/factory_helpers.rb' - - 'spec/support/matchers/hash_matchers.rb' - 'spec/support/scheme_date_helpers.rb' # Offense count: 7 @@ -514,7 +510,7 @@ RSpec/BeforeAfterAll: - 'spec/services/claims/update_claim_spec.rb' - 'spec/services/claims/update_draft_spec.rb' -# Offense count: 1343 +# Offense count: 1342 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -600,7 +596,6 @@ RSpec/ContextWording: - 'spec/models/offence_class_spec.rb' - 'spec/models/provider_spec.rb' - 'spec/models/redetermination_spec.rb' - - 'spec/models/remote/case_type_spec.rb' - 'spec/models/representation_order_spec.rb' - 'spec/models/stage_collection_spec.rb' - 'spec/models/stage_transition_spec.rb' @@ -731,7 +726,7 @@ RSpec/EmptyExampleGroup: - 'spec/services/claims/fee_calculator/graduated_price_spec.rb' - 'spec/validators/claim/base_claim_sub_model_validator_spec.rb' -# Offense count: 166 +# Offense count: 165 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: @@ -782,7 +777,6 @@ RSpec/ExampleLength: - 'spec/models/message_spec.rb' - 'spec/models/offence_spec.rb' - 'spec/models/redetermination_spec.rb' - - 'spec/models/remote/case_type_spec.rb' - 'spec/models/stats/stats_report_spec.rb' - 'spec/models/subscribers/slack_spec.rb' - 'spec/models/timed_transitions/transitioner_spec.rb' @@ -1012,7 +1006,7 @@ RSpec/LetSetup: - 'spec/validators/claim/advocate_interim_claim_web_validations_spec.rb' - 'spec/views/case_workers/claims/show_spec.rb' -# Offense count: 169 +# Offense count: 167 # Configuration parameters: EnforcedStyle. # SupportedStyles: have_received, receive RSpec/MessageSpies: @@ -1026,7 +1020,6 @@ RSpec/MessageSpies: - 'spec/controllers/messages_controller_spec.rb' - 'spec/helpers/case_workers/claims_helper_spec.rb' - 'spec/helpers/case_workers/travel_helper_spec.rb' - - 'spec/helpers/claims_helper_spec.rb' - 'spec/lib/caching/api_request_spec.rb' - 'spec/models/allocation_spec.rb' - 'spec/models/assessment_spec.rb' @@ -1078,7 +1071,7 @@ RSpec/MultipleDescribes: - 'spec/models/claim/base_claim_spec.rb' - 'spec/routing/claims_controller_spec.rb' -# Offense count: 636 +# Offense count: 632 # Configuration parameters: Max. RSpec/MultipleExpectations: Exclude: @@ -1123,9 +1116,7 @@ RSpec/MultipleExpectations: - 'spec/controllers/provider_management/providers_controller_spec.rb' - 'spec/controllers/users_controller_spec.rb' - 'spec/controllers/vat_rates_controller_spec.rb' - - 'spec/helpers/case_workers/admin/allocations_helper_spec.rb' - 'spec/helpers/case_workers/claims_helper_spec.rb' - - 'spec/helpers/claims_helper_spec.rb' - 'spec/lib/caching/api_request_spec.rb' - 'spec/lib/caching/memory_store_spec.rb' - 'spec/lib/extensions/devise_extension_spec.rb' @@ -1155,7 +1146,6 @@ RSpec/MultipleExpectations: - 'spec/models/fee/shared_examples_for_duplicable.rb' - 'spec/models/injection_attempt_spec.rb' - 'spec/models/message_spec.rb' - - 'spec/models/remote/case_type_spec.rb' - 'spec/models/representation_order_spec.rb' - 'spec/models/stage_collection_spec.rb' - 'spec/models/stage_transition_spec.rb' @@ -1466,7 +1456,7 @@ RSpec/PredicateMatcher: - 'spec/services/claims/update_draft_spec.rb' - 'spec/validators/claim/shared_examples_for_advocate_litigator.rb' -# Offense count: 69 +# Offense count: 67 RSpec/StubbedMock: Exclude: - 'spec/api/entities/cclf/case_type_spec.rb' @@ -1474,7 +1464,6 @@ RSpec/StubbedMock: - 'spec/controllers/case_workers/claims_controller_spec.rb' - 'spec/controllers/messages_controller_spec.rb' - 'spec/helpers/case_workers/claims_helper_spec.rb' - - 'spec/helpers/claims_helper_spec.rb' - 'spec/models/claim/advocate_hardship_claim_spec.rb' - 'spec/models/claim/advocate_interim_claim_spec.rb' - 'spec/models/claim/advocate_supplementary_claim_spec.rb' @@ -1512,7 +1501,7 @@ RSpec/SubjectStub: - 'spec/services/claims/create_draft_spec.rb' - 'spec/services/claims/update_claim_spec.rb' -# Offense count: 71 +# Offense count: 69 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Exclude: @@ -1522,7 +1511,6 @@ RSpec/VerifiedDoubles: - 'spec/controllers/heartbeat_controller_spec.rb' - 'spec/controllers/messages_controller_spec.rb' - 'spec/helpers/case_workers/claims_helper_spec.rb' - - 'spec/helpers/claims_helper_spec.rb' - 'spec/lib/caching/api_request_spec.rb' - 'spec/lib/rule/applicator_spec.rb' - 'spec/models/allocation_spec.rb' @@ -1673,11 +1661,10 @@ Rails/Output: - 'lib/data_migrator/offence_unique_code_migrator.rb' - 'lib/data_migrator/provider_suppliers_migrator.rb' -# Offense count: 3 +# Offense count: 2 Rails/OutputSafety: Exclude: - 'app/helpers/application_helper.rb' - - 'app/helpers/claims_helper.rb' - 'app/helpers/external_users/claims_helper.rb' # Offense count: 2 diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 240d199fed..f6a34bd9ad 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -14,23 +14,10 @@ def api_release_notes; end def servicedown respond_to do |format| - format.html do - render :servicedown - end - format.json do - render json: - [{ error: 'Service temporarily unavailable' }], - status: :service_unavailable - end - format.js do - render json: - [{ error: 'Service temporarily unavailable' }], - status: :service_unavailable - end - format.all do - render plain: 'error: Service temporarily unavailable', - status: :service_unavailable - end + format.html { render :servicedown } + format.json { render json: [{ error: 'Service temporarily unavailable' }], status: :service_unavailable } + format.js { render json: [{ error: 'Service temporarily unavailable' }], status: :service_unavailable } + format.all { render plain: 'error: Service temporarily unavailable', status: :service_unavailable } end end diff --git a/app/helpers/case_workers/admin/allocations_helper.rb b/app/helpers/case_workers/admin/allocations_helper.rb index 6dde0f0bf6..181f6a19b3 100644 --- a/app/helpers/case_workers/admin/allocations_helper.rb +++ b/app/helpers/case_workers/admin/allocations_helper.rb @@ -3,8 +3,4 @@ def allocation_scheme_filters %w[agfs lgfs] end - - def owner_column_header - params[:scheme].blank? || params[:scheme] == 'agfs' ? I18n.t('common.advocate') : I18n.t('common.litigator') - end end diff --git a/app/helpers/claims_helper.rb b/app/helpers/claims_helper.rb index b568ddee92..8fbb6d9d9c 100644 --- a/app/helpers/claims_helper.rb +++ b/app/helpers/claims_helper.rb @@ -11,12 +11,6 @@ module ClaimsHelper SIGNPOST_FEES = %w[MIUMU MIAPF].freeze - def claim_allocation_checkbox_helper(claim, case_worker) - checked = claim.allocated_to_case_worker?(case_worker) ? 'checked="checked"' : nil - element_id = "id=\"case_worker_claim_ids_#{claim.id}\"" - %().html_safe - end - def to_slug(string) string.downcase.gsub(/ +/, '-').gsub(/[^a-zA-Z0-9-]/, '') end diff --git a/app/services/message_queue/message_template.rb b/app/services/message_queue/message_template.rb deleted file mode 100644 index f57ec962cc..0000000000 --- a/app/services/message_queue/message_template.rb +++ /dev/null @@ -1,22 +0,0 @@ -module MessageQueue - class MessageTemplate - def self.claim_created(type, uuid) - { - body: 'Claim submitted', - attributes: - { - type: - { - data_type: 'String', - string_value: type - }, - uuid: - { - data_type: 'String', - string_value: uuid - } - } - } - end - end -end diff --git a/spec/helpers/case_workers/admin/allocations_helper_spec.rb b/spec/helpers/case_workers/admin/allocations_helper_spec.rb deleted file mode 100644 index 8182d63728..0000000000 --- a/spec/helpers/case_workers/admin/allocations_helper_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -describe CaseWorkers::Admin::AllocationsHelper do - describe '#owner_column_header' do - it 'returns advocate for agfs filter or by default' do - expect(owner_column_header).to eql 'Advocate' - allow(params).to receive(:[]).with(:scheme).and_return('agfs') - expect(owner_column_header).to eql 'Advocate' - end - - it 'returns litigator for lgfs filter' do - allow(params).to receive(:[]).with(:scheme).and_return('lgfs') - expect(owner_column_header).to eql 'Litigator' - end - end -end diff --git a/spec/helpers/claims_helper_spec.rb b/spec/helpers/claims_helper_spec.rb index 0678a09bcc..6f432c4cb1 100644 --- a/spec/helpers/claims_helper_spec.rb +++ b/spec/helpers/claims_helper_spec.rb @@ -54,28 +54,6 @@ end RSpec.describe ClaimsHelper do - describe '#claim_allocation_checkbox_helper' do - let(:case_worker) { double CaseWorker } - let(:claim) { double Claim } - - before do - allow(claim).to receive(:id).and_return(66) - allow(case_worker).to receive(:id).and_return(888) - end - - it 'produces the html for a checked checkbox if the claim is allocated to the case worker' do - expect(claim).to receive(:allocated_to_case_worker?).with(case_worker).and_return(true) - expected_html = '' - expect(claim_allocation_checkbox_helper(claim, case_worker)).to eq expected_html - end - - it 'produces the html for a un-checked checkbox if the claim is not allocated to the case worker' do - expect(claim).to receive(:allocated_to_case_worker?).with(case_worker).and_return(false) - expected_html = '' - expect(claim_allocation_checkbox_helper(claim, case_worker)).to eq expected_html - end - end - describe '#show_api_promo_to_user?' do helper do def current_user diff --git a/spec/models/remote/case_type_spec.rb b/spec/models/remote/case_type_spec.rb index 72e2f37337..e6b029581f 100644 --- a/spec/models/remote/case_type_spec.rb +++ b/spec/models/remote/case_type_spec.rb @@ -3,57 +3,7 @@ describe Remote::CaseType do let(:client) { instance_double(Remote::HttpClient, get: response) } - it 'has the correct resource path' do - expect(described_class.resource_path).to eq('case_types') - end - - context 'class methods' do - before do - allow(described_class).to receive(:client).and_return(client) - end - - describe '.all' do - it 'returns a collection of all case types' do - case_types = described_class.all - expect(case_types.map(&:id)).to eq([1, 9, 13, 11, 12]) - end - end - - describe '.agfs' do - it 'returns a collection of case types with role agfs' do - expect(described_class.agfs.map(&:id)).to eq([1, 9, 11, 12]) - end - end - - describe '.lgfs' do - it 'returns a collection of case types with role lgfs' do - expect(described_class.lgfs.map(&:id)).to eq([1, 9, 13, 11, 12]) - end - end - - describe '.interims' do - it 'returns a collection of case types with role interim' do - expect(described_class.interims.map(&:id)).to eq([11, 12]) - end - end - - describe '.find' do - it 'returns the case type with the specified id' do - ct = described_class.find(9) - expect(ct.id).to eq 9 - expect(ct.name).to eq('Elected cases not proceeded') - expect(ct.is_fixed_fee).to be true - expect(ct.requires_cracked_dates).to be false - expect(ct.requires_trial_dates).to be false - expect(ct.allow_pcmh_fee_type).to be false - expect(ct.requires_maat_reference).to be true - expect(ct.requires_retrial_dates).to be false - expect(ct.roles).to eq(%w[agfs lgfs]) - end - end - end - - def response + let(:response) do [ { 'id' => 1, @@ -117,4 +67,53 @@ def response } ] end + + before do + allow(described_class).to receive(:client).and_return(client) + end + + describe '.resource_path' do + subject { described_class.resource_path } + + it { is_expected.to eq('case_types') } + end + + describe '.all' do + it 'returns a collection of all case types' do + case_types = described_class.all + expect(case_types.map(&:id)).to eq([1, 9, 13, 11, 12]) + end + end + + describe '.agfs' do + it 'returns a collection of case types with role agfs' do + expect(described_class.agfs.map(&:id)).to eq([1, 9, 11, 12]) + end + end + + describe '.lgfs' do + it 'returns a collection of case types with role lgfs' do + expect(described_class.lgfs.map(&:id)).to eq([1, 9, 13, 11, 12]) + end + end + + describe '.interims' do + it 'returns a collection of case types with role interim' do + expect(described_class.interims.map(&:id)).to eq([11, 12]) + end + end + + describe '.find' do + subject(:case_type) { described_class.find(9) } + + it { expect(case_type.id).to eq 9 } + it { expect(case_type.name).to eq('Elected cases not proceeded') } + it { expect(case_type.is_fixed_fee).to be true } + it { expect(case_type.requires_cracked_dates).to be false } + it { expect(case_type.requires_trial_dates).to be false } + it { expect(case_type.allow_pcmh_fee_type).to be false } + it { expect(case_type.requires_maat_reference).to be true } + it { expect(case_type.requires_retrial_dates).to be false } + it { expect(case_type.roles).to eq(%w[agfs lgfs]) } + end end diff --git a/spec/support/matchers/hash_matchers.rb b/spec/support/matchers/hash_matchers.rb index 006d59fcc3..1f806bb1d3 100644 --- a/spec/support/matchers/hash_matchers.rb +++ b/spec/support/matchers/hash_matchers.rb @@ -23,15 +23,12 @@ end def format_diff(diff) - spacer = "-\s" - diff_sep = '--------------------' - diff_array = diff.each_with_object([]) do |el, memo| if el.is_a? Array - memo << diff_sep + memo << '--------------------' memo << format_diff(el) else - memo << "\"#{el}\"".prepend(spacer) + memo << "\"#{el}\"".prepend("-\s") end end