Browse Source
* Add a non temp accommocation validation for vacancy reason * Only show errors relevant to the page questions * Add referral question/field * Add validation for referrals and vacancy reasons * change error message contentpull/247/head
kosiakkatrina
3 years ago
committed by
GitHub
13 changed files with 176 additions and 12 deletions
@ -0,0 +1,6 @@ |
|||||||
|
module FormPageErrorHelper |
||||||
|
def remove_other_page_errors(case_log, page) |
||||||
|
other_page_error_ids = case_log.errors.map(&:attribute) - page.questions.map { |q| q.id.to_sym }.concat([:base]) |
||||||
|
other_page_error_ids.each { |id| case_log.errors.delete(id) } |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,7 @@ |
|||||||
|
class AddReferralField < ActiveRecord::Migration[7.0] |
||||||
|
def change |
||||||
|
change_table :case_logs, bulk: true do |t| |
||||||
|
t.column :referral, :integer |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,24 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe FormPageErrorHelper do |
||||||
|
describe "#remove_other_page_errors" do |
||||||
|
context "removes non base other questions" do |
||||||
|
let!(:case_log) { FactoryBot.create(:case_log, :in_progress) } |
||||||
|
let!(:form) { case_log.form } |
||||||
|
|
||||||
|
before do |
||||||
|
case_log.errors.add :layear, "error" |
||||||
|
case_log.errors.add :period, "error_one" |
||||||
|
case_log.errors.add :base, "error_too" |
||||||
|
end |
||||||
|
|
||||||
|
it "returns details and user tabs" do |
||||||
|
page = form.get_page("rent") |
||||||
|
remove_other_page_errors(case_log, page) |
||||||
|
expect(case_log.errors.count).to eq(2) |
||||||
|
expect(case_log.errors.map(&:attribute)).to include(:period) |
||||||
|
expect(case_log.errors.map(&:attribute)).to include(:base) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue