-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for teachercon1819 registration model
- Loading branch information
Showing
3 changed files
with
114 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
dashboard/test/models/pd/teachercon1819_registration_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'test_helper' | ||
|
||
class Pd::Teachercon1819RegistrationTest < ActiveSupport::TestCase | ||
test 'required field validations' do | ||
registration = Pd::Teachercon1819Registration.new | ||
refute registration.valid? | ||
assert_equal [ | ||
"Form data is required", | ||
], registration.errors.full_messages | ||
|
||
registration.form_data = {}.to_json | ||
refute registration.valid? | ||
assert_equal [ | ||
"Form data preferredFirstName", | ||
"Form data lastName", | ||
"Form data email", | ||
"Form data phone", | ||
"Form data teacherAcceptSeat", | ||
"Form data contactFirstName", | ||
"Form data contactLastName", | ||
"Form data contactRelationship", | ||
"Form data contactPhone", | ||
"Form data dietaryNeeds", | ||
"Form data liveFarAway", | ||
"Form data howTraveling", | ||
"Form data needHotel", | ||
"Form data photoRelease", | ||
"Form data liabilityWaiver", | ||
"Form data agreeShareContact", | ||
], registration.errors.full_messages | ||
|
||
registration.pd_application = create(:pd_teacher1819_application) | ||
registration.form_data = build(:pd_teachercon1819_registration_hash).to_json | ||
|
||
assert registration.valid? | ||
end | ||
|
||
test 'declined application requires fewer fields' do | ||
registration = create(:pd_teachercon1819_registration, accepted: false) | ||
|
||
assert registration.valid? | ||
refute registration.sanitize_form_data_hash.key?(:contact_first_name) | ||
refute registration.sanitize_form_data_hash.key?(:dietary_needs) | ||
end | ||
end |