Skip to content

Commit

Permalink
switch to using a helper
Browse files Browse the repository at this point in the history
  • Loading branch information
alkesh committed Sep 9, 2024
1 parent a813043 commit 13117fa
Show file tree
Hide file tree
Showing 31 changed files with 54 additions and 33 deletions.
1 change: 0 additions & 1 deletion app/controllers/admin/amendments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class Admin::AmendmentsController < Admin::BaseAdminController
before_action :load_claim
before_action :ensure_service_operator
before_action :ensure_claim_is_amendable
before_action :set_claim_summary_view, only: [:index]

def index
end
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/admin/base_admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,5 @@ def clear_session
session.delete(:role_codes)
session.delete(:claims_backlink_path)
end

def set_claim_summary_view
policy_append = @claim.policy.to_s.underscore if @claim.policy.is_a?(Policies::FurtherEducationPayments)
@claim_summary_view = ["claim_summary", policy_append].compact.join("_")
end
end
end
1 change: 0 additions & 1 deletion app/controllers/admin/claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def hold
redirect_to admin_claim_notes_path(@claim)
else
@note = Note.new
set_claim_summary_view
render "admin/notes/index"
end
end
Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin/decisions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Admin::DecisionsController < Admin::BaseAdminController
before_action :reject_decided_claims, unless: -> { qa_decision_task? }
before_action :reject_missing_payroll_gender, only: [:create]
before_action :reject_if_claims_preventing_payment, only: [:create]
before_action :set_claim_summary_view

def new
@decision = Decision.new
Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Admin
class NotesController < BaseAdminController
before_action :ensure_service_operator
before_action :load_claim
before_action :set_claim_summary_view

def index
@note = Note.new
Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class PaymentsController < BaseAdminController
before_action :ensure_service_operator
before_action :find_payroll_run, except: [:index]
before_action :find_payment, except: [:index]
before_action :set_claim_summary_view, only: [:index]

def index
@claim = Claim.find(params[:claim_id])
Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin/support_tickets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Admin
class SupportTicketsController < BaseAdminController
before_action :ensure_service_operator
before_action :load_claim
before_action :set_claim_summary_view

def create
@support_ticket = @claim.build_support_ticket(support_ticket_params)
Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Admin::TasksController < Admin::BaseAdminController
before_action :load_claim
before_action :ensure_task_has_not_already_been_completed, only: [:create]
before_action :load_matching_claims, only: [:show], if: -> { params[:name] == "matching_details" }
before_action :set_claim_summary_view

def index
@claim_checking_tasks = ClaimCheckingTasks.new(@claim)
Expand Down
8 changes: 8 additions & 0 deletions app/helpers/admin/claim_summary_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Admin
module ClaimSummaryHelper
def claim_summary_view
policy_name_to_append = @claim.policy.to_s.underscore if @claim.policy.is_a?(Policies::FurtherEducationPayments)
["claim_summary", policy_name_to_append].compact.join("_")
end
end
end
2 changes: 1 addition & 1 deletion app/views/admin/amendments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= link_to "Back", claims_backlink_path, class: "govuk-back-link" %>

<div class="govuk-grid-row">
<%= render "admin/tasks/#{@claim_summary_view}", claim: @claim, heading: @claim.reference %>
<%= render "admin/tasks/#{claim_summary_view}", claim: @claim, heading: @claim.reference %>
</div>

<div class="govuk-grid-row">
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/decisions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="govuk-grid-row">
<%= render("shared/error_summary", instance: @decision, errored_field_id_overrides: { "result": "decision_result_approved" }) if @decision.errors.any? %>

<%= render "admin/tasks/#{@claim_summary_view}", claim: @claim, heading: "Claim decision" %>
<%= render "admin/tasks/#{claim_summary_view}", claim: @claim, heading: "Claim decision" %>

<div class="govuk-grid-column-two-thirds">
<%= render("incomplete_tasks", claim: @claim, incomplete_task_names: @claim_checking_tasks.incomplete_task_names) if @claim_checking_tasks.incomplete_task_names.any? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/notes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<%= render("shared/error_summary", instance: @hold_note, errored_field_id_overrides: {body: "hold_body"}) if @hold_note.errors.any? %>

<div class="govuk-grid-row">
<%= render "admin/tasks/#{@claim_summary_view}", claim: @claim, heading: @claim.reference %>
<%= render "admin/tasks/#{claim_summary_view}", claim: @claim, heading: @claim.reference %>
</div>

<div class="govuk-grid-row">
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/payments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<%# render("shared/error_summary", instance: @hold_note, errored_field_id_overrides: {body: "hold_body"}) if @hold_note.errors.any? %>

<div class="govuk-grid-row">
<%= render "admin/tasks/#{@claim_summary_view}", claim: @claim, heading: @claim.reference %>
<%= render "admin/tasks/#{claim_summary_view}", claim: @claim, heading: @claim.reference %>
</div>

<div class="govuk-grid-row">
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/arrival_date.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= render "shared/error_summary", instance: @task, errored_field_id_overrides: { "passed": "task_passed_true" } if @task.errors.any? %>

<div class="govuk-grid-row">
<%= render @claim_summary_view, claim: @claim, heading: "Arrival date" %>
<%= render claim_summary_view, claim: @claim, heading: "Arrival date" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/census_subjects_taught.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="govuk-grid-row">

<%= render @claim_summary_view, claim: @claim, heading: "School workforce census subjects taught" %>
<%= render claim_summary_view, claim: @claim, heading: "School workforce census subjects taught" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/employment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="govuk-grid-row">

<%= render @claim_summary_view, claim: @claim, heading: "Employment" %>
<%= render claim_summary_view, claim: @claim, heading: "Employment" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/employment_contract.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= render "shared/error_summary", instance: @task, errored_field_id_overrides: { "passed": "task_passed_true" } if @task.errors.any? %>

<div class="govuk-grid-row">
<%= render @claim_summary_view, claim: @claim, heading: "Employment contract check" %>
<%= render claim_summary_view, claim: @claim, heading: "Employment contract check" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/employment_start.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= render "shared/error_summary", instance: @task, errored_field_id_overrides: { "passed": "task_passed_true" } if @task.errors.any? %>

<div class="govuk-grid-row">
<%= render @claim_summary_view, claim: @claim, heading: "Employment start date check" %>
<%= render claim_summary_view, claim: @claim, heading: "Employment start date check" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/identity_confirmation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="govuk-grid-row">

<%= render @claim_summary_view, claim: @claim, heading: "Identity confirmation" %>
<%= render claim_summary_view, claim: @claim, heading: "Identity confirmation" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<% end %>

<div class="govuk-grid-row">
<%= render @claim_summary_view, claim: @claim %>
<%= render claim_summary_view, claim: @claim %>
</div>

<div class="govuk-grid-row">
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/induction_confirmation.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="govuk-grid-row">

<%= render @claim_summary_view, claim: @claim, heading: "Induction confirmation" %>
<%= render claim_summary_view, claim: @claim, heading: "Induction confirmation" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/matching_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="govuk-grid-row">

<%= render @claim_summary_view, claim: @claim, heading: "Claims with matching details" %>
<%= render claim_summary_view, claim: @claim, heading: "Claims with matching details" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/payroll_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= render "shared/error_summary", instance: @task, errored_field_id_overrides: { "passed": "task_passed_true" } if @task.errors.any? %>

<div class="govuk-grid-row">
<%= render @claim_summary_view, claim: @claim, heading: "Payroll details" %>
<%= render claim_summary_view, claim: @claim, heading: "Payroll details" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/payroll_gender.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="govuk-grid-row">

<%= render @claim_summary_view, claim: @claim, heading: "Payroll gender" %>
<%= render claim_summary_view, claim: @claim, heading: "Payroll gender" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/qualifications.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="govuk-grid-row">

<%= render @claim_summary_view, claim: @claim, heading: "Qualifications" %>
<%= render claim_summary_view, claim: @claim, heading: "Qualifications" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/student_loan_amount.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="govuk-grid-row">

<%= render @claim_summary_view, claim: @claim, heading: "Student loan amount" %>
<%= render claim_summary_view, claim: @claim, heading: "Student loan amount" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/student_loan_plan.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="govuk-grid-row">

<%= render @claim_summary_view, claim: @claim, heading: "Student loan plan type" %>
<%= render claim_summary_view, claim: @claim, heading: "Student loan plan type" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/subject.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= render "shared/error_summary", instance: @task, errored_field_id_overrides: { "passed": "task_passed_true" } if @task.errors.any? %>

<div class="govuk-grid-row">
<%= render @claim_summary_view, claim: @claim, heading: "Subject check" %>
<%= render claim_summary_view, claim: @claim, heading: "Subject check" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/teaching_hours.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= render "shared/error_summary", instance: @task, errored_field_id_overrides: { "passed": "task_passed_true" } if @task.errors.any? %>

<div class="govuk-grid-row">
<%= render @claim_summary_view, claim: @claim, heading: "Subject check" %>
<%= render claim_summary_view, claim: @claim, heading: "Subject check" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/visa.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= render "shared/error_summary", instance: @task, errored_field_id_overrides: { "passed": "task_passed_true" } if @task.errors.any? %>

<div class="govuk-grid-row">
<%= render @claim_summary_view, claim: @claim, heading: "Visa check" %>
<%= render claim_summary_view, claim: @claim, heading: "Visa check" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
Expand Down
25 changes: 25 additions & 0 deletions spec/helpers/admin/claim_summary_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require "rails_helper"

describe Admin::ClaimsHelper do
describe "#claim_summary_view" do
subject { helper.claim_summary_view }

let(:claim) { build(:claim, policy: policy) }

before { assign(:claim, claim) }

Policies.all.excluding(Policies::FurtherEducationPayments).each do |policy|
context "for policy #{policy}" do
let(:policy) { policy }

it { is_expected.to eq "claim_summary" }
end
end

context "for FurtherEducationPayments" do
let(:policy) { Policies::FurtherEducationPayments }

it { is_expected.to eq "claim_summary_further_education_payments" }
end
end
end

0 comments on commit 13117fa

Please sign in to comment.