Browse Source

Include shared validations in sales log model and run validate_numeric_min_max method

pull/1079/head
Kat 4 years ago
parent
commit
3ab684733b
  1. 1
      app/models/form/sales/questions/buyer1_income.rb
  2. 1
      app/models/sales_log.rb
  3. 4
      spec/models/form/sales/questions/buyer1_income_spec.rb

1
app/models/form/sales/questions/buyer1_income.rb

@ -7,6 +7,7 @@ class Form::Sales::Questions::Buyer1Income < ::Form::Question
@type = "numeric" @type = "numeric"
@page = page @page = page
@min = 0 @min = 0
@max = 999_999
@step = 1 @step = 1
@width = 5 @width = 5
@prefix = "£" @prefix = "£"

1
app/models/sales_log.rb

@ -1,5 +1,6 @@
class SalesLogValidator < ActiveModel::Validator class SalesLogValidator < ActiveModel::Validator
include Validations::Sales::HouseholdValidations include Validations::Sales::HouseholdValidations
include Validations::SharedValidations
def validate(record) def validate(record)
validation_methods = public_methods.select { |method| method.starts_with?("validate_") } validation_methods = public_methods.select { |method| method.starts_with?("validate_") }

4
spec/models/form/sales/questions/buyer1_income_spec.rb

@ -54,4 +54,8 @@ RSpec.describe Form::Sales::Questions::Buyer1Income, type: :model do
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(1) expect(question.check_answers_card_number).to eq(1)
end end
it "has correct max" do
expect(question.max).to eq(999_999)
end
end end

Loading…
Cancel
Save