<NME> minimum_wage_calculator_test.rb
<BEF> require_relative "../../test_helper"

module SmartAnswer::Calculators
  class MinimumWageCalculatorTest < ActiveSupport::TestCase
    context "Validation" do
      setup do
        @calculator = MinimumWageCalculator.new
      end

      context "for age" do
        should "not accept ages less than or equal to 0" do
          assert_not @calculator.valid_age?(0)
        end

        should "not accept ages greater than 200" do
          assert_not @calculator.valid_age?(201)
        end

        should "accept ages between 1 and 200" do
          assert @calculator.valid_age?(1)
          assert @calculator.valid_age?(200)
        end
      end

      context "for pay frequency" do
        should "not accept frequency less than 1" do
          assert_not @calculator.valid_pay_frequency?(0)
        end

        should "not accept frequency greater than 31" do
          assert_not @calculator.valid_pay_frequency?(32)
        end

        should "accept frequency between 1 and 31" do
          assert @calculator.valid_pay_frequency?(1)
          assert @calculator.valid_pay_frequency?(31)
        end
      end

      context "for hours worked" do
        setup do
          @calculator.pay_frequency = 1
        end

        should "not accept hours less than 0" do
          assert_not @calculator.valid_hours_worked?(0)
        end

        should "not accept hours greater than 16 times the pay frequency" do
          invalid_hours = (16 * @calculator.pay_frequency) + 1
          assert_not @calculator.valid_hours_worked?(invalid_hours)
        end

        should "accept hours greater than or equal to 1" do
          assert @calculator.valid_hours_worked?(1)
        end

        should "accept hours less than or equal to 16 times the pay frequency" do
          valid_hours = 16 * @calculator.pay_frequency
          assert @calculator.valid_hours_worked?(valid_hours)
        end
      end

      context "for accommodation charge" do
        should "not accept amount less than or equal to 0" do
          assert_not @calculator.valid_accommodation_charge?(0)
        end

        should "accept 1 or more" do
          assert @calculator.valid_accommodation_charge?(1)
        end
      end

      context "for accommodation usage" do
        should "not accept days per week of less than or equal to -1" do
          assert_not @calculator.valid_accommodation_usage?(-1)
        end

        should "not accept days per week of greater than or equal to 8" do
          assert_not @calculator.valid_accommodation_usage?(8)
        end

        should "accept days per week greater than or equal to 0" do
          assert @calculator.valid_accommodation_usage?(0)
        end

        should "accept days per week less than or equal to 7" do
          assert @calculator.valid_accommodation_usage?(7)
        end
      end

      context "for age for living wage" do
        should "not accept ages below 23" do
          assert_not @calculator.valid_age_for_living_wage?(22)
        end

        should "accept ages 23 or above" do
          assert @calculator.valid_age_for_living_wage?(23)
          assert @calculator.valid_age_for_living_wage?(24)
        end

        context "when a date is before 1 April 2021" do
          setup { @calculator.date = Date.parse("2020-04-01") }

          should "not accept ages below 25" do
            assert_not @calculator.valid_age_for_living_wage?(23)
          end

          should "accept ages 25 or above" do
            assert @calculator.valid_age_for_living_wage?(25)
            assert @calculator.valid_age_for_living_wage?(26)
          end
        end
      end
    end

    context "#eligible_for_living_wage?" do
      setup do
        @calculator = MinimumWageCalculator.new
      end

      should "return true if the age is 25 or over" do
        %w[25 26].each do |age|
          @calculator.age = age
          assert @calculator.eligible_for_living_wage?
        end
      end

      should "return true if the age is 23 or over, and the date is on or after 2021-04-01" do
        %w[23 24].each do |age|
          @calculator.date = Date.parse("2021-04-01")
          @calculator.age = age
          assert @calculator.eligible_for_living_wage?
        end
      end

      should "return false if age is lower than 24 or nil, and date is before 2021-04-01" do
        %w[nil 0 24].each do |age|
          @calculator.date = Date.parse("2020-04-01")
          @calculator.age = age
          assert_not @calculator.eligible_for_living_wage?
        end
      end

      should "return false if age is over 25, and date is on or before 2016-04-01" do
        @calculator.date = Date.parse("2016-03-30")
        @calculator.age = 26
        assert_not @calculator.eligible_for_living_wage?
      end
    end

    context "#under_school_leaving_age?" do
      setup do
        @calculator = MinimumWageCalculator.new
      end

      should "return true if age is lower than 16" do
        @calculator.age = 15
        assert @calculator.under_school_leaving_age?
      end

      should "return false if age is greater than or equal to 16" do
        @calculator.age = 16
        assert_not @calculator.under_school_leaving_age?
      end
    end

    context "MinimumWageCalculator" do
      setup do
        @age = 19
        @basic_pay = 187.46
        @basic_hours = 39
        @calculator = MinimumWageCalculator.new(
          age: @age,
          date: Date.parse("2010-10-01"),
          basic_pay: @basic_pay,
          basic_hours: @basic_hours,
        )
      end

      context "compare basic_pay_check and @basic_pay" do
        should "be the same " do
          assert_equal @basic_pay, @calculator.basic_total
        end
      end

      context "minimum hourly rate" do
        should "be the minimum wage per hour for the age and year" do
          assert_equal 4.92, @calculator.minimum_hourly_rate
        end
        context "when eligible for living wage?" do
          should "return the national living wage rate" do
            @calculator = MinimumWageCalculator.new(age: 25, date: Date.parse("2016-04-02"))
            assert_equal 7.2, @calculator.minimum_hourly_rate
          end
        end
      end

      context "total hours" do
        should "be basic" do
          assert_equal 39, @calculator.total_hours
        end
      end

      context "total pay" do
        should "calculate the basic pay plus the accomodation cost" do
          @calculator.accommodation_cost = 100
          assert_equal 287.46, @calculator.total_pay
        end
      end

      context "above minimum wage?" do
        should "indicate if the minimum hourly rate is less than the total hourly rate" do
          assert_not @calculator.minimum_wage_or_above?
        end

        should "be above if the average hourly rate is above the minimum hourly rate" do
          @calculator.basic_pay = 400
          @calculator.basic_hours = 39
          assert @calculator.minimum_wage_or_above?
        end
      end

      context "adjust for accommodation" do
        setup do
          @calculator.accommodation_adjustment(7.99, 4)
        end

        should "calculate the accommodation cost" do
          assert_equal(-13.52, @calculator.accommodation_cost)
        end

        should "be included the total pay calculation" do
          assert_equal 173.94, @calculator.total_pay
        end
      end

      context "historical entitlement" do
        setup do
          @historical_entitlement = 191.88
        end
        should "be minimum wage for the year multiplied by total hours" do
          assert_equal @historical_entitlement, @calculator.historical_entitlement
        end
      end

      # Test cases from the Minimum National Wage docs.
      # for various scenarios.
      #
      # Scenario 1
      context "minimum wage calculator for a 24 yr old low hourly rate" do
        setup do
          # NOTE: test_date included as all minimum wage calculations are date sensitive
          test_date = Date.parse("2012-08-01")
          @calculator = MinimumWageCalculator.new(
            age: 24,
            pay_frequency: 7,
            basic_pay: 168,
            basic_hours: 40,
            date: test_date,
          )
        end

        should "have a total hourly rate of 4.20" do
          assert_equal 6.08, @calculator.minimum_hourly_rate
        end
      end

      # Scenario 2
      context "minimum wage calculator for a 23 yr old working 70 hours over a fortnight after 01/10/2012" do
        setup do
          @calculator = MinimumWageCalculator.new(
            age: 23,
            pay_frequency: 14,
            date: Date.parse("2012-10-01"),
            basic_pay: 420,
            basic_hours: 70,
          )
        end

        should "calculate total hourly rate" do
          assert_equal 6.19, @calculator.minimum_hourly_rate
        end
      end

      # Scenario 3
      context "24 y/o with a low hourly rate" do
        setup do
          @calculator = MinimumWageCalculator.new(
            age: 24,
            date: Date.parse("2011-10-01"),
            pay_frequency: 7,
            basic_pay: 100,
            basic_hours: 40,
          )
        end

        should "calculate total hourly rate" do
          assert_equal 6.08, @calculator.minimum_hourly_rate
          assert_not @calculator.minimum_wage_or_above?, "should be below the minimum wage"
        end

        should "adjust for free accommodation" do
          @calculator.accommodation_adjustment(0, 5)
          assert_equal 23.65, @calculator.accommodation_cost
          assert_not @calculator.minimum_wage_or_above?, "should be below the minimum wage"
        end

        should "adjust for accommodation charged above the threshold" do
          @calculator.accommodation_adjustment(6, 5)
          assert_equal(-6.35, @calculator.accommodation_cost)
          assert_not @calculator.minimum_wage_or_above?, "should be below the minimum wage"
        end

        should "adjust for accommodation charged below the threshold" do
          @calculator.accommodation_adjustment(4, 5)
          assert_equal 0, @calculator.accommodation_cost
          assert_not @calculator.minimum_wage_or_above?, "should be below the minimum wage"
        end
      end
    end
    # Test URL: /am-i-getting-minimum-wage/y/past_payment/2010-10-01/apprentice_under_19/7/35/78.0/0/no
    context "Historical adjustment for apprentices (hours:35, pay:78)" do
      setup do
        travel_to("30 Sep 2013")
      end
      should "equal 10.07 historical adjustment" do
        @calculator = MinimumWageCalculator.new(
          age: 0,
          date: Date.parse("1 November 2010"),
          pay_frequency: 7,
          basic_hours: 35,
          basic_pay: 78,
          is_apprentice: true,
        )
        assert_equal 2.50, @calculator.minimum_hourly_rate
      end
    end

    context "per hour minimum wage" do
      should "give the minimum wage for this year (2011-2012) for a given age" do
        test_date = Date.parse("2012-08-01")
        @calculator = MinimumWageCalculator.new age: 17, date: test_date
        assert_equal 3.68, @calculator.per_hour_minimum_wage
        @calculator = MinimumWageCalculator.new age: 21, date: test_date
        assert_equal 6.08, @calculator.per_hour_minimum_wage
      end
      should "give the historical minimum wage" do
        @calculator = MinimumWageCalculator.new age: 17, date: Date.parse("2010-10-01")
        assert_equal 3.64, @calculator.per_hour_minimum_wage
        @calculator = MinimumWageCalculator.new age: 18, date: Date.parse("2010-10-01")
        assert_equal 4.92, @calculator.per_hour_minimum_wage
      end
      should "account for the 18-22 age range before 2010" do
        @calculator = MinimumWageCalculator.new age: 21, date: Date.parse("2009-10-01")
        assert_equal 4.83, @calculator.per_hour_minimum_wage
        @calculator = MinimumWageCalculator.new age: 22, date: Date.parse("2009-10-01")
        assert_equal 5.8, @calculator.per_hour_minimum_wage
      end

      context "from 1 Oct 2013" do
        setup do
          @calculator = MinimumWageCalculator.new(date: Date.parse("2013-10-01"))
        end

        should "be 3.72 for people aged under 18" do
          [0, 17].each do |age|
            @calculator.age = age
            assert_equal 3.72, @calculator.per_hour_minimum_wage
          end
        end

        should "be 5.03 for people aged between 18 and 20" do
          [18, 20].each do |age|
            @calculator.age = age
            assert_equal 5.03, @calculator.per_hour_minimum_wage
          end
        end

        should "be 6.31 for people aged over 25" do
          [25, 999].each do |age|
            @calculator.age = age
            assert_equal 6.31, @calculator.per_hour_minimum_wage
          end
        end

        should "have an apprentice rate of 2.68" do
          assert_equal 2.68, @calculator.apprentice_rate
        end

        should "have an accommodation rate of 4.91" do
          assert_equal 4.91, @calculator.free_accommodation_rate
        end
      end

      context "from 1 Oct 2014" do
        setup do
          @calculator = MinimumWageCalculator.new(date: Date.parse("2014-10-01"))
        end

        should "be 3.79 for people aged under 18" do
          [0, 17].each do |age|
            @calculator.age = age
            assert_equal 3.79, @calculator.per_hour_minimum_wage
          end
        end

        should "be 5.13 for people aged between 18 and 20" do
          [18, 20].each do |age|
            @calculator.age = age
            assert_equal 5.13, @calculator.per_hour_minimum_wage
          end
        end

        should "be 6.50 for people aged over 25" do
          [25, 999].each do |age|
            @calculator.age = age
            assert_equal 6.50, @calculator.per_hour_minimum_wage
          end
        end

        should "have an apprentice rate of 3.40" do
          assert_equal 2.73, @calculator.apprentice_rate
        end

        should "have an accommodation rate of 5.08" do
          assert_equal 5.08, @calculator.free_accommodation_rate
        end
      end

      context "from 1 Oct 2015" do
        setup do
          @calculator = MinimumWageCalculator.new(date: Date.parse("2015-10-01"))
        end

        should "be 3.87 for people aged under 18" do
          [0, 17].each do |age|
            @calculator.age = age
            assert_equal 3.87, @calculator.per_hour_minimum_wage
          end
        end

        should "be 5.30 for people aged between 18 and 20" do
          [18, 20].each do |age|
            @calculator.age = age
            assert_equal 5.30, @calculator.per_hour_minimum_wage
          end
        end

        should "be 6.70 for people aged over 25" do
          [25, 999].each do |age|
            @calculator.age = age
            assert_equal 6.70, @calculator.per_hour_minimum_wage
          end
        end

        should "have an apprentice rate of 3.30" do
          assert_equal 3.30, @calculator.apprentice_rate
        end

        should "have an accommodation rate of 5.35" do
          assert_equal 5.35, @calculator.free_accommodation_rate
        end
      end

      context "from 1 Apr 2016" do
        setup do
          @calculator = MinimumWageCalculator.new(date: Date.parse("2016-04-01"))
        end

        should "be 3.87 for people aged under 18" do
          [0, 17].each do |age|
            @calculator.age = age
            assert_equal 3.87, @calculator.per_hour_minimum_wage
          end
        end

        should "be 5.30 for people aged between 18 and 20" do
          [18, 20].each do |age|
            @calculator.age = age
            assert_equal 5.30, @calculator.per_hour_minimum_wage
          end
        end

        should "be 6.70 for people aged between 21 and 24" do
          [21, 24].each do |age|
            @calculator.age = age
            assert_equal 6.70, @calculator.per_hour_minimum_wage
          end
        end

        should "be 7.20 for people aged over 25" do
          [25, 999].each do |age|
            @calculator.age = age
            assert_equal 7.20, @calculator.per_hour_minimum_wage
          end
        end

        should "have an apprentice rate of 3.30" do
          assert_equal 3.30, @calculator.apprentice_rate
        end

        should "have an accommodation rate of 5.35" do
          assert_equal 5.35, @calculator.free_accommodation_rate
        end
      end

      context "from 1 Oct 2016" do
        setup do
          @calculator = MinimumWageCalculator.new(date: Date.parse("2016-10-02"))
        end

        should "be 4.00 for people aged under 18" do
          [0, 17].each do |age|
            @calculator.age = age
            assert_equal 4.00, @calculator.per_hour_minimum_wage
          end
        end

        should "be 5.55 for people aged between 18 and 20" do
          [18, 20].each do |age|
            @calculator.age = age
            assert_equal 5.55, @calculator.per_hour_minimum_wage
          end
        end

        should "be 6.95 for people aged between 21 and 24" do
          [21, 24].each do |age|
            @calculator.age = age
            assert_equal 6.95, @calculator.per_hour_minimum_wage
          end
        end

        should "be 7.20 for people aged over 25" do
          [25, 999].each do |age|
            @calculator.age = age
            assert_equal 7.20, @calculator.per_hour_minimum_wage
          end
        end

        should "have an apprentice rate of 3.40" do
          assert_equal 3.40, @calculator.apprentice_rate
        end

        should "have an accommodation rate of 6.0" do
          assert_equal 6.00, @calculator.free_accommodation_rate
        end
      end

      context "from 1 Apr 2022" do
        setup do
          @calculator = MinimumWageCalculator.new(date: Date.parse("2022-04-01"))
        end

        should "be correct for those under 18" do
          [0, 17].each do |age|
            @calculator.age = age
            assert_equal 4.81, @calculator.per_hour_minimum_wage
          end
        end

        should "be correct for 18 to 20 year olds" do
          [18, 20].each do |age|
            @calculator.age = age
            assert_equal 6.83, @calculator.per_hour_minimum_wage
          end
        end

        should "be correct for 21 to 22 year olds" do
          [21, 22].each do |age|
            @calculator.age = age
            assert_equal 9.18, @calculator.per_hour_minimum_wage
          end
        end

        should "be correct for those aged 23 and over" do
          [23, 100].each do |age|
            @calculator.age = age
            assert_equal 9.50, @calculator.per_hour_minimum_wage
          end
        end

        should "have correct apprentice rate" do
          assert_equal 4.81, @calculator.apprentice_rate
        end

        should "have correct accommodation rate" do
          assert_equal 8.7, @calculator.free_accommodation_rate
        end
      end
    end

    context "accommodation adjustment" do
      setup do
        # NOTE: test_date must be included as results are date sensitive
        test_date = Date.parse("2012-08-01")
        @calculator = MinimumWageCalculator.new age: 22, date: test_date
      end
      should "return 0 for accommodation charged under the threshold" do
        assert_equal 0, @calculator.accommodation_adjustment("3.50", 5)
      end
      should "return the number of nights times the threshold if the accommodation is free" do
        assert_equal((4.73 * 4), @calculator.accommodation_adjustment("0", 4))
      end
      should "subtract the charged fee from the free fee where the accommodation costs more than the threshold" do
        charge = 10.12
        number_of_nights = 5
        free_adjustment = (4.73 * number_of_nights).round(2)
        charged_adjustment = @calculator.accommodation_adjustment(charge, number_of_nights)
        assert_equal((free_adjustment - (charge * number_of_nights)).round(2), charged_adjustment)
        assert charged_adjustment.negative? # this should always be less than zero
      end
    end

    context "total_pay and basic_rate calculations" do
      setup do
        @calculator = MinimumWageCalculator.new(
          age: 25,
          pay_frequency: 5,
          basic_pay: 260,
          basic_hours: 40,
        )
      end

      context "test date sensitive vars" do
        setup do
          test_date = Date.parse("2012-08-01")
          @calculator = MinimumWageCalculator.new(
            age: 25,
            pay_frequency: 5,
            basic_pay: 260,
            basic_hours: 40,
            date: test_date,
          )
        end

        should "[with accommodation_adjustment] return rate total (216.39)" do
          @calculator.accommodation_adjustment(20, 4)
          assert_equal 216.39, @calculator.total_pay
        end
      end
    end

    context "non-historical minimum wage" do
      should "return today's minimum wage rate for 25 year old" do
        @calculator = MinimumWageCalculator.new(
          age: 24,
          pay_frequency: 7,
          basic_pay: 312,
          basic_hours: 39,
          date: Date.parse("5 Aug 2012"),
        )
        assert_equal 6.08, @calculator.minimum_hourly_rate
      end
      should "return today's minimum wage rate for 19 year old" do
        @calculator = MinimumWageCalculator.new(
          age: 19,
          pay_frequency: 7,
          basic_pay: 312,
          basic_hours: 39,
          date: Date.parse("5 Aug 2012"),
        )
        assert_equal 4.98, @calculator.minimum_hourly_rate
      end
      should "return today's minimum wage rate for 17 year old" do
        @calculator = MinimumWageCalculator.new(
          age: 17,
          pay_frequency: 7,
          basic_pay: 312,
          basic_hours: 39,
          date: Date.parse("5 Aug 2012"),
        )
        assert_equal 3.68, @calculator.minimum_hourly_rate
      end
    end

    context "non-historical total entitlement and underpayment test" do
      setup do
        @calculator = MinimumWageCalculator.new(
          age: 24,
          pay_frequency: 7,
          basic_pay: 100,
          basic_hours: 39,
          date: Date.parse("5 Aug 2012"),
        )
      end
      should "return total_entitlement" do
        assert_equal 237.12, @calculator.total_entitlement
      end
      should "return total_underpayment" do
        assert_equal 100.0, @calculator.total_pay
      end
      should "return total_underpayment as 0.0" do
        @calculator = MinimumWageCalculator.new(
          age: 25,
          pay_frequency: 7,
          basic_pay: 300,
          basic_hours: 39,
          date: Date.parse("5 Aug 2012"),
        )
        assert_equal 300.0, @calculator.total_pay
      end
    end

    context "historical below minimum wage" do
      setup do
        travel_to("2012-10-09")
      end
      should "return false to minimum_wage_or_above?" do
        @calculator = MinimumWageCalculator.new(
          age: 25,
          pay_frequency: 7,
          basic_pay: 100,
          basic_hours: 39,
          date: Date.parse("5 Aug 2010"),
        )
        assert_not @calculator.minimum_wage_or_above?
      end
      should "below minimum_wage_or_above (200)" do
        @calculator = MinimumWageCalculator.new(
          age: 24,
          pay_frequency: 7,
          basic_pay: 200,
          basic_hours: 40,
          date: Date.parse("5 Aug 2010"),
        )
        # underpayment
        assert_not @calculator.minimum_wage_or_above?
        assert_equal 6.19, @calculator.per_hour_minimum_wage(Time.zone.today)
      end
    end
  end
