Browse Source

alter copy to avoid redundant repetition in validaiton message

validations-copy
Arthur Campbell 2 years ago
parent
commit
ca62bd5fa4
  1. 2
      app/models/form/sales/questions/savings.rb
  2. 2
      spec/models/form/sales/questions/savings_spec.rb
  3. 6
      spec/models/validations/shared_validations_spec.rb

2
app/models/form/sales/questions/savings.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::Savings < ::Form::Question
def initialize(id, hsh, page)
super
@id = "savings"
@check_answer_label = "Buyer’s total savings (to nearest £10) before any deposit paid"
@check_answer_label = "Buyer’s total savings before any deposit paid"
@header = "Enter their total savings to the nearest £10"
@type = "numeric"
@width = 5

2
spec/models/form/sales/questions/savings_spec.rb

@ -20,7 +20,7 @@ RSpec.describe Form::Sales::Questions::Savings, type: :model do
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyer’s total savings (to nearest £10) before any deposit paid")
expect(question.check_answer_label).to eq("Buyer’s total savings before any deposit paid")
end
it "has the correct type" do

6
spec/models/validations/shared_validations_spec.rb

@ -90,7 +90,7 @@ RSpec.describe Validations::SharedValidations do
it "adds the correct validation text when a question has a min but not a max" do
sales_log.savings = -10
shared_validator.validate_numeric_min_max(sales_log)
expect(sales_log.errors["savings"]).to include(match I18n.t("validations.numeric.above_min", field: "Buyer’s total savings (to nearest £10) before any deposit paid", min: "£0"))
expect(sales_log.errors["savings"]).to include(match I18n.t("validations.numeric.above_min", field: "Buyer’s total savings before any deposit paid", min: "£0"))
end
context "when validating percent" do
@ -139,13 +139,13 @@ RSpec.describe Validations::SharedValidations do
it "adds an error if input is not a multiple of ten" do
sales_log.savings = 30_005
shared_validator.validate_numeric_step(sales_log)
expect(sales_log.errors[:savings]).to include I18n.t("validations.numeric.nearest_ten", field: "Buyer’s total savings (to nearest £10) before any deposit paid")
expect(sales_log.errors[:savings]).to include I18n.t("validations.numeric.nearest_ten", field: "Buyer’s total savings before any deposit paid")
end
it "adds an error if the user attempts to input a number in exponent format" do
sales_log.savings = "3e5"
shared_validator.validate_numeric_step(sales_log)
expect(sales_log.errors[:savings]).to include I18n.t("validations.numeric.nearest_ten", field: "Buyer’s total savings (to nearest £10) before any deposit paid")
expect(sales_log.errors[:savings]).to include I18n.t("validations.numeric.nearest_ten", field: "Buyer’s total savings before any deposit paid")
end
it "does not add an error if input is a multiple of ten" do

Loading…
Cancel
Save