Browse Source
# Conflicts: # spec/models/validations/sales/household_validations_spec.rbpull/1178/head
19 changed files with 121 additions and 38 deletions
@ -0,0 +1,9 @@
|
||||
module Validations::Sales::SaleInformationValidations |
||||
def validate_deposit_range(record) |
||||
return if record.deposit.blank? |
||||
|
||||
unless record.deposit >= 0 && record.deposit <= 999_999 |
||||
record.errors.add :deposit, "Cash deposit must be £0 - £999,999" |
||||
end |
||||
end |
||||
end |
||||
@ -1,16 +1,22 @@
|
||||
<div class="app-card"> |
||||
<h2 class="govuk-heading-s">Collection resources</h2> |
||||
<p class="govuk-body-l govuk-!-margin-bottom-3">Collection resources</p> |
||||
<p class="govuk-body govuk-!-margin-bottom-6">For lettings starting during 1 April 2023 - 31 March 2024 and sales completing during the same period, use the 23/24 forms.</p> |
||||
|
||||
<h2 class="govuk-body-l govuk-!-margin-bottom-3">Lettings 23/24</h2> |
||||
<%= render DocumentListComponent.new(items: [ |
||||
{ |
||||
name: "Lettings log for tenants (2023/24)", |
||||
href: "https://core.communities.gov.uk/public/download/guides-and-manuals/2023-24%20Lettings%20paper%20form.pdf?download-format=pdf", |
||||
metadata: "PDF, 281 KB, 8 pages", |
||||
}, |
||||
]) %> |
||||
|
||||
<h2 class="govuk-body-l govuk-!-margin-bottom-3">Lettings 22/23</h2> |
||||
<%= render DocumentListComponent.new(items: [ |
||||
{ |
||||
name: "Lettings log for tenants (2022/23)", |
||||
href: "https://core.communities.gov.uk/public/download/guides-and-manuals/2022-23%20Lettings%20paper%20form.pdf?download-format=pdf", |
||||
metadata: "PDF, 654 KB, 4 pages", |
||||
}, |
||||
{ |
||||
name: "Lettings log for tenants (2021/22)", |
||||
href: "https://core.communities.gov.uk/public/download/guides-and-manuals/2021_22%20Lettings%20Log.pdf?download-format=pdf", |
||||
metadata: "PDF, 302 KB, 3 pages", |
||||
}, |
||||
]) %> |
||||
</div> |
||||
|
||||
@ -0,0 +1,49 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Validations::Sales::SaleInformationValidations do |
||||
subject(:sale_information_validator) { validator_class.new } |
||||
|
||||
let(:validator_class) { Class.new { include Validations::Sales::SaleInformationValidations } } |
||||
|
||||
describe "#validate_deposit_range" do |
||||
context "when within permitted bounds" do |
||||
let(:record) { build(:sales_log, deposit: 0) } |
||||
|
||||
it "does not add an error" do |
||||
sale_information_validator.validate_deposit_range(record) |
||||
|
||||
expect(record.errors[:deposit]).not_to be_present |
||||
end |
||||
end |
||||
|
||||
context "when blank" do |
||||
let(:record) { build(:sales_log, deposit: nil) } |
||||
|
||||
it "does not add an error" do |
||||
sale_information_validator.validate_deposit_range(record) |
||||
|
||||
expect(record.errors[:deposit]).not_to be_present |
||||
end |
||||
end |
||||
|
||||
context "when below lower bound" do |
||||
let(:record) { build(:sales_log, deposit: -1) } |
||||
|
||||
it "adds an error" do |
||||
sale_information_validator.validate_deposit_range(record) |
||||
|
||||
expect(record.errors[:deposit]).to be_present |
||||
end |
||||
end |
||||
|
||||
context "when higher than upper bound" do |
||||
let(:record) { build(:sales_log, deposit: 1_000_000) } |
||||
|
||||
it "adds an error" do |
||||
sale_information_validator.validate_deposit_range(record) |
||||
|
||||
expect(record.errors[:deposit]).to be_present |
||||
end |
||||
end |
||||
end |
||||
end |
||||
Loading…
Reference in new issue