end

<MSG> Remove historic data, update tests for minimum_wage calculator.

<DFF> @@ -172,7 +172,7 @@ module SmartAnswer::Calculators
         @basic_hours = 39
         @calculator = MinimumWageCalculator.new(
           age: @age,
-          date: Date.parse("2010-10-01"),
+          date: Date.parse("2022-04-01"),
           basic_pay: @basic_pay,
           basic_hours: @basic_hours,
         )
@@ -186,12 +186,12 @@ module SmartAnswer::Calculators
 
       context "minimum hourly rate" do
         should "be the minimum wage per hour for the age and year" do
-          assert_equal 4.92, @calculator.minimum_hourly_rate
+          assert_equal 6.83, @calculator.minimum_hourly_rate
         end
         context "when eligible for living wage?" do
           should "return the national living wage rate" do
-            @calculator = MinimumWageCalculator.new(age: 25, date: Date.parse("2016-04-02"))
-            assert_equal 7.2, @calculator.minimum_hourly_rate
+            @calculator = MinimumWageCalculator.new(age: 25)
+            assert_equal 9.5, @calculator.minimum_hourly_rate
           end
         end
       end
@@ -223,21 +223,21 @@ module SmartAnswer::Calculators
 
       context "adjust for accommodation" do
         setup do
