From 4a24614aca6b6aeaf3c8a3fb51337c0a88e40f87 Mon Sep 17 00:00:00 2001 From: fumimowdan Date: Fri, 22 Sep 2023 14:59:04 +0100 Subject: [PATCH] Delete unused code --- app/models/policies/contract_start_date.rb | 29 ------------------ app/models/policies/entry_date.rb | 21 ------------- .../policies/contract_start_date_spec.rb | 24 --------------- spec/models/policies/entry_date_spec.rb | 30 ------------------- 4 files changed, 104 deletions(-) delete mode 100644 app/models/policies/contract_start_date.rb delete mode 100644 app/models/policies/entry_date.rb delete mode 100644 spec/models/policies/contract_start_date_spec.rb delete mode 100644 spec/models/policies/entry_date_spec.rb diff --git a/app/models/policies/contract_start_date.rb b/app/models/policies/contract_start_date.rb deleted file mode 100644 index 925282eb..00000000 --- a/app/models/policies/contract_start_date.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# The `ContractStartDate` class defines the policy for contract start dates. -# -# This policy determines whether a given start date is eligible based on the -# rule that employment start dates from the first Monday in July are considered -# eligible. -# -# It calculates the first Monday in July of the current year and compares -# it with the given start date to determine eligibility. -# -# @example -# Policies::ContractStartDate.eligible?(Date.new(2023, 7, 3)) #=> true -# -# @example -# Policies::ContractStartDate.eligible?(Date.new(2023, 6, 30)) #=> false -# -module Policies - class ContractStartDate - def self.eligible?(start_date) - current_year = Date.current.year - first_monday_in_july = Date.new(current_year, 7, 1) - .beginning_of_month - .next_occurring(:monday) - - start_date >= first_monday_in_july - end - end -end diff --git a/app/models/policies/entry_date.rb b/app/models/policies/entry_date.rb deleted file mode 100644 index 6837f009..00000000 --- a/app/models/policies/entry_date.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# The `EntryDate` class defines the policy for contract start dates. -# -# This Policy determines whether a given entry date is eligible based on the -# start date of the contract. If the applicant entered the country 3 months -# or less before the start of the contract, then they are eligible. -# -# @example -# Policies::ContractStartDate.eligible?( -# Date.new(2023, 1, 2), -# Date.new(2023, 4, 2) -# ) #=> true -# -module Policies - class EntryDate - def self.eligible?(entry_date, start_date) - entry_date >= start_date - 3.months - end - end -end diff --git a/spec/models/policies/contract_start_date_spec.rb b/spec/models/policies/contract_start_date_spec.rb deleted file mode 100644 index 0f60f3de..00000000 --- a/spec/models/policies/contract_start_date_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -RSpec.describe Policies::ContractStartDate do - let(:first_monday_july) { Date.new(2023, 7, 3) } - - describe "#eligible?" do - it "returns true when the date is on the first Monday in July" do - expect(described_class.eligible?(first_monday_july)).to be true - end - - it "returns true when the date is after the first Monday in July" do - date = first_monday_july.advance(days: 1) - - expect(described_class.eligible?(date)).to be true - end - - it "returns false when the date is before the first Monday in July" do - date = first_monday_july.advance(days: -1) - expect(described_class.eligible?(date)).to be false - end - end -end diff --git a/spec/models/policies/entry_date_spec.rb b/spec/models/policies/entry_date_spec.rb deleted file mode 100644 index b4ced3db..00000000 --- a/spec/models/policies/entry_date_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -RSpec.describe Policies::EntryDate do - subject(:policy) { described_class } - - describe "#eligible?" do - it "returns true if the entry date is more than 3 months since start of contract" do - entry_date = Date.parse("2020-01-03") - start_date = Date.parse("2020-04-02") - - expect(policy.eligible?(entry_date, start_date)).to be(true) - end - - it "returns true if the entry date is 3 months since start of contract" do - entry_date = Date.parse("2020-01-02") - start_date = Date.parse("2020-04-02") - - expect(policy.eligible?(entry_date, start_date)).to be(true) - end - - it "returns false if the entry date is less than 3 months since start of contract" do - entry_date = Date.parse("2020-01-01") - start_date = Date.parse("2020-04-02") - - expect(policy.eligible?(entry_date, start_date)).to be(false) - end - end -end