Skip to content

Commit

Permalink
Setup the admin to display IRP claims
Browse files Browse the repository at this point in the history
In order to be able to display the IRP claims in the admin, there are
some basic methods that need to be available.

This change ensures the minimum implementation for displaying claims
without being concerned about the correctness of the required methods.
Specifically the `award_amount` is a placeholder.
  • Loading branch information
felixclack committed Jun 24, 2024
1 parent d5aa992 commit 7cbcdd6
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/models/policies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module Policies
POLICIES = [
StudentLoans,
EarlyCareerPayments,
LevellingUpPremiumPayments
LevellingUpPremiumPayments,
InternationalRelocationPayments,
].freeze

AMENDABLE_ELIGIBILITY_ATTRIBUTES = POLICIES.map do |policy|
Expand Down
2 changes: 2 additions & 0 deletions app/models/policies/international_relocation_payments.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module Policies
module InternationalRelocationPayments
include BasePolicy
extend self
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Policies
module InternationalRelocationPayments
class AdminTasksPresenter
include Admin::PresenterMethods

attr_reader :claim

def initialize(claim)
@claim = claim
end

def identity_confirmation
[
["Current school", current_school&.name],
["Contact number", current_school&.phone_number]
]
end

def qualifications
[
["Qualifications", "No qualifications"]
]
end

private

delegate :eligibility, to: :claim
delegate :current_school, to: :eligibility, allow_nil: true
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ module InternationalRelocationPayments
class Eligibility < ApplicationRecord
self.table_name = "international_relocation_payments_eligibilities"

AMENDABLE_ATTRIBUTES = %i[].freeze

has_one :claim, as: :eligibility, inverse_of: :eligibility
belongs_to :current_school, class_name: "School", optional: true

def award_amount
0
end

def ineligible?
false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Policies
module InternationalRelocationPayments
class EligibilityAdminAnswersPresenter
include Admin::PresenterMethods

attr_reader :eligibility

def initialize(eligibility)
@eligibility = eligibility
end

def answers
[].tap do |a|
a << current_school
end
end

private

def current_school
[
translate("admin.current_school"),
eligibility.current_school.present? ? display_school(eligibility.current_school) : "No"
]
end
end
end
end
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,10 @@ en:
claim_amount_description: "Additional payment for teaching"
support_email_address: "[email protected]"
information_provided_further_details_link_text: levelling up premium payment (opens in new tab)
international_relocation_payments:
<<: *additional_payments
policy_short_name: "International Relocation Payments"
policy_acronym: "IRP"
get_a_teacher_relocation_payment:
journey_name: "Get a teacher relocation payment"
feedback_email: "[email protected]"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCurrentSchoolToIrpEligiblity < ActiveRecord::Migration[7.0]
def change
add_reference :international_relocation_payments_eligibilities, :current_school, type: :uuid, foreign_key: {to_table: :schools}, index: { name: 'index_irp_on_current_school_id' }
end
end
5 changes: 4 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_06_21_152642) do
ActiveRecord::Schema[7.0].define(version: 2024_06_24_113100) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
enable_extension "pgcrypto"
Expand Down Expand Up @@ -191,7 +191,9 @@
t.string "application_route"
t.boolean "state_funded_secondary_school"
t.boolean "one_year"
t.uuid "current_school_id"
t.date "start_date"
t.index ["current_school_id"], name: "index_irp_on_current_school_id"
end

create_table "journey_configurations", primary_key: "routing_name", id: :string, force: :cascade do |t|
Expand Down Expand Up @@ -469,6 +471,7 @@
add_foreign_key "claims", "journeys_sessions"
add_foreign_key "decisions", "dfe_sign_in_users", column: "created_by_id"
add_foreign_key "early_career_payments_eligibilities", "schools", column: "current_school_id"
add_foreign_key "international_relocation_payments_eligibilities", "schools", column: "current_school_id"
add_foreign_key "levelling_up_premium_payments_eligibilities", "schools", column: "current_school_id"
add_foreign_key "notes", "claims"
add_foreign_key "notes", "dfe_sign_in_users", column: "created_by_id"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FactoryBot.define do
factory :international_relocation_payments_eligibility, class: "Policies::InternationalRelocationPayments::Eligibility" do
trait :eligible do
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'rails_helper'

RSpec.describe Policies::InternationalRelocationPayments::AdminTasksPresenter, type: :model do
subject { presenter }

let(:claim) { build(:claim, policy: Policies::InternationalRelocationPayments) }
let(:eligibility) { claim.eligibility }
let(:presenter) { described_class.new(claim) }

it { is_expected.to delegate_method(:eligibility).to(:claim) }

describe "#identity_confirmation" do
subject { presenter.identity_confirmation }
before do
eligibility.current_school = build(:school, name: "School name", phone_number: "0123456789")
end

it "returns an array of label and values for displaying information for the identity confirmation check" do
is_expected.to eq [["Current school", "School name"], ["Contact number", "0123456789"]]
end
end

describe "#qualifications" do
subject(:qualifications) { presenter.qualifications }

it "returns an array of label and values for displaying information for the qualifications check" do
is_expected.to eq [["Qualifications", "No qualifications"]]
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require "rails_helper"

RSpec.describe Policies::InternationalRelocationPayments::EligibilityAdminAnswersPresenter, type: :model do
let(:claim) { build(:claim, :submittable, policy: Policies::InternationalRelocationPayments, academic_year: "2021/2022") }

subject(:presenter) { described_class.new(claim.eligibility) }

describe "#answers" do
it "returns an array of questions and answers for displaying to service operator" do
expected_answers = [
[I18n.t("admin.current_school"), "No"],
]

expect(presenter.answers).to eq expected_answers
end
end
end

0 comments on commit 7cbcdd6

Please sign in to comment.