-          @calculator.accommodation_adjustment(7.99, 4)
+          @calculator.accommodation_adjustment(12.00, 4)
         end
 
         should "calculate the accommodation cost" do
-          assert_equal(-13.52, @calculator.accommodation_cost)
+          assert_equal(-13.2, @calculator.accommodation_cost)
         end
 
         should "be included the total pay calculation" do
-          assert_equal 173.94, @calculator.total_pay
+          assert_equal 174.26, @calculator.total_pay
         end
       end
 
       context "historical entitlement" do
         setup do
-          @historical_entitlement = 191.88
+          @historical_entitlement = 266.37
         end
         should "be minimum wage for the year multiplied by total hours" do
           assert_equal @historical_entitlement, @calculator.historical_entitlement
@@ -262,7 +262,7 @@ module SmartAnswer::Calculators
         end
 
         should "have a total hourly rate of 4.20" do
-          assert_equal 6.08, @calculator.minimum_hourly_rate
+          assert_equal 9.5, @calculator.minimum_hourly_rate
         end
       end
 
@@ -272,14 +272,14 @@ module SmartAnswer::Calculators
           @calculator = MinimumWageCalculator.new(
             age: 23,
             pay_frequency: 14,
-            date: Date.parse("2012-10-01"),
+            date: Date.parse("2022-10-01"),
             basic_pay: 420,
             basic_hours: 70,
           )
         end
 
         should "calculate total hourly rate" do
-          assert_equal 6.19, @calculator.minimum_hourly_rate
+          assert_equal 9.5, @calculator.minimum_hourly_rate
         end
       end
 
@@ -296,257 +296,31 @@ module SmartAnswer::Calculators
         end
 
         should "calculate total hourly rate" do
-          assert_equal 6.08, @calculator.minimum_hourly_rate
+          assert_equal 9.5, @calculator.minimum_hourly_rate
           assert_not @calculator.minimum_wage_or_above?, "should be below the minimum wage"
         end
 
         should "adjust for free accommodation" do
           @calculator.accommodation_adjustment(0, 5)
-          assert_equal 23.65, @calculator.accommodation_cost
+          assert_equal 43.5, @calculator.accommodation_cost
           assert_not @calculator.minimum_wage_or_above?, "should be below the minimum wage"
         end
 
         should "adjust for accommodation charged above the threshold" do
-          @calculator.accommodation_adjustment(6, 5)
-          assert_equal(-6.35, @calculator.accommodation_cost)
+          @calculator.accommodation_adjustment(12, 5)
+          assert_equal(-16.5, @calculator.accommodation_cost)
           assert_not @calculator.minimum_wage_or_above?, "should be below the minimum wage"
         end
 
         should "adjust for accommodation charged below the threshold" do
