Browse Source

change period mappings in test

pull/388/head
Kat 3 years ago
parent
commit
716adf08c8
  1. 144
      spec/models/case_log_spec.rb

144
spec/models/case_log_spec.rb

@ -310,35 +310,35 @@ RSpec.describe CaseLog do
context "when rent is paid bi-weekly" do context "when rent is paid bi-weekly" do
it "correctly derives and saves weekly rent" do it "correctly derives and saves weekly rent" do
case_log.update!(brent: 100, period: 0) case_log.update!(brent: 100, period: 2)
record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wrent).to eq(50.0) expect(case_log.wrent).to eq(50.0)
expect(record_from_db["wrent"]).to eq(50.0) expect(record_from_db["wrent"]).to eq(50.0)
end end
it "correctly derives and saves weekly service charge" do it "correctly derives and saves weekly service charge" do
case_log.update!(scharge: 100, period: 0) case_log.update!(scharge: 100, period: 2)
record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wscharge).to eq(50.0) expect(case_log.wscharge).to eq(50.0)
expect(record_from_db["wscharge"]).to eq(50.0) expect(record_from_db["wscharge"]).to eq(50.0)
end end
it "correctly derives and saves weekly personal service charge" do it "correctly derives and saves weekly personal service charge" do
case_log.update!(pscharge: 100, period: 0) case_log.update!(pscharge: 100, period: 2)
record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wpschrge).to eq(50.0) expect(case_log.wpschrge).to eq(50.0)
expect(record_from_db["wpschrge"]).to eq(50.0) expect(record_from_db["wpschrge"]).to eq(50.0)
end end
it "correctly derives and saves weekly support charge" do it "correctly derives and saves weekly support charge" do
case_log.update!(supcharg: 100, period: 0) case_log.update!(supcharg: 100, period: 2)
record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(50.0) expect(case_log.wsupchrg).to eq(50.0)
expect(record_from_db["wsupchrg"]).to eq(50.0) expect(record_from_db["wsupchrg"]).to eq(50.0)
end end
it "correctly derives and saves weekly total charge" do it "correctly derives and saves weekly total charge" do
case_log.update!(tcharge: 100, period: 0) case_log.update!(tcharge: 100, period: 2)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtcharge).to eq(50.0) expect(case_log.wtcharge).to eq(50.0)
expect(record_from_db["wtcharge"]).to eq(50.0) expect(record_from_db["wtcharge"]).to eq(50.0)
@ -347,7 +347,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 0, hb: 1) case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 2, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(50.0) expect(case_log.wtshortfall).to eq(50.0)
expect(record_from_db["wtshortfall"]).to eq(50.0) expect(record_from_db["wtshortfall"]).to eq(50.0)
@ -356,7 +356,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 0, hb: 6) case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 2, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(50.0) expect(case_log.wtshortfall).to eq(50.0)
expect(record_from_db["wtshortfall"]).to eq(50.0) expect(record_from_db["wtshortfall"]).to eq(50.0)
@ -365,7 +365,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 0, hb: 8) case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 2, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(50.0) expect(case_log.wtshortfall).to eq(50.0)
expect(record_from_db["wtshortfall"]).to eq(50.0) expect(record_from_db["wtshortfall"]).to eq(50.0)
@ -376,35 +376,35 @@ RSpec.describe CaseLog do
context "when rent is paid every 4 weeks" do context "when rent is paid every 4 weeks" do
it "correctly derives and saves weekly rent" do it "correctly derives and saves weekly rent" do
case_log.update!(brent: 120, period: 1) case_log.update!(brent: 120, period: 3)
record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wrent).to eq(30.0) expect(case_log.wrent).to eq(30.0)
expect(record_from_db["wrent"]).to eq(30.0) expect(record_from_db["wrent"]).to eq(30.0)
end end
it "correctly derives and saves weekly service charge" do it "correctly derives and saves weekly service charge" do
case_log.update!(scharge: 120, period: 1) case_log.update!(scharge: 120, period: 3)
record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wscharge).to eq(30.0) expect(case_log.wscharge).to eq(30.0)
expect(record_from_db["wscharge"]).to eq(30.0) expect(record_from_db["wscharge"]).to eq(30.0)
end end
it "correctly derives and saves weekly personal service charge" do it "correctly derives and saves weekly personal service charge" do
case_log.update!(pscharge: 120, period: 1) case_log.update!(pscharge: 120, period: 3)
record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wpschrge).to eq(30.0) expect(case_log.wpschrge).to eq(30.0)
expect(record_from_db["wpschrge"]).to eq(30.0) expect(record_from_db["wpschrge"]).to eq(30.0)
end end
it "correctly derives and saves weekly support charge" do it "correctly derives and saves weekly support charge" do
case_log.update!(supcharg: 120, period: 1) case_log.update!(supcharg: 120, period: 3)
record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(30.0) expect(case_log.wsupchrg).to eq(30.0)
expect(record_from_db["wsupchrg"]).to eq(30.0) expect(record_from_db["wsupchrg"]).to eq(30.0)
end end
it "correctly derives and saves weekly total charge" do it "correctly derives and saves weekly total charge" do
case_log.update!(tcharge: 120, period: 1) case_log.update!(tcharge: 120, period: 3)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtcharge).to eq(30.0) expect(case_log.wtcharge).to eq(30.0)
expect(record_from_db["wtcharge"]).to eq(30.0) expect(record_from_db["wtcharge"]).to eq(30.0)
@ -413,7 +413,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 1, hb: 1) case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 3, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0) expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0) expect(record_from_db["wtshortfall"]).to eq(30.0)
@ -422,7 +422,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 1, hb: 6) case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 3, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0) expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0) expect(record_from_db["wtshortfall"]).to eq(30.0)
@ -431,7 +431,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 1, hb: 8) case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 3, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0) expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0) expect(record_from_db["wtshortfall"]).to eq(30.0)
@ -442,35 +442,35 @@ RSpec.describe CaseLog do
context "when rent is paid every calendar month" do context "when rent is paid every calendar month" do
it "correctly derives and saves weekly rent" do it "correctly derives and saves weekly rent" do
case_log.update!(brent: 130, period: 2) case_log.update!(brent: 130, period: 4)
record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wrent).to eq(30.0) expect(case_log.wrent).to eq(30.0)
expect(record_from_db["wrent"]).to eq(30.0) expect(record_from_db["wrent"]).to eq(30.0)
end end
it "correctly derives and saves weekly service charge" do it "correctly derives and saves weekly service charge" do
case_log.update!(scharge: 130, period: 2) case_log.update!(scharge: 130, period: 4)
record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wscharge).to eq(30.0) expect(case_log.wscharge).to eq(30.0)
expect(record_from_db["wscharge"]).to eq(30.0) expect(record_from_db["wscharge"]).to eq(30.0)
end end
it "correctly derives and saves weekly personal service charge" do it "correctly derives and saves weekly personal service charge" do
case_log.update!(pscharge: 130, period: 2) case_log.update!(pscharge: 130, period: 4)
record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wpschrge).to eq(30.0) expect(case_log.wpschrge).to eq(30.0)
expect(record_from_db["wpschrge"]).to eq(30.0) expect(record_from_db["wpschrge"]).to eq(30.0)
end end
it "correctly derives and saves weekly support charge" do it "correctly derives and saves weekly support charge" do
case_log.update!(supcharg: 130, period: 2) case_log.update!(supcharg: 130, period: 4)
record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(30.0) expect(case_log.wsupchrg).to eq(30.0)
expect(record_from_db["wsupchrg"]).to eq(30.0) expect(record_from_db["wsupchrg"]).to eq(30.0)
end end
it "correctly derives and saves weekly total charge" do it "correctly derives and saves weekly total charge" do
case_log.update!(tcharge: 130, period: 2) case_log.update!(tcharge: 130, period: 4)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtcharge).to eq(30.0) expect(case_log.wtcharge).to eq(30.0)
expect(record_from_db["wtcharge"]).to eq(30.0) expect(record_from_db["wtcharge"]).to eq(30.0)
@ -479,7 +479,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 2, hb: 1) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0) expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0) expect(record_from_db["wtshortfall"]).to eq(30.0)
@ -488,7 +488,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 2, hb: 6) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0) expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0) expect(record_from_db["wtshortfall"]).to eq(30.0)
@ -497,7 +497,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 2, hb: 8) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0) expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0) expect(record_from_db["wtshortfall"]).to eq(30.0)
@ -508,35 +508,35 @@ RSpec.describe CaseLog do
context "when rent is paid weekly for 50 weeks" do context "when rent is paid weekly for 50 weeks" do
it "correctly derives and saves weekly rent" do it "correctly derives and saves weekly rent" do
case_log.update!(brent: 130, period: 3) case_log.update!(brent: 130, period: 5)
record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wrent).to eq(125.0) expect(case_log.wrent).to eq(125.0)
expect(record_from_db["wrent"]).to eq(125.0) expect(record_from_db["wrent"]).to eq(125.0)
end end
it "correctly derives and saves weekly service charge" do it "correctly derives and saves weekly service charge" do
case_log.update!(scharge: 130, period: 3) case_log.update!(scharge: 130, period: 5)
record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wscharge).to eq(125.0) expect(case_log.wscharge).to eq(125.0)
expect(record_from_db["wscharge"]).to eq(125.0) expect(record_from_db["wscharge"]).to eq(125.0)
end end
it "correctly derives and saves weekly personal service charge" do it "correctly derives and saves weekly personal service charge" do
case_log.update!(pscharge: 130, period: 3) case_log.update!(pscharge: 130, period: 5)
record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wpschrge).to eq(125.0) expect(case_log.wpschrge).to eq(125.0)
expect(record_from_db["wpschrge"]).to eq(125.0) expect(record_from_db["wpschrge"]).to eq(125.0)
end end
it "correctly derives and saves weekly support charge" do it "correctly derives and saves weekly support charge" do
case_log.update!(supcharg: 130, period: 3) case_log.update!(supcharg: 130, period: 5)
record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(125.0) expect(case_log.wsupchrg).to eq(125.0)
expect(record_from_db["wsupchrg"]).to eq(125.0) expect(record_from_db["wsupchrg"]).to eq(125.0)
end end
it "correctly derives and saves weekly total charge" do it "correctly derives and saves weekly total charge" do
case_log.update!(tcharge: 130, period: 3) case_log.update!(tcharge: 130, period: 5)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtcharge).to eq(125.0) expect(case_log.wtcharge).to eq(125.0)
expect(record_from_db["wtcharge"]).to eq(125.0) expect(record_from_db["wtcharge"]).to eq(125.0)
@ -545,7 +545,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 3, hb: 1) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(125.0) expect(case_log.wtshortfall).to eq(125.0)
expect(record_from_db["wtshortfall"]).to eq(125.0) expect(record_from_db["wtshortfall"]).to eq(125.0)
@ -554,7 +554,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 3, hb: 6) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(125.0) expect(case_log.wtshortfall).to eq(125.0)
expect(record_from_db["wtshortfall"]).to eq(125.0) expect(record_from_db["wtshortfall"]).to eq(125.0)
@ -563,7 +563,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 3, hb: 8) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(125.0) expect(case_log.wtshortfall).to eq(125.0)
expect(record_from_db["wtshortfall"]).to eq(125.0) expect(record_from_db["wtshortfall"]).to eq(125.0)
@ -574,35 +574,35 @@ RSpec.describe CaseLog do
context "when rent is paid weekly for 49 weeks" do context "when rent is paid weekly for 49 weeks" do
it "correctly derives and saves weekly rent" do it "correctly derives and saves weekly rent" do
case_log.update!(brent: 130, period: 4) case_log.update!(brent: 130, period: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wrent).to eq(122.5) expect(case_log.wrent).to eq(122.5)
expect(record_from_db["wrent"]).to eq(122.5) expect(record_from_db["wrent"]).to eq(122.5)
end end
it "correctly derives and saves weekly service charge" do it "correctly derives and saves weekly service charge" do
case_log.update!(scharge: 130, period: 4) case_log.update!(scharge: 130, period: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wscharge).to eq(122.5) expect(case_log.wscharge).to eq(122.5)
expect(record_from_db["wscharge"]).to eq(122.5) expect(record_from_db["wscharge"]).to eq(122.5)
end end
it "correctly derives and saves weekly personal service charge" do it "correctly derives and saves weekly personal service charge" do
case_log.update!(pscharge: 130, period: 4) case_log.update!(pscharge: 130, period: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wpschrge).to eq(122.5) expect(case_log.wpschrge).to eq(122.5)
expect(record_from_db["wpschrge"]).to eq(122.5) expect(record_from_db["wpschrge"]).to eq(122.5)
end end
it "correctly derives and saves weekly support charge" do it "correctly derives and saves weekly support charge" do
case_log.update!(supcharg: 130, period: 4) case_log.update!(supcharg: 130, period: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(122.5) expect(case_log.wsupchrg).to eq(122.5)
expect(record_from_db["wsupchrg"]).to eq(122.5) expect(record_from_db["wsupchrg"]).to eq(122.5)
end end
it "correctly derives and saves weekly total charge" do it "correctly derives and saves weekly total charge" do
case_log.update!(tcharge: 130, period: 4) case_log.update!(tcharge: 130, period: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtcharge).to eq(122.5) expect(case_log.wtcharge).to eq(122.5)
expect(record_from_db["wtcharge"]).to eq(122.5) expect(record_from_db["wtcharge"]).to eq(122.5)
@ -611,7 +611,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 1) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(122.5) expect(case_log.wtshortfall).to eq(122.5)
expect(record_from_db["wtshortfall"]).to eq(122.5) expect(record_from_db["wtshortfall"]).to eq(122.5)
@ -620,7 +620,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 6) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(122.5) expect(case_log.wtshortfall).to eq(122.5)
expect(record_from_db["wtshortfall"]).to eq(122.5) expect(record_from_db["wtshortfall"]).to eq(122.5)
@ -629,7 +629,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 8) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(122.5) expect(case_log.wtshortfall).to eq(122.5)
expect(record_from_db["wtshortfall"]).to eq(122.5) expect(record_from_db["wtshortfall"]).to eq(122.5)
@ -640,35 +640,35 @@ RSpec.describe CaseLog do
context "when rent is paid weekly for 48 weeks" do context "when rent is paid weekly for 48 weeks" do
it "correctly derives and saves weekly rent" do it "correctly derives and saves weekly rent" do
case_log.update!(brent: 130, period: 5) case_log.update!(brent: 130, period: 7)
record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wrent).to eq(120.0) expect(case_log.wrent).to eq(120.0)
expect(record_from_db["wrent"]).to eq(120.0) expect(record_from_db["wrent"]).to eq(120.0)
end end
it "correctly derives and saves weekly service charge" do it "correctly derives and saves weekly service charge" do
case_log.update!(scharge: 130, period: 5) case_log.update!(scharge: 130, period: 7)
record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wscharge).to eq(120.0) expect(case_log.wscharge).to eq(120.0)
expect(record_from_db["wscharge"]).to eq(120.0) expect(record_from_db["wscharge"]).to eq(120.0)
end end
it "correctly derives and saves weekly personal service charge" do it "correctly derives and saves weekly personal service charge" do
case_log.update!(pscharge: 130, period: 5) case_log.update!(pscharge: 130, period: 7)
record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wpschrge).to eq(120.0) expect(case_log.wpschrge).to eq(120.0)
expect(record_from_db["wpschrge"]).to eq(120.0) expect(record_from_db["wpschrge"]).to eq(120.0)
end end
it "correctly derives and saves weekly support charge" do it "correctly derives and saves weekly support charge" do
case_log.update!(supcharg: 130, period: 5) case_log.update!(supcharg: 130, period: 7)
record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(120.0) expect(case_log.wsupchrg).to eq(120.0)
expect(record_from_db["wsupchrg"]).to eq(120.0) expect(record_from_db["wsupchrg"]).to eq(120.0)
end end
it "correctly derives and saves weekly total charge" do it "correctly derives and saves weekly total charge" do
case_log.update!(tcharge: 130, period: 5) case_log.update!(tcharge: 130, period: 7)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtcharge).to eq(120.0) expect(case_log.wtcharge).to eq(120.0)
expect(record_from_db["wtcharge"]).to eq(120.0) expect(record_from_db["wtcharge"]).to eq(120.0)
@ -677,7 +677,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 1) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(120.0) expect(case_log.wtshortfall).to eq(120.0)
expect(record_from_db["wtshortfall"]).to eq(120.0) expect(record_from_db["wtshortfall"]).to eq(120.0)
@ -686,7 +686,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 6) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(120.0) expect(case_log.wtshortfall).to eq(120.0)
expect(record_from_db["wtshortfall"]).to eq(120.0) expect(record_from_db["wtshortfall"]).to eq(120.0)
@ -695,7 +695,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 8) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(120.0) expect(case_log.wtshortfall).to eq(120.0)
expect(record_from_db["wtshortfall"]).to eq(120.0) expect(record_from_db["wtshortfall"]).to eq(120.0)
@ -706,35 +706,35 @@ RSpec.describe CaseLog do
context "when rent is paid weekly for 47 weeks" do context "when rent is paid weekly for 47 weeks" do
it "correctly derives and saves weekly rent" do it "correctly derives and saves weekly rent" do
case_log.update!(brent: 130, period: 6) case_log.update!(brent: 130, period: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wrent).to eq(117.5) expect(case_log.wrent).to eq(117.5)
expect(record_from_db["wrent"]).to eq(117.5) expect(record_from_db["wrent"]).to eq(117.5)
end end
it "correctly derives and saves weekly service charge" do it "correctly derives and saves weekly service charge" do
case_log.update!(scharge: 130, period: 6) case_log.update!(scharge: 130, period: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wscharge).to eq(117.5) expect(case_log.wscharge).to eq(117.5)
expect(record_from_db["wscharge"]).to eq(117.5) expect(record_from_db["wscharge"]).to eq(117.5)
end end
it "correctly derives and saves weekly personal service charge" do it "correctly derives and saves weekly personal service charge" do
case_log.update!(pscharge: 130, period: 6) case_log.update!(pscharge: 130, period: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wpschrge).to eq(117.5) expect(case_log.wpschrge).to eq(117.5)
expect(record_from_db["wpschrge"]).to eq(117.5) expect(record_from_db["wpschrge"]).to eq(117.5)
end end
it "correctly derives and saves weekly support charge" do it "correctly derives and saves weekly support charge" do
case_log.update!(supcharg: 130, period: 6) case_log.update!(supcharg: 130, period: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(117.5) expect(case_log.wsupchrg).to eq(117.5)
expect(record_from_db["wsupchrg"]).to eq(117.5) expect(record_from_db["wsupchrg"]).to eq(117.5)
end end
it "correctly derives and saves weekly total charge" do it "correctly derives and saves weekly total charge" do
case_log.update!(tcharge: 130, period: 6) case_log.update!(tcharge: 130, period: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtcharge).to eq(117.5) expect(case_log.wtcharge).to eq(117.5)
expect(record_from_db["wtcharge"]).to eq(117.5) expect(record_from_db["wtcharge"]).to eq(117.5)
@ -743,7 +743,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 1) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(117.5) expect(case_log.wtshortfall).to eq(117.5)
expect(record_from_db["wtshortfall"]).to eq(117.5) expect(record_from_db["wtshortfall"]).to eq(117.5)
@ -752,7 +752,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 6) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(117.5) expect(case_log.wtshortfall).to eq(117.5)
expect(record_from_db["wtshortfall"]).to eq(117.5) expect(record_from_db["wtshortfall"]).to eq(117.5)
@ -761,7 +761,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 8) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(117.5) expect(case_log.wtshortfall).to eq(117.5)
expect(record_from_db["wtshortfall"]).to eq(117.5) expect(record_from_db["wtshortfall"]).to eq(117.5)
@ -772,35 +772,35 @@ RSpec.describe CaseLog do
context "when rent is paid weekly for 46 weeks" do context "when rent is paid weekly for 46 weeks" do
it "correctly derives and saves weekly rent" do it "correctly derives and saves weekly rent" do
case_log.update!(brent: 130, period: 7) case_log.update!(brent: 130, period: 9)
record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wrent).to eq(115.0) expect(case_log.wrent).to eq(115.0)
expect(record_from_db["wrent"]).to eq(115.0) expect(record_from_db["wrent"]).to eq(115.0)
end end
it "correctly derives and saves weekly service charge" do it "correctly derives and saves weekly service charge" do
case_log.update!(scharge: 130, period: 7) case_log.update!(scharge: 130, period: 9)
record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wscharge).to eq(115.0) expect(case_log.wscharge).to eq(115.0)
expect(record_from_db["wscharge"]).to eq(115.0) expect(record_from_db["wscharge"]).to eq(115.0)
end end
it "correctly derives and saves weekly personal service charge" do it "correctly derives and saves weekly personal service charge" do
case_log.update!(pscharge: 130, period: 7) case_log.update!(pscharge: 130, period: 9)
record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wpschrge).to eq(115.0) expect(case_log.wpschrge).to eq(115.0)
expect(record_from_db["wpschrge"]).to eq(115.0) expect(record_from_db["wpschrge"]).to eq(115.0)
end end
it "correctly derives and saves weekly support charge" do it "correctly derives and saves weekly support charge" do
case_log.update!(supcharg: 130, period: 7) case_log.update!(supcharg: 130, period: 9)
record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(115.0) expect(case_log.wsupchrg).to eq(115.0)
expect(record_from_db["wsupchrg"]).to eq(115.0) expect(record_from_db["wsupchrg"]).to eq(115.0)
end end
it "correctly derives and saves weekly total charge" do it "correctly derives and saves weekly total charge" do
case_log.update!(tcharge: 130, period: 7) case_log.update!(tcharge: 130, period: 9)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtcharge).to eq(115.0) expect(case_log.wtcharge).to eq(115.0)
expect(record_from_db["wtcharge"]).to eq(115.0) expect(record_from_db["wtcharge"]).to eq(115.0)
@ -809,7 +809,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 1) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 9, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(115.0) expect(case_log.wtshortfall).to eq(115.0)
expect(record_from_db["wtshortfall"]).to eq(115.0) expect(record_from_db["wtshortfall"]).to eq(115.0)
@ -818,7 +818,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 6) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 9, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(115.0) expect(case_log.wtshortfall).to eq(115.0)
expect(record_from_db["wtshortfall"]).to eq(115.0) expect(record_from_db["wtshortfall"]).to eq(115.0)
@ -827,7 +827,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 8) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 9, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(115.0) expect(case_log.wtshortfall).to eq(115.0)
expect(record_from_db["wtshortfall"]).to eq(115.0) expect(record_from_db["wtshortfall"]).to eq(115.0)
@ -838,35 +838,35 @@ RSpec.describe CaseLog do
context "when rent is paid weekly for 52 weeks" do context "when rent is paid weekly for 52 weeks" do
it "correctly derives and saves weekly rent" do it "correctly derives and saves weekly rent" do
case_log.update!(brent: 130, period: 8) case_log.update!(brent: 130, period: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wrent).to eq(130.0) expect(case_log.wrent).to eq(130.0)
expect(record_from_db["wrent"]).to eq(130.0) expect(record_from_db["wrent"]).to eq(130.0)
end end
it "correctly derives and saves weekly service charge" do it "correctly derives and saves weekly service charge" do
case_log.update!(scharge: 130, period: 8) case_log.update!(scharge: 130, period: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wscharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wscharge).to eq(130.0) expect(case_log.wscharge).to eq(130.0)
expect(record_from_db["wscharge"]).to eq(130.0) expect(record_from_db["wscharge"]).to eq(130.0)
end end
it "correctly derives and saves weekly personal service charge" do it "correctly derives and saves weekly personal service charge" do
case_log.update!(pscharge: 130, period: 8) case_log.update!(pscharge: 130, period: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wpschrge).to eq(130.0) expect(case_log.wpschrge).to eq(130.0)
expect(record_from_db["wpschrge"]).to eq(130.0) expect(record_from_db["wpschrge"]).to eq(130.0)
end end
it "correctly derives and saves weekly support charge" do it "correctly derives and saves weekly support charge" do
case_log.update!(supcharg: 130, period: 8) case_log.update!(supcharg: 130, period: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(130.0) expect(case_log.wsupchrg).to eq(130.0)
expect(record_from_db["wsupchrg"]).to eq(130.0) expect(record_from_db["wsupchrg"]).to eq(130.0)
end end
it "correctly derives and saves weekly total charge" do it "correctly derives and saves weekly total charge" do
case_log.update!(tcharge: 130, period: 8) case_log.update!(tcharge: 130, period: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtcharge from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtcharge).to eq(130.0) expect(case_log.wtcharge).to eq(130.0)
expect(record_from_db["wtcharge"]).to eq(130.0) expect(record_from_db["wtcharge"]).to eq(130.0)
@ -875,7 +875,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 1) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 1, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(130.0) expect(case_log.wtshortfall).to eq(130.0)
expect(record_from_db["wtshortfall"]).to eq(130.0) expect(record_from_db["wtshortfall"]).to eq(130.0)
@ -884,7 +884,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 6) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 1, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(130.0) expect(case_log.wtshortfall).to eq(130.0)
expect(record_from_db["wtshortfall"]).to eq(130.0) expect(record_from_db["wtshortfall"]).to eq(130.0)
@ -893,7 +893,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do
case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 8) case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 1, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0] record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(130.0) expect(case_log.wtshortfall).to eq(130.0)
expect(record_from_db["wtshortfall"]).to eq(130.0) expect(record_from_db["wtshortfall"]).to eq(130.0)

Loading…
Cancel
Save