Skip to content

Commit

Permalink
Merge pull request #1404 from consul/polls-officing-age-error
Browse files Browse the repository at this point in the history
makes age errors visible
  • Loading branch information
xuanxu committed Feb 7, 2017
2 parents 7abb741 + c473f98 commit 81d8baa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/officing/residence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def allowed_age
return unless @census_api_response.valid?

unless allowed_age?
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age'))
errors.add(:year_of_birth, I18n.t('verification.residence.new.error_not_allowed_age'))
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/models/officing/residence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
it "should not be valid if user is under allowed age" do
allow_any_instance_of(Officing::Residence).to receive(:date_of_birth).and_return(15.years.ago)
expect(residence).to_not be_valid
expect(residence.errors[:date_of_birth]).to include("You don't have the required age to participate")
expect(residence.errors[:year_of_birth]).to include("You don't have the required age to participate")
end

it "should be valid if user is above allowed age" do
allow_any_instance_of(Officing::Residence).to receive(:date_of_birth).and_return(16.years.ago)
expect(residence).to be_valid
expect(residence.errors[:date_of_birth]).to be_empty
expect(residence.errors[:year_of_birth]).to be_empty
end
end

Expand Down Expand Up @@ -94,4 +94,4 @@
end

end
end
end

0 comments on commit 81d8baa

Please sign in to comment.