-          @calculator.accommodation_adjustment(4, 5)
+          @calculator.accommodation_adjustment(8, 5)
           assert_equal 0, @calculator.accommodation_cost
           assert_not @calculator.minimum_wage_or_above?, "should be below the minimum wage"
         end
       end
     end
-    # Test URL: /am-i-getting-minimum-wage/y/past_payment/2010-10-01/apprentice_under_19/7/35/78.0/0/no
-    context "Historical adjustment for apprentices (hours:35, pay:78)" do
-      setup do
-        travel_to("30 Sep 2013")
-      end
-      should "equal 10.07 historical adjustment" do
-        @calculator = MinimumWageCalculator.new(
-          age: 0,
-          date: Date.parse("1 November 2010"),
-          pay_frequency: 7,
-          basic_hours: 35,
-          basic_pay: 78,
-          is_apprentice: true,
-        )
-        assert_equal 2.50, @calculator.minimum_hourly_rate
-      end
-    end
 
     context "per hour minimum wage" do
-      should "give the minimum wage for this year (2011-2012) for a given age" do
-        test_date = Date.parse("2012-08-01")
-        @calculator = MinimumWageCalculator.new age: 17, date: test_date
-        assert_equal 3.68, @calculator.per_hour_minimum_wage
-        @calculator = MinimumWageCalculator.new age: 21, date: test_date
-        assert_equal 6.08, @calculator.per_hour_minimum_wage
-      end
-      should "give the historical minimum wage" do
-        @calculator = MinimumWageCalculator.new age: 17, date: Date.parse("2010-10-01")
-        assert_equal 3.64, @calculator.per_hour_minimum_wage
-        @calculator = MinimumWageCalculator.new age: 18, date: Date.parse("2010-10-01")
-        assert_equal 4.92, @calculator.per_hour_minimum_wage
-      end
-      should "account for the 18-22 age range before 2010" do
-        @calculator = MinimumWageCalculator.new age: 21, date: Date.parse("2009-10-01")
-        assert_equal 4.83, @calculator.per_hour_minimum_wage
-        @calculator = MinimumWageCalculator.new age: 22, date: Date.parse("2009-10-01")
-        assert_equal 5.8, @calculator.per_hour_minimum_wage
-      end
-
-      context "from 1 Oct 2013" do
-        setup do
-          @calculator = MinimumWageCalculator.new(date: Date.parse("2013-10-01"))
-        end
-
-        should "be 3.72 for people aged under 18" do
-          [0, 17].each do |age|
-            @calculator.age = age
-            assert_equal 3.72, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 5.03 for people aged between 18 and 20" do
-          [18, 20].each do |age|
-            @calculator.age = age
-            assert_equal 5.03, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 6.31 for people aged over 25" do
-          [25, 999].each do |age|
-            @calculator.age = age
-            assert_equal 6.31, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "have an apprentice rate of 2.68" do
-          assert_equal 2.68, @calculator.apprentice_rate
-        end
-
-        should "have an accommodation rate of 4.91" do
-          assert_equal 4.91, @calculator.free_accommodation_rate
-        end
-      end
-
-      context "from 1 Oct 2014" do
-        setup do
-          @calculator = MinimumWageCalculator.new(date: Date.parse("2014-10-01"))
-        end
-
-        should "be 3.79 for people aged under 18" do
-          [0, 17].each do |age|
-            @calculator.age = age
-            assert_equal 3.79, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 5.13 for people aged between 18 and 20" do
-          [18, 20].each do |age|
-            @calculator.age = age
-            assert_equal 5.13, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 6.50 for people aged over 25" do
-          [25, 999].each do |age|
-            @calculator.age = age
-            assert_equal 6.50, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "have an apprentice rate of 3.40" do
-          assert_equal 2.73, @calculator.apprentice_rate
-        end
-
-        should "have an accommodation rate of 5.08" do
-          assert_equal 5.08, @calculator.free_accommodation_rate
-        end
-      end
-
-      context "from 1 Oct 2015" do
-        setup do
-          @calculator = MinimumWageCalculator.new(date: Date.parse("2015-10-01"))
-        end
-
-        should "be 3.87 for people aged under 18" do
-          [0, 17].each do |age|
-            @calculator.age = age
-            assert_equal 3.87, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 5.30 for people aged between 18 and 20" do
-          [18, 20].each do |age|
-            @calculator.age = age
-            assert_equal 5.30, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 6.70 for people aged over 25" do
-          [25, 999].each do |age|
-            @calculator.age = age
-            assert_equal 6.70, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "have an apprentice rate of 3.30" do
-          assert_equal 3.30, @calculator.apprentice_rate
-        end
-
-        should "have an accommodation rate of 5.35" do
-          assert_equal 5.35, @calculator.free_accommodation_rate
-        end
-      end
-
-      context "from 1 Apr 2016" do
-        setup do
-          @calculator = MinimumWageCalculator.new(date: Date.parse("2016-04-01"))
-        end
-
-        should "be 3.87 for people aged under 18" do
-          [0, 17].each do |age|
-            @calculator.age = age
-            assert_equal 3.87, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 5.30 for people aged between 18 and 20" do
-          [18, 20].each do |age|
-            @calculator.age = age
-            assert_equal 5.30, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 6.70 for people aged between 21 and 24" do
-          [21, 24].each do |age|
-            @calculator.age = age
-            assert_equal 6.70, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 7.20 for people aged over 25" do
-          [25, 999].each do |age|
-            @calculator.age = age
-            assert_equal 7.20, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "have an apprentice rate of 3.30" do
-          assert_equal 3.30, @calculator.apprentice_rate
-        end
-
-        should "have an accommodation rate of 5.35" do
-          assert_equal 5.35, @calculator.free_accommodation_rate
-        end
-      end
-
-      context "from 1 Oct 2016" do
-        setup do
-          @calculator = MinimumWageCalculator.new(date: Date.parse("2016-10-02"))
-        end
-
-        should "be 4.00 for people aged under 18" do
-          [0, 17].each do |age|
-            @calculator.age = age
-            assert_equal 4.00, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 5.55 for people aged between 18 and 20" do
-          [18, 20].each do |age|
-            @calculator.age = age
-            assert_equal 5.55, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 6.95 for people aged between 21 and 24" do
-          [21, 24].each do |age|
-            @calculator.age = age
-            assert_equal 6.95, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "be 7.20 for people aged over 25" do
-          [25, 999].each do |age|
-            @calculator.age = age
-            assert_equal 7.20, @calculator.per_hour_minimum_wage
-          end
-        end
-
-        should "have an apprentice rate of 3.40" do
-          assert_equal 3.40, @calculator.apprentice_rate
-        end
-
-        should "have an accommodation rate of 6.0" do
-          assert_equal 6.00, @calculator.free_accommodation_rate
-        end
-      end
-
       context "from 1 Apr 2022" do
         setup do
           @calculator = MinimumWageCalculator.new(date: Date.parse("2022-04-01"))
@@ -593,19 +367,19 @@ module SmartAnswer::Calculators
     context "accommodation adjustment" do
       setup do
         # NOTE: test_date must be included as results are date sensitive
-        test_date = Date.parse("2012-08-01")
+        test_date = Date.parse("2022-08-01")
         @calculator = MinimumWageCalculator.new age: 22, date: test_date
       end
       should "return 0 for accommodation charged under the threshold" do
         assert_equal 0, @calculator.accommodation_adjustment("3.50", 5)
       end
       should "return the number of nights times the threshold if the accommodation is free" do
-        assert_equal((4.73 * 4), @calculator.accommodation_adjustment("0", 4))
+        assert_equal((8.70 * 4), @calculator.accommodation_adjustment("0", 4))
       end
       should "subtract the charged fee from the free fee where the accommodation costs more than the threshold" do
         charge = 10.12
         number_of_nights = 5
-        free_adjustment = (4.73 * number_of_nights).round(2)
+        free_adjustment = (8.70 * number_of_nights).round(2)
         charged_adjustment = @calculator.accommodation_adjustment(charge, number_of_nights)
         assert_equal((free_adjustment - (charge * number_of_nights)).round(2), charged_adjustment)
         assert charged_adjustment.negative? # this should always be less than zero
@@ -636,7 +410,7 @@ module SmartAnswer::Calculators
 
         should "[with accommodation_adjustment] return rate total (216.39)" do
           @calculator.accommodation_adjustment(20, 4)
