Browse Source
* Change net income known question * earnings and frequency on same page * check answers changes and other fixes * some fixes * delete unnecessary test * fix failing spec * Refactor answer label Co-authored-by: baarkerlounger <baarkerlounger@users.noreply.github.com> * test and lint fixes * Method args * Fix specs * Rubocop * Incfreq doesn't have it's own check answers display * Add suffix to actual form * JSON linting * Conditional suffix only applies to check answers * Validate that earnings and incfreq must be provided together * Rubocop * Fix spec * Fix page view specs * form fixes * update error messages Co-authored-by: baarkerlounger <baarkerlounger@users.noreply.github.com> Co-authored-by: baarkerlounger <db@slothlife.xyz>pull/283/head
Dushan
3 years ago
committed by
GitHub
18 changed files with 163 additions and 122 deletions
@ -0,0 +1,24 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Validations::FinancialValidations do |
||||
subject(:financial_validator) { validator_class.new } |
||||
|
||||
let(:validator_class) { Class.new { include Validations::FinancialValidations } } |
||||
let(:record) { FactoryBot.create(:case_log) } |
||||
|
||||
describe "earnings and income frequency" do |
||||
it "when earnings are provided it validates that income frequency must be provided" do |
||||
record.earnings = 500 |
||||
record.incfreq = nil |
||||
financial_validator.validate_net_income(record) |
||||
expect(record.errors["incfreq"]).to include(match I18n.t("validations.financial.earnings.freq_missing")) |
||||
end |
||||
|
||||
it "when income frequency is provided it validates that earnings must be provided" do |
||||
record.earnings = nil |
||||
record.incfreq = "Weekly" |
||||
financial_validator.validate_net_income(record) |
||||
expect(record.errors["earnings"]).to include(match I18n.t("validations.financial.earnings.earnings_missing")) |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue