fe 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +4 -4
- data/app/assets/config/fe/manifest.js +3 -0
- data/app/assets/config/manifest.js +3 -0
- data/app/assets/javascripts/application.js.erb +1 -1
- data/app/assets/javascripts/fe/admin.js +0 -1
- data/app/assets/javascripts/fe/fe.admin.js +2 -6
- data/app/assets/javascripts/fe/{fe.common.js → fe.common.js.erb} +14 -7
- data/app/assets/javascripts/fe/fe.public.js +1 -2
- data/app/assets/javascripts/fe/{fe.public.nojquery.js → fe.public.nojquery.js.erb} +152 -76
- data/app/assets/javascripts/fe/jquery.html5_upload.js +258 -0
- data/app/assets/stylesheets/fe/fe.screen.css.scss.erb +22 -1
- data/app/assets/stylesheets/fe/validation.css +5 -1
- data/app/controllers/{fe/concerns → concerns/fe}/admin/question_sheets_controller_concern.rb +15 -16
- data/app/controllers/concerns/fe/answer_pages_controller_concern.rb +131 -0
- data/app/controllers/{fe/concerns → concerns/fe}/answer_sheets_controller_concern.rb +14 -6
- data/app/controllers/{fe/concerns → concerns/fe}/application_controller_concern.rb +3 -3
- data/app/controllers/fe/admin/elements_controller.rb +46 -24
- data/app/controllers/fe/admin/email_templates_controller.rb +5 -5
- data/app/controllers/fe/admin/question_pages_controller.rb +8 -8
- data/app/controllers/fe/reference_pages_controller.rb +11 -11
- data/app/controllers/fe/reference_sheets_controller.rb +4 -4
- data/app/controllers/fe/references_controller.rb +19 -19
- data/app/controllers/fe/submit_pages_controller.rb +5 -5
- data/app/helpers/fe/answer_pages_helper.rb +1 -1
- data/app/helpers/fe/application_helper.rb +3 -3
- data/app/jobs/fe/update_reference_sheet_visibility_job.rb +11 -0
- data/app/mailers/fe/notifier.rb +4 -4
- data/app/models/answer_sheet.rb +1 -1
- data/app/models/application_record.rb +3 -0
- data/app/models/{fe/concerns → concerns/fe}/answer_concern.rb +2 -2
- data/app/models/{fe/concerns → concerns/fe}/answer_pages_presenter_concern.rb +6 -5
- data/app/models/concerns/fe/answer_sheet_concern.rb +125 -0
- data/app/models/{fe/concerns → concerns/fe}/choice_field_concern.rb +41 -23
- data/app/models/fe/address.rb +2 -2
- data/app/models/fe/answer.rb +1 -1
- data/app/models/fe/answer_sheet.rb +1 -1
- data/app/models/fe/answer_sheet_question_sheet.rb +2 -2
- data/app/models/fe/application.rb +14 -10
- data/app/models/fe/condition.rb +4 -4
- data/app/models/fe/date_field.rb +1 -1
- data/app/models/fe/element.rb +126 -44
- data/app/models/fe/email_address.rb +2 -2
- data/app/models/fe/email_template.rb +1 -1
- data/app/models/fe/page.rb +94 -19
- data/app/models/fe/page_element.rb +2 -2
- data/app/models/fe/paragraph.rb +1 -1
- data/app/models/fe/person.rb +5 -5
- data/app/models/fe/phone_number.rb +1 -1
- data/app/models/fe/question.rb +62 -38
- data/app/models/fe/question_grid.rb +15 -3
- data/app/models/fe/question_set.rb +53 -13
- data/app/models/fe/question_sheet.rb +49 -16
- data/app/models/fe/reference_question.rb +9 -3
- data/app/models/fe/reference_sheet.rb +102 -47
- data/app/models/fe/state_chooser.rb +2 -2
- data/app/models/fe/text_field.rb +2 -2
- data/app/models/fe/user.rb +1 -1
- data/app/models/staff.rb +6 -6
- data/app/views/fe/admin/elements/create.js.erb +3 -3
- data/app/views/fe/admin/elements/destroy.js.erb +1 -1
- data/app/views/fe/admin/elements/drop.js.erb +1 -1
- data/app/views/fe/admin/elements/duplicate.js.erb +1 -1
- data/app/views/fe/admin/elements/edit.js.erb +1 -1
- data/app/views/fe/admin/elements/error.js.erb +1 -1
- data/app/views/fe/admin/elements/new.js.erb +13 -6
- data/app/views/fe/admin/elements/update.js.erb +1 -1
- data/app/views/fe/admin/email_templates/_form.html.erb +3 -3
- data/app/views/fe/admin/email_templates/edit.html.erb +3 -3
- data/app/views/fe/admin/email_templates/index.html.erb +3 -3
- data/app/views/fe/admin/email_templates/new.html.erb +3 -3
- data/app/views/fe/admin/panels/_advanced_options.html.erb +8 -8
- data/app/views/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
- data/app/views/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
- data/app/views/fe/admin/panels/_common_fields.html.erb +2 -17
- data/app/views/fe/admin/panels/_condition.html.erb +1 -1
- data/app/views/fe/admin/panels/_insert.html.erb +25 -25
- data/app/views/fe/admin/panels/_nav_controls.html.erb +4 -4
- data/app/views/fe/admin/panels/_page.html.erb +1 -1
- data/app/views/fe/admin/panels/_pages_list.html.erb +3 -3
- data/app/views/fe/admin/panels/_prop_attachment_field.html.erb +2 -2
- data/app/views/fe/admin/panels/_prop_choice_field.html.erb +36 -17
- data/app/views/fe/admin/panels/_prop_date_field.html.erb +1 -1
- data/app/views/fe/admin/panels/_prop_element.html.erb +5 -5
- data/app/views/fe/admin/panels/_prop_page.html.erb +3 -3
- data/app/views/fe/admin/panels/_prop_paragraph.html.erb +8 -8
- data/app/views/fe/admin/panels/_prop_question_grid.html.erb +7 -2
- data/app/views/fe/admin/panels/_prop_question_grid_with_total.html.erb +2 -2
- data/app/views/fe/admin/panels/_prop_reference_question.html.erb +3 -3
- data/app/views/fe/admin/panels/_prop_section.html.erb +1 -1
- data/app/views/fe/admin/panels/_prop_sheet.html.erb +3 -3
- data/app/views/fe/admin/panels/_prop_text_field.html.erb +12 -12
- data/app/views/fe/admin/question_pages/_element.html.erb +7 -7
- data/app/views/fe/admin/question_pages/_element_show.html.erb +2 -2
- data/app/views/fe/admin/question_pages/_question_page.html.erb +4 -4
- data/app/views/fe/admin/question_pages/create.js.erb +3 -3
- data/app/views/fe/admin/question_pages/destroy.js.erb +3 -3
- data/app/views/fe/admin/question_pages/edit.js.erb +1 -1
- data/app/views/fe/admin/question_pages/error.js.erb +1 -1
- data/app/views/fe/admin/question_pages/show.js.erb +2 -2
- data/app/views/fe/admin/question_pages/show_panel.js.erb +1 -1
- data/app/views/fe/admin/question_pages/update.js.erb +1 -1
- data/app/views/fe/admin/question_sheets/edit.js.erb +1 -1
- data/app/views/fe/admin/question_sheets/error.js.erb +1 -1
- data/app/views/fe/admin/question_sheets/index.html.erb +8 -8
- data/app/views/fe/admin/question_sheets/new.html.erb +3 -3
- data/app/views/fe/admin/question_sheets/show.html.erb +5 -5
- data/app/views/fe/admin/question_sheets/update.js.erb +1 -1
- data/app/views/fe/answer_pages/_answer_page.html.erb +13 -14
- data/app/views/fe/answer_pages/_element.html.erb +22 -2
- data/app/views/fe/answer_pages/_page_name.html.erb +1 -1
- data/app/views/fe/answer_pages/show.html.erb +39 -0
- data/app/views/fe/answer_pages/update.js.erb +10 -2
- data/app/views/fe/answer_sheets/_answer_sheet.html.erb +4 -4
- data/app/views/fe/answer_sheets/_element.html.erb +9 -7
- data/app/views/fe/answer_sheets/_incomplete.html.erb +1 -1
- data/app/views/fe/answer_sheets/_page_link.html.erb +9 -7
- data/app/views/fe/answer_sheets/_pages_list.html.erb +3 -3
- data/app/views/fe/answer_sheets/_submit_to.html.erb +1 -1
- data/app/views/fe/answer_sheets/_title.html.erb +1 -1
- data/app/views/fe/answer_sheets/edit.html.erb +18 -18
- data/app/views/fe/answer_sheets/incomplete.js.erb +7 -4
- data/app/views/fe/answer_sheets/index.html.erb +1 -1
- data/app/views/fe/answer_sheets/show.html.erb +1 -1
- data/app/views/fe/applications/_logout.html.erb +1 -1
- data/app/views/fe/questions/fe/_acceptance.html.erb +10 -9
- data/app/views/fe/questions/fe/_attachment_field.html.erb +129 -10
- data/app/views/fe/questions/fe/_checkbox_field.html.erb +18 -16
- data/app/views/fe/questions/fe/_country.html.erb +6 -6
- data/app/views/fe/questions/fe/_date_field.html.erb +5 -4
- data/app/views/fe/questions/fe/_date_field_mmyy.html.erb +8 -8
- data/app/views/fe/questions/fe/_drop_down_field.html.erb +5 -5
- data/app/views/fe/questions/fe/_question_grid.html.erb +10 -10
- data/app/views/fe/questions/fe/_question_grid_with_total.html.erb +8 -8
- data/app/views/fe/questions/fe/_questions.html.erb +11 -5
- data/app/views/fe/questions/fe/_radio_button_field.html.erb +35 -19
- data/app/views/fe/questions/fe/_rating.html.erb +56 -18
- data/app/views/fe/questions/fe/_reference_discipler.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_friend.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_parent.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_peer.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_question.html.erb +40 -24
- data/app/views/fe/questions/fe/_reference_roommate.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_spiritual.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_staff.html.erb +1 -1
- data/app/views/fe/questions/fe/_state_chooser.html.erb +6 -6
- data/app/views/fe/questions/fe/_text_area_field.html.erb +14 -10
- data/app/views/fe/questions/fe/_text_field.html.erb +7 -6
- data/app/views/fe/questions/fe/_yes_no.html.erb +8 -8
- data/app/views/fe/questions/fe/_yes_no_field.erb +11 -8
- data/app/views/fe/reference_pages/_reference.html.erb +12 -12
- data/app/views/fe/reference_pages/edit.html.erb +4 -4
- data/app/views/fe/reference_sheets/done.html.erb +2 -2
- data/app/views/fe/reference_sheets/not_found.html.erb +3 -3
- data/app/views/fe/references/edit.html.erb +5 -5
- data/app/views/fe/references/show.html.erb +3 -3
- data/app/views/fe/references/submit.js.erb +3 -3
- data/app/views/fe/submit_pages/_thankyou.html.erb +1 -1
- data/app/views/fe/submit_pages/edit.html.erb +9 -9
- data/app/views/fe/submit_pages/error.js.erb +1 -1
- data/app/views/fe/submit_pages/submit.js.erb +2 -2
- data/app/views/layouts/fe/_error_messages_for.html.erb +1 -1
- data/app/views/layouts/fe/application.html.erb +3 -4
- data/app/views/layouts/fe/fe_admin.html.erb +30 -0
- data/app/views.current/fe/admin/elements/_errors.html.erb +11 -0
- data/app/views.current/fe/admin/elements/create.js.erb +12 -0
- data/app/views.current/fe/admin/elements/destroy.js.erb +4 -0
- data/app/views.current/fe/admin/elements/drop.js.erb +3 -0
- data/app/views.current/fe/admin/elements/duplicate.js.erb +3 -0
- data/app/views.current/fe/admin/elements/edit.js.erb +4 -0
- data/app/views.current/fe/admin/elements/error.js.erb +4 -0
- data/app/views.current/fe/admin/elements/new.js.erb +17 -0
- data/app/views.current/fe/admin/elements/update.js.erb +9 -0
- data/app/views.current/fe/admin/email_templates/_form.html.erb +8 -0
- data/app/views.current/fe/admin/email_templates/edit.html.erb +13 -0
- data/app/views.current/fe/admin/email_templates/index.html.erb +20 -0
- data/app/views.current/fe/admin/email_templates/new.html.erb +11 -0
- data/app/views.current/fe/admin/panels/_advanced_options.html.erb +49 -0
- data/app/views.current/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
- data/app/views.current/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
- data/app/views.current/fe/admin/panels/_common_fields.html.erb +23 -0
- data/app/views.current/fe/admin/panels/_condition.html.erb +6 -0
- data/app/views.current/fe/admin/panels/_insert.html.erb +39 -0
- data/app/views.current/fe/admin/panels/_nav_controls.html.erb +6 -0
- data/app/views.current/fe/admin/panels/_page.html.erb +3 -0
- data/app/views.current/fe/admin/panels/_pages_list.html.erb +16 -0
- data/app/views.current/fe/admin/panels/_prop_attachment_field.html.erb +2 -0
- data/app/views.current/fe/admin/panels/_prop_choice_field.html.erb +74 -0
- data/app/views.current/fe/admin/panels/_prop_date_field.html.erb +7 -0
- data/app/views.current/fe/admin/panels/_prop_element.html.erb +23 -0
- data/app/views.current/fe/admin/panels/_prop_page.html.erb +26 -0
- data/app/views.current/fe/admin/panels/_prop_paragraph.html.erb +46 -0
- data/app/views.current/fe/admin/panels/_prop_question_grid.html.erb +28 -0
- data/app/views.current/fe/admin/panels/_prop_question_grid_with_total.html.erb +14 -0
- data/app/views.current/fe/admin/panels/_prop_reference_question.html.erb +12 -0
- data/app/views.current/fe/admin/panels/_prop_section.html.erb +8 -0
- data/app/views.current/fe/admin/panels/_prop_sheet.html.erb +20 -0
- data/app/views.current/fe/admin/panels/_prop_text_field.html.erb +20 -0
- data/app/views.current/fe/admin/question_pages/_element.html.erb +28 -0
- data/app/views.current/fe/admin/question_pages/_element_show.html.erb +10 -0
- data/app/views.current/fe/admin/question_pages/_errors.html.erb +10 -0
- data/app/views.current/fe/admin/question_pages/_question_page.html.erb +13 -0
- data/app/views.current/fe/admin/question_pages/create.js.erb +11 -0
- data/app/views.current/fe/admin/question_pages/destroy.js.erb +5 -0
- data/app/views.current/fe/admin/question_pages/edit.js.erb +3 -0
- data/app/views.current/fe/admin/question_pages/error.js.erb +4 -0
- data/app/views.current/fe/admin/question_pages/show.js.erb +9 -0
- data/app/views.current/fe/admin/question_pages/show_panel.js.erb +3 -0
- data/app/views.current/fe/admin/question_pages/update.js.erb +2 -0
- data/app/views.current/fe/admin/question_sheets/_errors.html.erb +11 -0
- data/app/views.current/fe/admin/question_sheets/edit.js.erb +3 -0
- data/app/views.current/fe/admin/question_sheets/error.js.erb +5 -0
- data/app/views.current/fe/admin/question_sheets/index.html.erb +41 -0
- data/app/views.current/fe/admin/question_sheets/new.html.erb +15 -0
- data/app/views.current/fe/admin/question_sheets/show.html.erb +27 -0
- data/app/views.current/fe/admin/question_sheets/update.js.erb +2 -0
- data/app/views.current/fe/answer_pages/_answer_page.html.erb +53 -0
- data/app/views.current/fe/answer_pages/_element.html.erb +32 -0
- data/app/views.current/fe/answer_pages/_page_name.html.erb +1 -0
- data/app/views.current/fe/answer_pages/show.html.erb +39 -0
- data/app/views.current/fe/answer_pages/update.js.erb +13 -0
- data/app/views.current/fe/answer_sheets/_answer_sheet.html.erb +26 -0
- data/app/views.current/fe/answer_sheets/_element.html.erb +74 -0
- data/app/views.current/fe/answer_sheets/_incomplete.html.erb +10 -0
- data/app/views.current/fe/answer_sheets/_page_link.html.erb +9 -0
- data/app/views.current/fe/answer_sheets/_pages_list.html.erb +11 -0
- data/app/views.current/fe/answer_sheets/_submit_to.html.erb +1 -0
- data/app/views.current/fe/answer_sheets/_title.html.erb +1 -0
- data/app/views.current/fe/answer_sheets/edit.html.erb +66 -0
- data/app/views.current/fe/answer_sheets/incomplete.js.erb +11 -0
- data/app/views.current/fe/answer_sheets/index.html.erb +18 -0
- data/app/views.current/fe/answer_sheets/send_reference_invite.js.erb +8 -0
- data/app/views.current/fe/answer_sheets/show.html.erb +13 -0
- data/app/views.current/fe/applications/_logout.html.erb +1 -0
- data/app/views.current/fe/applications/show.html.erb +1 -0
- data/app/views.current/fe/help/builder.html +33 -0
- data/app/views.current/fe/help/question_grid.html +18 -0
- data/app/views.current/fe/questions/fe/_acceptance.html.erb +14 -0
- data/app/views.current/fe/questions/fe/_attachment_field.html.erb +165 -0
- data/app/views.current/fe/questions/fe/_checkbox_field.html.erb +53 -0
- data/app/views.current/fe/questions/fe/_country.html.erb +7 -0
- data/app/views.current/fe/questions/fe/_date_field.html.erb +7 -0
- data/app/views.current/fe/questions/fe/_date_field_mmyy.html.erb +9 -0
- data/app/views.current/fe/questions/fe/_drop_down_field.html.erb +8 -0
- data/app/views.current/fe/questions/fe/_paragraph.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_question_grid.html.erb +70 -0
- data/app/views.current/fe/questions/fe/_question_grid_with_total.html.erb +64 -0
- data/app/views.current/fe/questions/fe/_questions.html.erb +15 -0
- data/app/views.current/fe/questions/fe/_radio_button_field.html.erb +60 -0
- data/app/views.current/fe/questions/fe/_rating.html.erb +64 -0
- data/app/views.current/fe/questions/fe/_reference_discipler.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_friend.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_parent.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_peer.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_question.html.erb +61 -0
- data/app/views.current/fe/questions/fe/_reference_roommate.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_spiritual.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_staff.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_section.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_state_chooser.html.erb +7 -0
- data/app/views.current/fe/questions/fe/_text_area_field.html.erb +17 -0
- data/app/views.current/fe/questions/fe/_text_field.html.erb +9 -0
- data/app/views.current/fe/questions/fe/_yes_no.html.erb +17 -0
- data/app/views.current/fe/questions/fe/_yes_no_field.erb +20 -0
- data/app/views.current/fe/reference_pages/_reference.html.erb +31 -0
- data/app/views.current/fe/reference_pages/edit.html.erb +24 -0
- data/app/views.current/fe/reference_sheets/done.html.erb +2 -0
- data/app/views.current/fe/reference_sheets/not_found.html.erb +5 -0
- data/app/views.current/fe/reference_sheets/submitted.js.erb +1 -0
- data/app/views.current/fe/references/edit.html.erb +8 -0
- data/app/views.current/fe/references/send_invite.js.erb +7 -0
- data/app/views.current/fe/references/show.html.erb +18 -0
- data/app/views.current/fe/references/submit.js.erb +3 -0
- data/app/views.current/fe/submit_pages/_errors.html.erb +1 -0
- data/app/views.current/fe/submit_pages/_thankyou.html.erb +2 -0
- data/app/views.current/fe/submit_pages/edit.html.erb +36 -0
- data/app/views.current/fe/submit_pages/error.js.erb +1 -0
- data/app/views.current/fe/submit_pages/submit.js.erb +3 -0
- data/app/views.current/layouts/fe/_error_messages_for.html.erb +7 -0
- data/app/views.current/layouts/fe/application.html.erb +47 -0
- data/app/{views/layouts/fe/fe.admin.html.erb → views.current/layouts/fe/fe_admin.html.erb} +4 -4
- data/config/initializers/paper_trail.rb +3 -0
- data/config/routes.rb +3 -1
- data/db/migrate/20131003041856_core.rb +23 -23
- data/db/migrate/20131003044250_create_reference_sheets.rb +1 -1
- data/db/migrate/20131003044436_add_element_and_answer_fields.rb +3 -3
- data/db/migrate/20131003044518_create_email_templates.rb +2 -2
- data/db/migrate/20131003044621_add_max_lengths.rb +1 -1
- data/db/migrate/20131003044714_create_join_table.rb +1 -1
- data/db/migrate/20131016162128_remove_question_id_from_element.rb +1 -1
- data/db/migrate/20140623153424_create_fe_people.rb +1 -1
- data/db/migrate/20140624180246_create_fe_addresses.rb +1 -1
- data/db/migrate/20140624182216_create_fe_phone_numbers.rb +1 -1
- data/db/migrate/20140625160545_create_fe_users.rb +1 -1
- data/db/migrate/20140808202507_add_conditional_type_to_elements.rb +1 -1
- data/db/migrate/20140808203609_add_conditional_answer_to_elements.rb +1 -1
- data/db/migrate/20141103204704_remove_short_value_column.rb +1 -1
- data/db/migrate/20141109154522_move_conditional_ids_used_for_choice_field_to_their_own_column.rb +1 -1
- data/db/migrate/20150504221439_add_all_element_ids_to_pages.rb +1 -1
- data/db/migrate/20150713022326_add_locale_columns.rb +1 -1
- data/db/migrate/20150714220730_add_locale_to_answer_sheet.rb +1 -1
- data/db/migrate/20150925181652_add_share_to_elements.rb +5 -0
- data/db/migrate/20150928085325_change_pages_all_element_ids_to_text.rb +1 -1
- data/db/migrate/20150930191538_add_locale_to_reference_sheets.rb +1 -1
- data/db/migrate/20151021181928_switch_conditional_answer_separator_to_semicolon.rb +7 -0
- data/db/migrate/20151021184250_add_question_sheet_id_in_refs.rb +12 -0
- data/db/migrate/20160201185838_add_visible_and_visibility_cache_key_to_reference_sheets.rb +6 -0
- data/db/migrate/20160805221415_add_rating_extra_labels.rb +10 -0
- data/db/migrate/20181108201746_create_versions.rb +80 -0
- data/db/migrate/20181218201130_increase_slug_length.rb +5 -0
- data/lib/fe/engine.rb +10 -10
- data/lib/fe/version.rb +1 -1
- data/lib/fe.rb +7 -1
- data/spec/controllers/fe/admin/elements_controller_spec.rb +30 -20
- data/spec/controllers/fe/admin/email_templates_controller_spec.rb +2 -2
- data/spec/controllers/fe/admin/question_pages_controller_spec.rb +1 -1
- data/spec/controllers/fe/admin/question_sheets_controller_spec.rb +4 -4
- data/spec/controllers/fe/answer_pages_controller_spec.rb +86 -30
- data/spec/controllers/fe/answer_sheets_controller_spec.rb +65 -9
- data/spec/dummy/app/assets/config/manifest.js +0 -0
- data/spec/dummy/app/models/user.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/config/application.rb +1 -0
- data/spec/dummy/config/environments/test.rb +3 -3
- data/spec/dummy/config/initializers/assets.rb +5 -2
- data/spec/dummy/config/initializers/fast_gettext.rb +1 -1
- data/spec/dummy/config/initializers/to_unsafe_h.rb +5 -0
- data/spec/dummy/config/initializers/to_unsafe_h.rb.new +5 -0
- data/spec/dummy/db/migrate/20141203214017_core.fe_engine.rb +23 -23
- data/spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb +3 -3
- data/spec/dummy/db/migrate/20141203214020_create_email_templates.fe_engine.rb +2 -2
- data/spec/dummy/db/migrate/20141203214021_add_max_lengths.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141203214022_create_join_table.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141203214023_remove_question_id_from_element.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141203214024_create_fe_people.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141203214025_create_fe_addresses.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141203214027_create_fe_users.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141203214028_add_conditional_type_to_elements.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141203214029_add_conditional_answer_to_elements.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141203214030_remove_short_value_column.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141203214031_move_conditional_ids_used_for_choice_field_to_their_own_column.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20150123215803_create_users.rb +1 -1
- data/spec/dummy/db/migrate/20150504222619_add_all_element_ids_to_pages.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20150925192557_add_share_to_elements.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150930190001_create_fe_phone_numbers.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20150930190002_add_locale_columns.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20150930190003_add_locale_to_answer_sheet.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20150930190004_change_pages_all_element_ids_to_text.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20150930191756_add_locale_to_reference_sheets.fe_engine.rb +1 -1
- data/spec/dummy/db/migrate/20151021190027_add_question_sheet_id_in_refs.fe_engine.rb +13 -0
- data/spec/dummy/db/migrate/20160204164612_switch_conditional_answer_separator_to_semicolon.fe_engine.rb +8 -0
- data/spec/dummy/db/migrate/20160204164613_add_visible_and_visibility_cache_key_to_reference_sheets.fe_engine.rb +7 -0
- data/spec/dummy/db/migrate/20181108201746_create_versions.rb +80 -0
- data/spec/dummy/db/schema.rb +71 -79
- data/spec/dummy/log/test.log +101278 -419
- data/spec/factories/answer_sheet_question_sheets.rb +1 -1
- data/spec/factories/answer_sheets.rb +2 -2
- data/spec/factories/answers.rb +1 -1
- data/spec/factories/applications.rb +3 -3
- data/spec/factories/dummy_applications.rb +3 -3
- data/spec/factories/dummy_people.rb +3 -3
- data/spec/factories/dummy_users.rb +3 -3
- data/spec/factories/elements.rb +21 -21
- data/spec/factories/email_templates.rb +3 -3
- data/spec/factories/fe_addresses.rb +10 -10
- data/spec/factories/fe_email_addresses.rb +3 -3
- data/spec/factories/fe_email_templates.rb +4 -4
- data/spec/factories/fe_people.rb +5 -5
- data/spec/factories/fe_phone_numbers.rb +3 -3
- data/spec/factories/fe_user.rb +3 -3
- data/spec/factories/page.rb +1 -1
- data/spec/factories/page_elements.rb +1 -1
- data/spec/factories/paragraphs.rb +1 -1
- data/spec/factories/question_sheet.rb +2 -2
- data/spec/factories/reference_questions.rb +1 -1
- data/spec/factories/reference_sheets.rb +1 -1
- data/spec/jobs/fe/update_reference_sheet_visibility_job_spec.rb +40 -0
- data/spec/models/fe/answer_sheet_question_sheet_spec.rb +1 -1
- data/spec/models/fe/answer_spec.rb +2 -2
- data/spec/models/fe/application_spec.rb +94 -1
- data/spec/models/fe/choice_field_spec.rb +47 -1
- data/spec/models/fe/condition_spec.rb +2 -2
- data/spec/models/fe/element_spec.rb +252 -60
- data/spec/models/fe/email_template_spec.rb +1 -1
- data/spec/models/fe/page_element_spec.rb +1 -1
- data/spec/models/fe/page_spec.rb +57 -12
- data/spec/models/fe/person_spec.rb +1 -1
- data/spec/models/fe/question_set_spec.rb +91 -0
- data/spec/models/fe/question_sheet_spec.rb +11 -15
- data/spec/models/fe/question_spec.rb +73 -6
- data/spec/models/fe/reference_question_spec.rb +20 -0
- data/spec/models/fe/reference_sheet_spec.rb +287 -4
- data/spec/models/fe/text_field_spec.rb +22 -0
- data/spec/rails_helper.rb +79 -76
- metadata +195 -57
- data/app/assets/javascripts/fe/jquery.scrollTo-min.js +0 -7
- data/app/controllers/fe/concerns/answer_pages_controller_concern.rb +0 -84
- data/app/models/fe/concerns/answer_sheet_concern.rb +0 -85
- data/spec/dummy/db/migrate/20141203214026_create_create_fe_phone_numbers.fe_engine.rb +0 -17
- data/spec/dummy/log/development.log +0 -5
- /data/app/{assets/stylesheets/360front.css → views.current/fe/admin/elements/reorder.js.erb} +0 -0
@@ -1,4 +1,95 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe Fe::QuestionSet do
|
4
|
+
let(:app) { create(:application) }
|
5
|
+
let(:app2) { create(:application) }
|
6
|
+
|
7
|
+
before do
|
8
|
+
@page = create(:page)
|
9
|
+
@el_confidential = create(:text_field_element, label: 'conf1', is_confidential: true, share: true)
|
10
|
+
@el_visible = create(:text_field_element, label: 'vis1', is_confidential: false, share: false)
|
11
|
+
@el_confidential2 = create(:text_field_element, label: 'conf2', is_confidential: true, share: true)
|
12
|
+
@el_visible2 = create(:text_field_element, label: 'vis2', is_confidential: false, share: true)
|
13
|
+
@page.elements << @el_confidential << @el_visible << @el_confidential2 << @el_visible2
|
14
|
+
@question_set = Fe::QuestionSet.new(@page.elements, app)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should filter default show' do
|
18
|
+
# filter out confidential questions and questions with share flag (the share flag would likely
|
19
|
+
# never be used to filter, but just to test that it will only filter those that match all the
|
20
|
+
# filter methods)
|
21
|
+
@question_set.set_filter(filter_default: :show, filter: [ :is_confidential, :share ])
|
22
|
+
expect(@question_set.elements).to eq([@el_visible, @el_visible2])
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should filter default hide' do
|
26
|
+
# show only confidential questions and questions with share flag (the share flag would likely
|
27
|
+
# never be used to filter, but just to test that it will only filter those that match all the
|
28
|
+
# filter methods)
|
29
|
+
@question_set.set_filter(filter_default: :hide, filter: [ :is_confidential, :share ])
|
30
|
+
expect(@question_set.elements).to eq([@el_confidential, @el_confidential2])
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'saving answers (#post then #save)' do
|
34
|
+
it 'saves a new value' do
|
35
|
+
@question_set.post({ @el_visible.id => 'a text response' }, app)
|
36
|
+
@question_set.save
|
37
|
+
expect(Fe::Answer.count).to eq(1)
|
38
|
+
expect(Fe::Answer.first.value).to eq('a text response')
|
39
|
+
expect(Fe::Answer.first.answer_sheet_id).to eq(app.id)
|
40
|
+
expect(Fe::Answer.first.question_id).to eq(@el_visible.id)
|
41
|
+
end
|
42
|
+
it 'replaces an existing answer' do
|
43
|
+
create(:answer, value: 'a text response', answer_sheet: app, question: @el_visible)
|
44
|
+
@question_set = Fe::QuestionSet.new(@page.elements, app) # need this to reload the elements in the question set to get the new answer
|
45
|
+
@question_set.post({ @el_visible.id => 'an updated response' }, app)
|
46
|
+
@question_set.save
|
47
|
+
expect(Fe::Answer.count).to eq(1)
|
48
|
+
expect(Fe::Answer.first.value).to eq('an updated response')
|
49
|
+
expect(Fe::Answer.first.answer_sheet_id).to eq(app.id)
|
50
|
+
expect(Fe::Answer.first.question_id).to eq(@el_visible.id)
|
51
|
+
end
|
52
|
+
it "doesn't save empty strings continually" do
|
53
|
+
create(:answer, value: '', answer_sheet: app, question: @el_visible)
|
54
|
+
@question_set = Fe::QuestionSet.new(@page.elements, app) # need this to reload the elements in the question set to get the new answer
|
55
|
+
@question_set.post({ @el_visible.id => '' }, app)
|
56
|
+
@question_set.save
|
57
|
+
expect(Fe::Answer.count).to eq(1)
|
58
|
+
expect(Fe::Answer.first.value).to eq('')
|
59
|
+
expect(Fe::Answer.first.answer_sheet_id).to eq(app.id)
|
60
|
+
expect(Fe::Answer.first.question_id).to eq(@el_visible.id)
|
61
|
+
end
|
62
|
+
it 'saves multiple values' do
|
63
|
+
@el_visible.update(kind: 'Fe::ChoiceField', style: 'checkbox', content: "choice 1\nchoice 2")
|
64
|
+
create(:answer, value: 'choice 1', answer_sheet: app, question: @el_visible)
|
65
|
+
@question_set = Fe::QuestionSet.new(@page.elements, app) # need this to reload the elements in the question set to get the new answer
|
66
|
+
@question_set.post({ @el_visible.id => { '0' => 'choice 1', '1' => 'choice 2' } }, app)
|
67
|
+
@question_set.save
|
68
|
+
expect(Fe::Answer.count).to eq(2)
|
69
|
+
expect(Fe::Answer.first.value).to eq('choice 1')
|
70
|
+
expect(Fe::Answer.first.answer_sheet_id).to eq(app.id)
|
71
|
+
expect(Fe::Answer.first.question_id).to eq(@el_visible.id)
|
72
|
+
expect(Fe::Answer.second.value).to eq('choice 2')
|
73
|
+
expect(Fe::Answer.second.answer_sheet_id).to eq(app.id)
|
74
|
+
expect(Fe::Answer.second.question_id).to eq(@el_visible.id)
|
75
|
+
end
|
76
|
+
it 'saves the same value for different answer sheets' do
|
77
|
+
@el_visible.update(kind: 'Fe::ChoiceField', style: 'checkbox', content: "choice 1\nchoice 2")
|
78
|
+
@question_set = Fe::QuestionSet.new(@page.elements, app) # need this to reload the elements in the question set to get the new answer
|
79
|
+
@question_set.post({ @el_visible.id => { '0' => 'choice 1' } }, app)
|
80
|
+
@question_set.save
|
81
|
+
@question_set = Fe::QuestionSet.new(@page.elements, app2) # need this to save answers to app2
|
82
|
+
$b = true
|
83
|
+
@question_set.post({ @el_visible.id => { '0' => 'choice 1' } }, app2)
|
84
|
+
@question_set.save
|
85
|
+
$b = false
|
86
|
+
expect(Fe::Answer.count).to eq(2)
|
87
|
+
expect(Fe::Answer.first.value).to eq('choice 1')
|
88
|
+
expect(Fe::Answer.first.answer_sheet_id).to eq(app.id)
|
89
|
+
expect(Fe::Answer.first.question_id).to eq(@el_visible.id)
|
90
|
+
expect(Fe::Answer.second.value).to eq('choice 1')
|
91
|
+
expect(Fe::Answer.second.answer_sheet_id).to eq(app2.id)
|
92
|
+
expect(Fe::Answer.second.question_id).to eq(@el_visible.id)
|
93
|
+
end
|
94
|
+
end
|
4
95
|
end
|
@@ -1,24 +1,11 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe Fe::QuestionSheet do
|
3
|
+
describe Fe::QuestionSheet, type: :model do
|
4
4
|
it { expect have_many :pages }
|
5
5
|
it { expect have_many :answer_sheets }
|
6
6
|
it { expect validate_presence_of :label }
|
7
7
|
it { expect validate_uniqueness_of :label }
|
8
8
|
|
9
|
-
context '#questions_count' do
|
10
|
-
it 'should count elements in a grid' do
|
11
|
-
s = create(:question_sheet)
|
12
|
-
p = create(:page, question_sheet: s)
|
13
|
-
e = create(:question_grid)
|
14
|
-
create(:page_element, page: p, element: e)
|
15
|
-
create(:text_field_element, question_grid: e)
|
16
|
-
create(:section, question_grid: e) # this shouldn't get counted
|
17
|
-
p.reload # get the updated all_element_ids column
|
18
|
-
expect(s.questions_count).to eq(1)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
9
|
context '#all_elements' do
|
23
10
|
it 'should return elements in the same order as the ids' do
|
24
11
|
s = create(:question_sheet)
|
@@ -92,9 +79,18 @@ describe Fe::QuestionSheet do
|
|
92
79
|
it 'should handle pages with no elements' do
|
93
80
|
qs = create(:question_sheet)
|
94
81
|
p = create(:page)
|
95
|
-
qs.pages
|
82
|
+
qs.pages << p
|
96
83
|
expect(qs.all_elements).to eq([])
|
97
84
|
end
|
85
|
+
it 'should handle pages with no elements with empty string for all_elements' do
|
86
|
+
qs = create(:question_sheet)
|
87
|
+
p = create(:page, all_element_ids: '')
|
88
|
+
p2 = create(:page, all_element_ids: '')
|
89
|
+
e = create(:text_field_element)
|
90
|
+
create(:page_element, page: p2, element: e)
|
91
|
+
qs.pages << p << p2
|
92
|
+
expect(qs.all_elements).to eq([e])
|
93
|
+
end
|
98
94
|
end
|
99
95
|
|
100
96
|
context '#elements' do
|
@@ -1,21 +1,88 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe Fe::Question do
|
3
|
+
describe Fe::Question, type: :model do
|
4
4
|
it { expect have_many :conditions }
|
5
5
|
it { expect have_many :dependents }
|
6
6
|
it { expect have_many :sheet_answers }
|
7
7
|
it { expect belong_to :related_question_sheet }
|
8
|
-
|
8
|
+
|
9
9
|
# it { expect validate_format_of :slug }
|
10
10
|
# it { expect validate_length_of :slug }
|
11
11
|
# it { expect validate_uniqueness_of :slug }
|
12
|
-
|
13
|
-
describe '#default_label?' do
|
14
|
-
it 'expect return true' do
|
12
|
+
|
13
|
+
describe '#default_label?' do
|
14
|
+
it 'expect return true' do
|
15
15
|
question = Fe::Question.new
|
16
16
|
#question.default_label?.expect be_true
|
17
17
|
expect(question.default_label?).to eq(true)
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
|
+
context 'slug' do
|
22
|
+
let(:qs) { create(:question_sheet_with_pages) }
|
23
|
+
let(:page) { qs.pages.first }
|
24
|
+
let(:qs2) { create(:question_sheet_with_pages) }
|
25
|
+
let(:page2) { qs2.pages.first }
|
26
|
+
let(:e1) { create(:text_field_element, slug: 'test') }
|
27
|
+
let(:e2) { create(:text_field_element) }
|
28
|
+
|
29
|
+
before do
|
30
|
+
e1.pages << page
|
31
|
+
end
|
32
|
+
|
33
|
+
it "doesn't let the same slug be used in the question sheet" do
|
34
|
+
e2.pages << page
|
35
|
+
e2.slug = 'test'
|
36
|
+
e2.save
|
37
|
+
expect(e2.errors.full_messages.join(', ')).to include('Slug must be unique (within the question sheet)')
|
38
|
+
end
|
39
|
+
it "lets two elements with the same slug save on different sheets" do
|
40
|
+
e2.pages << page2
|
41
|
+
e2.slug = 'test'
|
42
|
+
expect(e2.save).to be true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'saving' do
|
47
|
+
let(:e) { create(:text_field_element) }
|
48
|
+
let(:app) { create(:text_field_element) }
|
49
|
+
let(:app2) { create(:text_field_element) }
|
50
|
+
|
51
|
+
before do
|
52
|
+
e.set_response('answer value', app)
|
53
|
+
end
|
54
|
+
|
55
|
+
context '#save_file' do
|
56
|
+
it ' checks that the answer sheet that calls set_response is the same one that calls save' do
|
57
|
+
expect {
|
58
|
+
e.save_file(app2, nil)
|
59
|
+
}.to raise_error(RuntimeError, "Trying to save answers to a different answer sheet than the one given in set_response")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context '#delete_file' do
|
64
|
+
it ' checks that the answer sheet that calls set_response is the same one that calls delete' do
|
65
|
+
expect {
|
66
|
+
e.delete_file(app2, nil)
|
67
|
+
}.to raise_error(RuntimeError, "Trying to save answers to a different answer sheet than the one given in set_response")
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'deletes the given answer record' do
|
71
|
+
answer_sheet = create(:answer_sheet)
|
72
|
+
question = create(:attachment_field_element)
|
73
|
+
answer = create(:answer, attachment_file_name: 'test_file', answer_sheet: answer_sheet, question: question)
|
74
|
+
question.set_response('', answer_sheet)
|
75
|
+
question.delete_file(answer_sheet, answer)
|
76
|
+
expect{answer.reload}.to raise_error(ActiveRecord::RecordNotFound)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context '#save_response' do
|
81
|
+
it ' checks that the answer sheet that calls set_response is the same one that calls save' do
|
82
|
+
expect {
|
83
|
+
e.save_response(app2)
|
84
|
+
}.to raise_error(RuntimeError, "Trying to save answers to a different answer sheet than the one given in set_response")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
21
88
|
end
|
@@ -14,4 +14,24 @@ describe Fe::ReferenceQuestion do
|
|
14
14
|
expect(ref.ptemplate).to eq("fe/reference_abc")
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
it 'resets the question_sheet_id for references not created' do
|
19
|
+
qs1 = create(:question_sheet)
|
20
|
+
reference_question = create(:reference_question, related_question_sheet_id: qs1.id)
|
21
|
+
reference_sheet = create(:reference_sheet, question: reference_question)
|
22
|
+
expect(reference_sheet.question_sheet_id).to eq(qs1.id)
|
23
|
+
|
24
|
+
# change question sheet on ref element, the reference_sheet's question sheet should change
|
25
|
+
qs2 = create(:question_sheet)
|
26
|
+
expect(reference_sheet.status).to eq('created')
|
27
|
+
reference_question.update_attribute(:related_question_sheet_id, qs2.id)
|
28
|
+
expect(reference_sheet.reload.question_sheet_id).to eq(qs2.id)
|
29
|
+
|
30
|
+
# start the reference, then change question sheet on ref element,
|
31
|
+
# the reference_sheet's question sheet should not change
|
32
|
+
reference_sheet.update_attribute(:status, 'started')
|
33
|
+
qs3 = create(:question_sheet)
|
34
|
+
reference_question.update_attribute(:related_question_sheet_id, qs3.id)
|
35
|
+
expect(reference_sheet.reload.question_sheet_id).to eq(qs2.id)
|
36
|
+
end
|
17
37
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe Fe::ReferenceSheet do
|
4
|
-
it { expect belong_to :question }
|
3
|
+
describe Fe::ReferenceSheet, type: :model do
|
4
|
+
it { expect belong_to :question }
|
5
5
|
it { expect belong_to :applicant_answer_sheet }
|
6
6
|
# it { expect validate_presence_of :first_name } # need to add started_at column
|
7
7
|
# it { expect validate_presence_of :last_name } # need to add started_at column
|
8
8
|
# it { expect validate_presence_of :phone } # need to add started_at column
|
9
9
|
# it { expect validate_presence_of :email } # need to add started_at column
|
10
10
|
# it { expect validate_presence_of :relationship } # need to add started_at column
|
11
|
-
|
11
|
+
|
12
12
|
context '#access_key' do
|
13
13
|
it 'should generate two different in the same second' do
|
14
14
|
# there's a small chance the first and second access keys generated will be in different seconds
|
@@ -27,5 +27,288 @@ describe Fe::ReferenceSheet do
|
|
27
27
|
a = create(:answer_sheet, applicant_id: p.id)
|
28
28
|
r = create(:reference_sheet, applicant_answer_sheet: a)
|
29
29
|
expect(r.applicant).to eq(a.applicant)
|
30
|
-
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns the user for applicant' do
|
33
|
+
p = create(:fe_person)
|
34
|
+
a = create(:answer_sheet, applicant_id: p.id)
|
35
|
+
r = create(:reference_sheet, applicant_answer_sheet: a)
|
36
|
+
expect(r.applicant).to eq(a.applicant)
|
37
|
+
end
|
38
|
+
|
39
|
+
context '#required?' do
|
40
|
+
it 'should return the opposite of required? when optional? is false' do
|
41
|
+
question_sheet = FactoryBot.create(:question_sheet_with_pages)
|
42
|
+
application = FactoryBot.create(:answer_sheet)
|
43
|
+
application.question_sheets << question_sheet
|
44
|
+
element = FactoryBot.create(:reference_element, label: "Reference question here", required: true)
|
45
|
+
question_sheet.pages.first.elements << element
|
46
|
+
reference = FactoryBot.create(:reference_sheet, applicant_answer_sheet: application, question: element)
|
47
|
+
allow(reference).to receive(:optional?).and_return(false)
|
48
|
+
expect(reference.optional?).to be false
|
49
|
+
expect(reference.required?).to be true
|
50
|
+
end
|
51
|
+
it 'should return the opposite of required? when optional? is true' do
|
52
|
+
question_sheet = FactoryBot.create(:question_sheet_with_pages)
|
53
|
+
application = FactoryBot.create(:answer_sheet)
|
54
|
+
application.question_sheets << question_sheet
|
55
|
+
element = FactoryBot.create(:reference_element, label: "Reference question here", required: true)
|
56
|
+
question_sheet.pages.first.elements << element
|
57
|
+
reference = FactoryBot.create(:reference_sheet, applicant_answer_sheet: application, question: element)
|
58
|
+
allow(reference).to receive(:optional?).and_return(true)
|
59
|
+
expect(reference.optional?).to be true
|
60
|
+
expect(reference.required?).to be false
|
61
|
+
end
|
62
|
+
it 'should return false when the element is not required' do
|
63
|
+
question_sheet = FactoryBot.create(:question_sheet_with_pages)
|
64
|
+
application = FactoryBot.create(:answer_sheet)
|
65
|
+
application.question_sheets << question_sheet
|
66
|
+
element = FactoryBot.create(:reference_element, label: "Reference question here", required: false)
|
67
|
+
reference = FactoryBot.create(:reference_sheet, applicant_answer_sheet: application, question: element)
|
68
|
+
expect(reference.required?).to be false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context '#optional?' do
|
73
|
+
it 'returns true when the ref question element is hidden from a yes/no choice_field' do
|
74
|
+
question_sheet = FactoryBot.create(:question_sheet_with_pages)
|
75
|
+
choice_field = FactoryBot.create(:choice_field_element, label: "Is the reference required?")
|
76
|
+
question_sheet.pages.reload
|
77
|
+
question_sheet.pages[3].elements << choice_field
|
78
|
+
element = FactoryBot.create(:reference_element, label: "Reference question here", choice_field_id: choice_field.id, required: true)
|
79
|
+
question_sheet.pages[3].elements << element
|
80
|
+
|
81
|
+
application = FactoryBot.create(:answer_sheet)
|
82
|
+
application.question_sheets << question_sheet
|
83
|
+
reference = FactoryBot.create(:reference_sheet, applicant_answer_sheet: application, question: element)
|
84
|
+
|
85
|
+
# make the answer to the conditional question 'no' so that the ref is not required (optional true)
|
86
|
+
choice_field.set_response("no", application)
|
87
|
+
choice_field.save_response(application)
|
88
|
+
|
89
|
+
expect(reference.optional?).to be true
|
90
|
+
end
|
91
|
+
it 'returns false when the ref question element is visible from a yes/no choice_field' do
|
92
|
+
question_sheet = FactoryBot.create(:question_sheet_with_pages)
|
93
|
+
choice_field = FactoryBot.create(:choice_field_element, label: "Is the reference required?")
|
94
|
+
question_sheet.pages.reload
|
95
|
+
question_sheet.pages[3].elements << choice_field
|
96
|
+
element = FactoryBot.create(:reference_element, label: "Reference question here", choice_field_id: choice_field.id, required: true)
|
97
|
+
question_sheet.pages[3].elements << element
|
98
|
+
|
99
|
+
question_sheet.pages[3].elements << choice_field
|
100
|
+
application = FactoryBot.create(:answer_sheet)
|
101
|
+
application.question_sheets << question_sheet
|
102
|
+
reference = FactoryBot.create(:reference_sheet, applicant_answer_sheet: application, question: element)
|
103
|
+
|
104
|
+
# make the answer to the conditional question 'yes' so that the ref is required (optional false)
|
105
|
+
choice_field.set_response("yes", application)
|
106
|
+
choice_field.save_response(application)
|
107
|
+
|
108
|
+
expect(reference.optional?).to be false
|
109
|
+
end
|
110
|
+
it 'returns false when the ref question element is hidden from a conditional element' do
|
111
|
+
question_sheet = FactoryBot.create(:question_sheet_with_pages)
|
112
|
+
choice_field = FactoryBot.create(:choice_field_element, label: "Is the reference required?", conditional_type: "Fe::Element", conditional_answer: "yes")
|
113
|
+
question_sheet.pages.reload
|
114
|
+
question_sheet.pages[3].elements << choice_field
|
115
|
+
element = FactoryBot.create(:reference_element, label: "Reference question here", required: true)
|
116
|
+
question_sheet.pages[3].elements << element
|
117
|
+
|
118
|
+
application = FactoryBot.create(:answer_sheet)
|
119
|
+
application.question_sheets << question_sheet
|
120
|
+
reference = FactoryBot.create(:reference_sheet, applicant_answer_sheet: application, question: element)
|
121
|
+
|
122
|
+
# make the answer to the conditional question 'no' so that the ref is not required (optional true)
|
123
|
+
choice_field.set_response("no", application)
|
124
|
+
choice_field.save_response(application)
|
125
|
+
|
126
|
+
expect(reference.optional?).to be true
|
127
|
+
end
|
128
|
+
it 'returns false when the ref question element is visible from a conditional element' do
|
129
|
+
question_sheet = FactoryBot.create(:question_sheet_with_pages)
|
130
|
+
choice_field = FactoryBot.create(:choice_field_element, label: "Is the reference required?", conditional_type: "Fe::Element", conditional_answer: "yes")
|
131
|
+
question_sheet.pages.reload
|
132
|
+
question_sheet.pages[3].elements << choice_field
|
133
|
+
element = FactoryBot.create(:reference_element, label: "Reference question here", required: true)
|
134
|
+
question_sheet.pages[3].elements << element
|
135
|
+
|
136
|
+
application = FactoryBot.create(:answer_sheet)
|
137
|
+
application.question_sheets << question_sheet
|
138
|
+
reference = FactoryBot.create(:reference_sheet, applicant_answer_sheet: application, question: element)
|
139
|
+
|
140
|
+
# make the answer to the conditional question 'yes' so that the ref is required (optional false)
|
141
|
+
choice_field.set_response("yes", application)
|
142
|
+
choice_field.save_response(application)
|
143
|
+
|
144
|
+
expect(reference.optional?).to be false
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'sets the question_sheet_id' do
|
149
|
+
element = FactoryBot.create(:reference_element, label: "Reference question here", required: true, related_question_sheet_id: 1)
|
150
|
+
application = FactoryBot.create(:answer_sheet)
|
151
|
+
reference = FactoryBot.create(:reference_sheet, applicant_answer_sheet: application, question: element)
|
152
|
+
expect(reference.question_sheet_id).to eq(1)
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'starts out in created status' do
|
156
|
+
r = create(:reference_sheet)
|
157
|
+
expect(r.status).to eq('created')
|
158
|
+
end
|
159
|
+
|
160
|
+
context '#check_email_change' do
|
161
|
+
let(:qs) { create(:question_sheet) }
|
162
|
+
let(:ref_qs) { create(:question_sheet) }
|
163
|
+
let(:ref_tf) { create(:text_field_element) }
|
164
|
+
let(:q) { create(:reference_question, related_question_sheet: ref_qs) }
|
165
|
+
let(:applicant) { FactoryBot.create(:fe_person) }
|
166
|
+
let(:application) { FactoryBot.create(:answer_sheet, applicant_id: applicant.id) }
|
167
|
+
let(:r) { create(:reference_sheet, status: 'started', question: q, email_sent_at: 1.hour.ago, applicant_answer_sheet: application) }
|
168
|
+
let(:a) { create(:answer, value: 'test', answer_sheet_id: r.id, question: ref_tf) }
|
169
|
+
|
170
|
+
before do
|
171
|
+
ref_qs.pages << create(:page)
|
172
|
+
ref_qs.pages.first.elements << ref_tf
|
173
|
+
@access_key_before = r.access_key
|
174
|
+
@a = create(:answer, value: 'test', answer_sheet_id: r.id, question: ref_tf)
|
175
|
+
create(:fe_email_template, name: 'Reference Deleted', subject: 'Reference Deleted', content: "<a href='test'>reference deleted</a>")
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should reset the answers and access key if created' do
|
179
|
+
r.update_column(:status, 'created')
|
180
|
+
r.update_attribute(:email, 'a@b.com')
|
181
|
+
expect(r.access_key).to_not eq(@access_key_before)
|
182
|
+
expect(Fe::Answer.count).to eq(0)
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should reset the answers and access key if started' do
|
186
|
+
r.update_column(:status, 'started')
|
187
|
+
r.update_attribute(:email, 'a@b.com')
|
188
|
+
expect(r.access_key).to_not eq(@access_key_before)
|
189
|
+
expect(Fe::Answer.count).to eq(0)
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'should not reset the answers and access key if completed' do
|
193
|
+
r.update_column(:status, 'completed')
|
194
|
+
r.update_attribute(:email, 'a@b.com')
|
195
|
+
expect(r.access_key).to eq(@access_key_before)
|
196
|
+
expect(Fe::Answer.count).to eq(1)
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'should not reset the answers and access key if completed' do
|
200
|
+
r.update_column(:status, 'completed')
|
201
|
+
r.update_attribute(:email, 'a@b.com')
|
202
|
+
expect(r.access_key).to eq(@access_key_before)
|
203
|
+
expect(Fe::Answer.find_by(id: a.id)).to_not be_nil
|
204
|
+
end
|
205
|
+
|
206
|
+
it "doesn't delete the answers if allow_quiet_reference_email_changes is set " do
|
207
|
+
r.update_column(:status, 'started')
|
208
|
+
r.update_attribute(:email, 'a@b.com')
|
209
|
+
r.allow_quiet_reference_email_changes = true
|
210
|
+
expect(r.access_key).to_not eq(@access_key_before)
|
211
|
+
expect(Fe::Answer.count).to eq(0)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
context do
|
216
|
+
let(:qs) { create(:question_sheet_with_pages) }
|
217
|
+
let(:qs2) { create(:question_sheet_with_pages) }
|
218
|
+
let(:p) { qs.pages.first }
|
219
|
+
let(:p2) { qs.pages.first }
|
220
|
+
let(:ref_el) { create(:reference_element) }
|
221
|
+
let(:ref_el2) { create(:reference_element) }
|
222
|
+
let(:ref_el3) { create(:reference_element) }
|
223
|
+
let(:app) { create(:application) }
|
224
|
+
let(:affecting_el) { create(:choice_field_element, label: "Is the reference required?", conditional_type: "Fe::Element", conditional_id: ref_el.id, conditional_answer: "yes") }
|
225
|
+
let(:ref_sheet) { create(:reference_sheet, question: ref_el, applicant_answer_sheet_id: app.id) }
|
226
|
+
|
227
|
+
before do
|
228
|
+
p.elements << affecting_el << ref_el
|
229
|
+
p2.elements << ref_el2
|
230
|
+
app.question_sheets << qs << qs2
|
231
|
+
end
|
232
|
+
|
233
|
+
context '#computed_visibility_cache_key' do
|
234
|
+
it 'returns a cache key that changes when the answers on visibility_affecting_element_ids changes' do
|
235
|
+
# make the answer to the conditional question 'no' so that the ref is required (optional false)
|
236
|
+
affecting_el.set_response('no', app)
|
237
|
+
affecting_el.save_response(app)
|
238
|
+
|
239
|
+
cache_key_before = ref_sheet.computed_visibility_cache_key
|
240
|
+
|
241
|
+
# make the answer to the conditional question 'yes' so that the ref is required (optional false)
|
242
|
+
sleep(1) # make sure the update_at for the answer is changed
|
243
|
+
affecting_el.set_response('yes', app)
|
244
|
+
affecting_el.save_response(app)
|
245
|
+
cache_key_after = ref_sheet.computed_visibility_cache_key
|
246
|
+
|
247
|
+
expect(cache_key_before).to_not eq(cache_key_after)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
context '#update_visible' do
|
252
|
+
it "doesn't recompute the visibility if the cache key is the same" do
|
253
|
+
# make the answer to the conditional question 'no' so that the ref is required (optional false)
|
254
|
+
affecting_el.set_response('no', app)
|
255
|
+
affecting_el.save_response(app)
|
256
|
+
ref_sheet.update_visible
|
257
|
+
|
258
|
+
# call update_visible again, it shouldn't update anything because the cache
|
259
|
+
# key hasn't changed
|
260
|
+
allow(ref_sheet).to receive(:question).and_return(ref_el)
|
261
|
+
expect(ref_el).to_not receive(:visible?)
|
262
|
+
ref_sheet.update_visible
|
263
|
+
end
|
264
|
+
it 'computes the visibility and sets the cache key if cache key is initially null' do
|
265
|
+
ref_sheet.update(visibility_cache_key: nil)
|
266
|
+
|
267
|
+
# make the answer to the conditional question 'no' so that the ref is required (optional false)
|
268
|
+
affecting_el.set_response('no', app)
|
269
|
+
affecting_el.save_response(app)
|
270
|
+
allow(ref_sheet).to receive(:question).and_return(ref_el)
|
271
|
+
expect(ref_el).to receive(:visible?).and_return(true)
|
272
|
+
ref_sheet.update_visible
|
273
|
+
ref_sheet.reload
|
274
|
+
expect(ref_sheet.visible).to be true
|
275
|
+
expect(ref_sheet.visibility_cache_key).to_not be_nil
|
276
|
+
end
|
277
|
+
it 'computes the visibility and sets the cache key if the cache key changes' do
|
278
|
+
ref_sheet.update(visibility_cache_key: 'something')
|
279
|
+
|
280
|
+
# make the answer to the conditional question 'no' so that the ref is required (optional false)
|
281
|
+
affecting_el.set_response('no', app)
|
282
|
+
affecting_el.save_response(app)
|
283
|
+
allow(ref_sheet).to receive(:question).and_return(ref_el)
|
284
|
+
expect(ref_el).to receive(:visible?).and_return(false)
|
285
|
+
ref_sheet.update_visible
|
286
|
+
ref_sheet.reload
|
287
|
+
expect(ref_sheet.visible).to be false
|
288
|
+
expect(ref_sheet.visibility_cache_key).to_not eq('something')
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
context '#all_affecting_questions_answered' do
|
294
|
+
let(:p) { create(:fe_person) }
|
295
|
+
let(:a) { create(:answer_sheet, applicant_id: p.id) }
|
296
|
+
let(:ref_el) { create(:reference_element) }
|
297
|
+
let(:r) { create(:reference_sheet, question_id: ref_el.id, applicant_answer_sheet: a) }
|
298
|
+
let(:text_el) { create(:text_field_element) }
|
299
|
+
|
300
|
+
it 'returns true when all visibility affecting questions are answered' do
|
301
|
+
expect(r).to receive(:question).and_return(ref_el).twice
|
302
|
+
expect(ref_el).to receive(:visibility_affecting_questions).and_return([text_el])
|
303
|
+
text_el.set_response('some text response', a)
|
304
|
+
text_el.save_response(a)
|
305
|
+
expect(r.all_affecting_questions_answered).to be true
|
306
|
+
end
|
307
|
+
|
308
|
+
it 'returns false when not all visibility affecting questions are answered' do
|
309
|
+
expect(r).to receive(:question).and_return(ref_el).twice
|
310
|
+
expect(ref_el).to receive(:visibility_affecting_questions).and_return([text_el])
|
311
|
+
expect(r.all_affecting_questions_answered).to be false
|
312
|
+
end
|
313
|
+
end
|
31
314
|
end
|
@@ -14,4 +14,26 @@ describe Fe::TextField do
|
|
14
14
|
expect(text_field.ptemplate).to eq("fe/text_area_field")
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
it 'should match conditional_match' do
|
19
|
+
qs = create(:question_sheet)
|
20
|
+
app = create(:application)
|
21
|
+
app.question_sheets << qs
|
22
|
+
e = create(:text_field_element, conditional_answer: 'a;b', style: 'drop-down')
|
23
|
+
qs.pages << create(:page)
|
24
|
+
qs.pages.reload.first.elements << e
|
25
|
+
a = create(:answer, question_id: e.id, value: 'b', answer_sheet_id: app.id)
|
26
|
+
expect(e.conditional_match(app)).to be true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not match conditional_match if the answer doesn't match" do
|
30
|
+
qs = create(:question_sheet)
|
31
|
+
app = create(:application)
|
32
|
+
app.question_sheets << qs
|
33
|
+
e = create(:text_field_element, conditional_answer: 'a;b', style: 'drop-down')
|
34
|
+
qs.pages << create(:page)
|
35
|
+
qs.pages.reload.first.elements << e
|
36
|
+
a = create(:answer, question_id: e.id, value: 'c', answer_sheet_id: app.id)
|
37
|
+
expect(e.conditional_match(app)).to_not be true
|
38
|
+
end
|
17
39
|
end
|