-          assert_equal 216.39, @calculator.total_pay
+          assert_equal 227.73, @calculator.total_pay
         end
       end
     end
@@ -648,9 +422,8 @@ module SmartAnswer::Calculators
           pay_frequency: 7,
           basic_pay: 312,
           basic_hours: 39,
-          date: Date.parse("5 Aug 2012"),
         )
-        assert_equal 6.08, @calculator.minimum_hourly_rate
+        assert_equal 9.5, @calculator.minimum_hourly_rate
       end
       should "return today's minimum wage rate for 19 year old" do
         @calculator = MinimumWageCalculator.new(
@@ -658,9 +431,8 @@ module SmartAnswer::Calculators
           pay_frequency: 7,
           basic_pay: 312,
           basic_hours: 39,
-          date: Date.parse("5 Aug 2012"),
         )
-        assert_equal 4.98, @calculator.minimum_hourly_rate
+        assert_equal 6.83, @calculator.minimum_hourly_rate
       end
       should "return today's minimum wage rate for 17 year old" do
         @calculator = MinimumWageCalculator.new(
@@ -668,9 +440,8 @@ module SmartAnswer::Calculators
           pay_frequency: 7,
           basic_pay: 312,
           basic_hours: 39,
-          date: Date.parse("5 Aug 2012"),
         )
-        assert_equal 3.68, @calculator.minimum_hourly_rate
+        assert_equal 4.81, @calculator.minimum_hourly_rate
       end
     end
 
@@ -685,7 +456,7 @@ module SmartAnswer::Calculators
         )
       end
       should "return total_entitlement" do
-        assert_equal 237.12, @calculator.total_entitlement
+        assert_equal 370.5, @calculator.total_entitlement
       end
       should "return total_underpayment" do
         assert_equal 100.0, @calculator.total_pay
@@ -701,33 +472,5 @@ module SmartAnswer::Calculators
         assert_equal 300.0, @calculator.total_pay
       end
     end
-
-    context "historical below minimum wage" do
-      setup do
-        travel_to("2012-10-09")
-      end
-      should "return false to minimum_wage_or_above?" do
-        @calculator = MinimumWageCalculator.new(
-          age: 25,
-          pay_frequency: 7,
-          basic_pay: 100,
-          basic_hours: 39,
-          date: Date.parse("5 Aug 2010"),
-        )
-        assert_not @calculator.minimum_wage_or_above?
-      end
-      should "below minimum_wage_or_above (200)" do
-        @calculator = MinimumWageCalculator.new(
-          age: 24,
-          pay_frequency: 7,
-          basic_pay: 200,
-          basic_hours: 40,
-          date: Date.parse("5 Aug 2010"),
-        )
-        # underpayment
-        assert_not @calculator.minimum_wage_or_above?
-        assert_equal 6.19, @calculator.per_hour_minimum_wage(Time.zone.today)
-      end
-    end
   end
 end

{'addition_count': 24, 'commit_subject': 'Remove historic data, update tests for minimum_wage calculator.', 'deletion_count': 281, 'file_extension': '.rb', 'lang': 'rb', 'license': 'mit', 'repo_name': 'alphagov/smart-answers'}