fe 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (402) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +4 -4
  3. data/app/assets/config/fe/manifest.js +3 -0
  4. data/app/assets/config/manifest.js +3 -0
  5. data/app/assets/javascripts/application.js.erb +1 -1
  6. data/app/assets/javascripts/fe/admin.js +0 -1
  7. data/app/assets/javascripts/fe/fe.admin.js +2 -6
  8. data/app/assets/javascripts/fe/{fe.common.js → fe.common.js.erb} +14 -7
  9. data/app/assets/javascripts/fe/fe.public.js +1 -2
  10. data/app/assets/javascripts/fe/{fe.public.nojquery.js → fe.public.nojquery.js.erb} +152 -76
  11. data/app/assets/javascripts/fe/jquery.html5_upload.js +258 -0
  12. data/app/assets/stylesheets/fe/fe.screen.css.scss.erb +22 -1
  13. data/app/assets/stylesheets/fe/validation.css +5 -1
  14. data/app/controllers/{fe/concerns → concerns/fe}/admin/question_sheets_controller_concern.rb +15 -16
  15. data/app/controllers/concerns/fe/answer_pages_controller_concern.rb +131 -0
  16. data/app/controllers/{fe/concerns → concerns/fe}/answer_sheets_controller_concern.rb +14 -6
  17. data/app/controllers/{fe/concerns → concerns/fe}/application_controller_concern.rb +3 -3
  18. data/app/controllers/fe/admin/elements_controller.rb +46 -24
  19. data/app/controllers/fe/admin/email_templates_controller.rb +5 -5
  20. data/app/controllers/fe/admin/question_pages_controller.rb +8 -8
  21. data/app/controllers/fe/reference_pages_controller.rb +11 -11
  22. data/app/controllers/fe/reference_sheets_controller.rb +4 -4
  23. data/app/controllers/fe/references_controller.rb +19 -19
  24. data/app/controllers/fe/submit_pages_controller.rb +5 -5
  25. data/app/helpers/fe/answer_pages_helper.rb +1 -1
  26. data/app/helpers/fe/application_helper.rb +3 -3
  27. data/app/jobs/fe/update_reference_sheet_visibility_job.rb +11 -0
  28. data/app/mailers/fe/notifier.rb +4 -4
  29. data/app/models/answer_sheet.rb +1 -1
  30. data/app/models/application_record.rb +3 -0
  31. data/app/models/{fe/concerns → concerns/fe}/answer_concern.rb +2 -2
  32. data/app/models/{fe/concerns → concerns/fe}/answer_pages_presenter_concern.rb +6 -5
  33. data/app/models/concerns/fe/answer_sheet_concern.rb +125 -0
  34. data/app/models/{fe/concerns → concerns/fe}/choice_field_concern.rb +41 -23
  35. data/app/models/fe/address.rb +2 -2
  36. data/app/models/fe/answer.rb +1 -1
  37. data/app/models/fe/answer_sheet.rb +1 -1
  38. data/app/models/fe/answer_sheet_question_sheet.rb +2 -2
  39. data/app/models/fe/application.rb +14 -10
  40. data/app/models/fe/condition.rb +4 -4
  41. data/app/models/fe/date_field.rb +1 -1
  42. data/app/models/fe/element.rb +126 -44
  43. data/app/models/fe/email_address.rb +2 -2
  44. data/app/models/fe/email_template.rb +1 -1
  45. data/app/models/fe/page.rb +94 -19
  46. data/app/models/fe/page_element.rb +2 -2
  47. data/app/models/fe/paragraph.rb +1 -1
  48. data/app/models/fe/person.rb +5 -5
  49. data/app/models/fe/phone_number.rb +1 -1
  50. data/app/models/fe/question.rb +62 -38
  51. data/app/models/fe/question_grid.rb +15 -3
  52. data/app/models/fe/question_set.rb +53 -13
  53. data/app/models/fe/question_sheet.rb +49 -16
  54. data/app/models/fe/reference_question.rb +9 -3
  55. data/app/models/fe/reference_sheet.rb +102 -47
  56. data/app/models/fe/state_chooser.rb +2 -2
  57. data/app/models/fe/text_field.rb +2 -2
  58. data/app/models/fe/user.rb +1 -1
  59. data/app/models/staff.rb +6 -6
  60. data/app/views/fe/admin/elements/create.js.erb +3 -3
  61. data/app/views/fe/admin/elements/destroy.js.erb +1 -1
  62. data/app/views/fe/admin/elements/drop.js.erb +1 -1
  63. data/app/views/fe/admin/elements/duplicate.js.erb +1 -1
  64. data/app/views/fe/admin/elements/edit.js.erb +1 -1
  65. data/app/views/fe/admin/elements/error.js.erb +1 -1
  66. data/app/views/fe/admin/elements/new.js.erb +13 -6
  67. data/app/views/fe/admin/elements/update.js.erb +1 -1
  68. data/app/views/fe/admin/email_templates/_form.html.erb +3 -3
  69. data/app/views/fe/admin/email_templates/edit.html.erb +3 -3
  70. data/app/views/fe/admin/email_templates/index.html.erb +3 -3
  71. data/app/views/fe/admin/email_templates/new.html.erb +3 -3
  72. data/app/views/fe/admin/panels/_advanced_options.html.erb +8 -8
  73. data/app/views/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
  74. data/app/views/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
  75. data/app/views/fe/admin/panels/_common_fields.html.erb +2 -17
  76. data/app/views/fe/admin/panels/_condition.html.erb +1 -1
  77. data/app/views/fe/admin/panels/_insert.html.erb +25 -25
  78. data/app/views/fe/admin/panels/_nav_controls.html.erb +4 -4
  79. data/app/views/fe/admin/panels/_page.html.erb +1 -1
  80. data/app/views/fe/admin/panels/_pages_list.html.erb +3 -3
  81. data/app/views/fe/admin/panels/_prop_attachment_field.html.erb +2 -2
  82. data/app/views/fe/admin/panels/_prop_choice_field.html.erb +36 -17
  83. data/app/views/fe/admin/panels/_prop_date_field.html.erb +1 -1
  84. data/app/views/fe/admin/panels/_prop_element.html.erb +5 -5
  85. data/app/views/fe/admin/panels/_prop_page.html.erb +3 -3
  86. data/app/views/fe/admin/panels/_prop_paragraph.html.erb +8 -8
  87. data/app/views/fe/admin/panels/_prop_question_grid.html.erb +7 -2
  88. data/app/views/fe/admin/panels/_prop_question_grid_with_total.html.erb +2 -2
  89. data/app/views/fe/admin/panels/_prop_reference_question.html.erb +3 -3
  90. data/app/views/fe/admin/panels/_prop_section.html.erb +1 -1
  91. data/app/views/fe/admin/panels/_prop_sheet.html.erb +3 -3
  92. data/app/views/fe/admin/panels/_prop_text_field.html.erb +12 -12
  93. data/app/views/fe/admin/question_pages/_element.html.erb +7 -7
  94. data/app/views/fe/admin/question_pages/_element_show.html.erb +2 -2
  95. data/app/views/fe/admin/question_pages/_question_page.html.erb +4 -4
  96. data/app/views/fe/admin/question_pages/create.js.erb +3 -3
  97. data/app/views/fe/admin/question_pages/destroy.js.erb +3 -3
  98. data/app/views/fe/admin/question_pages/edit.js.erb +1 -1
  99. data/app/views/fe/admin/question_pages/error.js.erb +1 -1
  100. data/app/views/fe/admin/question_pages/show.js.erb +2 -2
  101. data/app/views/fe/admin/question_pages/show_panel.js.erb +1 -1
  102. data/app/views/fe/admin/question_pages/update.js.erb +1 -1
  103. data/app/views/fe/admin/question_sheets/edit.js.erb +1 -1
  104. data/app/views/fe/admin/question_sheets/error.js.erb +1 -1
  105. data/app/views/fe/admin/question_sheets/index.html.erb +8 -8
  106. data/app/views/fe/admin/question_sheets/new.html.erb +3 -3
  107. data/app/views/fe/admin/question_sheets/show.html.erb +5 -5
  108. data/app/views/fe/admin/question_sheets/update.js.erb +1 -1
  109. data/app/views/fe/answer_pages/_answer_page.html.erb +13 -14
  110. data/app/views/fe/answer_pages/_element.html.erb +22 -2
  111. data/app/views/fe/answer_pages/_page_name.html.erb +1 -1
  112. data/app/views/fe/answer_pages/show.html.erb +39 -0
  113. data/app/views/fe/answer_pages/update.js.erb +10 -2
  114. data/app/views/fe/answer_sheets/_answer_sheet.html.erb +4 -4
  115. data/app/views/fe/answer_sheets/_element.html.erb +9 -7
  116. data/app/views/fe/answer_sheets/_incomplete.html.erb +1 -1
  117. data/app/views/fe/answer_sheets/_page_link.html.erb +9 -7
  118. data/app/views/fe/answer_sheets/_pages_list.html.erb +3 -3
  119. data/app/views/fe/answer_sheets/_submit_to.html.erb +1 -1
  120. data/app/views/fe/answer_sheets/_title.html.erb +1 -1
  121. data/app/views/fe/answer_sheets/edit.html.erb +18 -18
  122. data/app/views/fe/answer_sheets/incomplete.js.erb +7 -4
  123. data/app/views/fe/answer_sheets/index.html.erb +1 -1
  124. data/app/views/fe/answer_sheets/show.html.erb +1 -1
  125. data/app/views/fe/applications/_logout.html.erb +1 -1
  126. data/app/views/fe/questions/fe/_acceptance.html.erb +10 -9
  127. data/app/views/fe/questions/fe/_attachment_field.html.erb +129 -10
  128. data/app/views/fe/questions/fe/_checkbox_field.html.erb +18 -16
  129. data/app/views/fe/questions/fe/_country.html.erb +6 -6
  130. data/app/views/fe/questions/fe/_date_field.html.erb +5 -4
  131. data/app/views/fe/questions/fe/_date_field_mmyy.html.erb +8 -8
  132. data/app/views/fe/questions/fe/_drop_down_field.html.erb +5 -5
  133. data/app/views/fe/questions/fe/_question_grid.html.erb +10 -10
  134. data/app/views/fe/questions/fe/_question_grid_with_total.html.erb +8 -8
  135. data/app/views/fe/questions/fe/_questions.html.erb +11 -5
  136. data/app/views/fe/questions/fe/_radio_button_field.html.erb +35 -19
  137. data/app/views/fe/questions/fe/_rating.html.erb +56 -18
  138. data/app/views/fe/questions/fe/_reference_discipler.html.erb +1 -1
  139. data/app/views/fe/questions/fe/_reference_friend.html.erb +1 -1
  140. data/app/views/fe/questions/fe/_reference_parent.html.erb +1 -1
  141. data/app/views/fe/questions/fe/_reference_peer.html.erb +1 -1
  142. data/app/views/fe/questions/fe/_reference_question.html.erb +40 -24
  143. data/app/views/fe/questions/fe/_reference_roommate.html.erb +1 -1
  144. data/app/views/fe/questions/fe/_reference_spiritual.html.erb +1 -1
  145. data/app/views/fe/questions/fe/_reference_staff.html.erb +1 -1
  146. data/app/views/fe/questions/fe/_state_chooser.html.erb +6 -6
  147. data/app/views/fe/questions/fe/_text_area_field.html.erb +14 -10
  148. data/app/views/fe/questions/fe/_text_field.html.erb +7 -6
  149. data/app/views/fe/questions/fe/_yes_no.html.erb +8 -8
  150. data/app/views/fe/questions/fe/_yes_no_field.erb +11 -8
  151. data/app/views/fe/reference_pages/_reference.html.erb +12 -12
  152. data/app/views/fe/reference_pages/edit.html.erb +4 -4
  153. data/app/views/fe/reference_sheets/done.html.erb +2 -2
  154. data/app/views/fe/reference_sheets/not_found.html.erb +3 -3
  155. data/app/views/fe/references/edit.html.erb +5 -5
  156. data/app/views/fe/references/show.html.erb +3 -3
  157. data/app/views/fe/references/submit.js.erb +3 -3
  158. data/app/views/fe/submit_pages/_thankyou.html.erb +1 -1
  159. data/app/views/fe/submit_pages/edit.html.erb +9 -9
  160. data/app/views/fe/submit_pages/error.js.erb +1 -1
  161. data/app/views/fe/submit_pages/submit.js.erb +2 -2
  162. data/app/views/layouts/fe/_error_messages_for.html.erb +1 -1
  163. data/app/views/layouts/fe/application.html.erb +3 -4
  164. data/app/views/layouts/fe/fe_admin.html.erb +30 -0
  165. data/app/views.current/fe/admin/elements/_errors.html.erb +11 -0
  166. data/app/views.current/fe/admin/elements/create.js.erb +12 -0
  167. data/app/views.current/fe/admin/elements/destroy.js.erb +4 -0
  168. data/app/views.current/fe/admin/elements/drop.js.erb +3 -0
  169. data/app/views.current/fe/admin/elements/duplicate.js.erb +3 -0
  170. data/app/views.current/fe/admin/elements/edit.js.erb +4 -0
  171. data/app/views.current/fe/admin/elements/error.js.erb +4 -0
  172. data/app/views.current/fe/admin/elements/new.js.erb +17 -0
  173. data/app/views.current/fe/admin/elements/update.js.erb +9 -0
  174. data/app/views.current/fe/admin/email_templates/_form.html.erb +8 -0
  175. data/app/views.current/fe/admin/email_templates/edit.html.erb +13 -0
  176. data/app/views.current/fe/admin/email_templates/index.html.erb +20 -0
  177. data/app/views.current/fe/admin/email_templates/new.html.erb +11 -0
  178. data/app/views.current/fe/admin/panels/_advanced_options.html.erb +49 -0
  179. data/app/views.current/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
  180. data/app/views.current/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
  181. data/app/views.current/fe/admin/panels/_common_fields.html.erb +23 -0
  182. data/app/views.current/fe/admin/panels/_condition.html.erb +6 -0
  183. data/app/views.current/fe/admin/panels/_insert.html.erb +39 -0
  184. data/app/views.current/fe/admin/panels/_nav_controls.html.erb +6 -0
  185. data/app/views.current/fe/admin/panels/_page.html.erb +3 -0
  186. data/app/views.current/fe/admin/panels/_pages_list.html.erb +16 -0
  187. data/app/views.current/fe/admin/panels/_prop_attachment_field.html.erb +2 -0
  188. data/app/views.current/fe/admin/panels/_prop_choice_field.html.erb +74 -0
  189. data/app/views.current/fe/admin/panels/_prop_date_field.html.erb +7 -0
  190. data/app/views.current/fe/admin/panels/_prop_element.html.erb +23 -0
  191. data/app/views.current/fe/admin/panels/_prop_page.html.erb +26 -0
  192. data/app/views.current/fe/admin/panels/_prop_paragraph.html.erb +46 -0
  193. data/app/views.current/fe/admin/panels/_prop_question_grid.html.erb +28 -0
  194. data/app/views.current/fe/admin/panels/_prop_question_grid_with_total.html.erb +14 -0
  195. data/app/views.current/fe/admin/panels/_prop_reference_question.html.erb +12 -0
  196. data/app/views.current/fe/admin/panels/_prop_section.html.erb +8 -0
  197. data/app/views.current/fe/admin/panels/_prop_sheet.html.erb +20 -0
  198. data/app/views.current/fe/admin/panels/_prop_text_field.html.erb +20 -0
  199. data/app/views.current/fe/admin/question_pages/_element.html.erb +28 -0
  200. data/app/views.current/fe/admin/question_pages/_element_show.html.erb +10 -0
  201. data/app/views.current/fe/admin/question_pages/_errors.html.erb +10 -0
  202. data/app/views.current/fe/admin/question_pages/_question_page.html.erb +13 -0
  203. data/app/views.current/fe/admin/question_pages/create.js.erb +11 -0
  204. data/app/views.current/fe/admin/question_pages/destroy.js.erb +5 -0
  205. data/app/views.current/fe/admin/question_pages/edit.js.erb +3 -0
  206. data/app/views.current/fe/admin/question_pages/error.js.erb +4 -0
  207. data/app/views.current/fe/admin/question_pages/show.js.erb +9 -0
  208. data/app/views.current/fe/admin/question_pages/show_panel.js.erb +3 -0
  209. data/app/views.current/fe/admin/question_pages/update.js.erb +2 -0
  210. data/app/views.current/fe/admin/question_sheets/_errors.html.erb +11 -0
  211. data/app/views.current/fe/admin/question_sheets/edit.js.erb +3 -0
  212. data/app/views.current/fe/admin/question_sheets/error.js.erb +5 -0
  213. data/app/views.current/fe/admin/question_sheets/index.html.erb +41 -0
  214. data/app/views.current/fe/admin/question_sheets/new.html.erb +15 -0
  215. data/app/views.current/fe/admin/question_sheets/show.html.erb +27 -0
  216. data/app/views.current/fe/admin/question_sheets/update.js.erb +2 -0
  217. data/app/views.current/fe/answer_pages/_answer_page.html.erb +53 -0
  218. data/app/views.current/fe/answer_pages/_element.html.erb +32 -0
  219. data/app/views.current/fe/answer_pages/_page_name.html.erb +1 -0
  220. data/app/views.current/fe/answer_pages/show.html.erb +39 -0
  221. data/app/views.current/fe/answer_pages/update.js.erb +13 -0
  222. data/app/views.current/fe/answer_sheets/_answer_sheet.html.erb +26 -0
  223. data/app/views.current/fe/answer_sheets/_element.html.erb +74 -0
  224. data/app/views.current/fe/answer_sheets/_incomplete.html.erb +10 -0
  225. data/app/views.current/fe/answer_sheets/_page_link.html.erb +9 -0
  226. data/app/views.current/fe/answer_sheets/_pages_list.html.erb +11 -0
  227. data/app/views.current/fe/answer_sheets/_submit_to.html.erb +1 -0
  228. data/app/views.current/fe/answer_sheets/_title.html.erb +1 -0
  229. data/app/views.current/fe/answer_sheets/edit.html.erb +66 -0
  230. data/app/views.current/fe/answer_sheets/incomplete.js.erb +11 -0
  231. data/app/views.current/fe/answer_sheets/index.html.erb +18 -0
  232. data/app/views.current/fe/answer_sheets/send_reference_invite.js.erb +8 -0
  233. data/app/views.current/fe/answer_sheets/show.html.erb +13 -0
  234. data/app/views.current/fe/applications/_logout.html.erb +1 -0
  235. data/app/views.current/fe/applications/show.html.erb +1 -0
  236. data/app/views.current/fe/help/builder.html +33 -0
  237. data/app/views.current/fe/help/question_grid.html +18 -0
  238. data/app/views.current/fe/questions/fe/_acceptance.html.erb +14 -0
  239. data/app/views.current/fe/questions/fe/_attachment_field.html.erb +165 -0
  240. data/app/views.current/fe/questions/fe/_checkbox_field.html.erb +53 -0
  241. data/app/views.current/fe/questions/fe/_country.html.erb +7 -0
  242. data/app/views.current/fe/questions/fe/_date_field.html.erb +7 -0
  243. data/app/views.current/fe/questions/fe/_date_field_mmyy.html.erb +9 -0
  244. data/app/views.current/fe/questions/fe/_drop_down_field.html.erb +8 -0
  245. data/app/views.current/fe/questions/fe/_paragraph.html.erb +1 -0
  246. data/app/views.current/fe/questions/fe/_question_grid.html.erb +70 -0
  247. data/app/views.current/fe/questions/fe/_question_grid_with_total.html.erb +64 -0
  248. data/app/views.current/fe/questions/fe/_questions.html.erb +15 -0
  249. data/app/views.current/fe/questions/fe/_radio_button_field.html.erb +60 -0
  250. data/app/views.current/fe/questions/fe/_rating.html.erb +64 -0
  251. data/app/views.current/fe/questions/fe/_reference_discipler.html.erb +1 -0
  252. data/app/views.current/fe/questions/fe/_reference_friend.html.erb +1 -0
  253. data/app/views.current/fe/questions/fe/_reference_parent.html.erb +1 -0
  254. data/app/views.current/fe/questions/fe/_reference_peer.html.erb +1 -0
  255. data/app/views.current/fe/questions/fe/_reference_question.html.erb +61 -0
  256. data/app/views.current/fe/questions/fe/_reference_roommate.html.erb +1 -0
  257. data/app/views.current/fe/questions/fe/_reference_spiritual.html.erb +1 -0
  258. data/app/views.current/fe/questions/fe/_reference_staff.html.erb +1 -0
  259. data/app/views.current/fe/questions/fe/_section.html.erb +1 -0
  260. data/app/views.current/fe/questions/fe/_state_chooser.html.erb +7 -0
  261. data/app/views.current/fe/questions/fe/_text_area_field.html.erb +17 -0
  262. data/app/views.current/fe/questions/fe/_text_field.html.erb +9 -0
  263. data/app/views.current/fe/questions/fe/_yes_no.html.erb +17 -0
  264. data/app/views.current/fe/questions/fe/_yes_no_field.erb +20 -0
  265. data/app/views.current/fe/reference_pages/_reference.html.erb +31 -0
  266. data/app/views.current/fe/reference_pages/edit.html.erb +24 -0
  267. data/app/views.current/fe/reference_sheets/done.html.erb +2 -0
  268. data/app/views.current/fe/reference_sheets/not_found.html.erb +5 -0
  269. data/app/views.current/fe/reference_sheets/submitted.js.erb +1 -0
  270. data/app/views.current/fe/references/edit.html.erb +8 -0
  271. data/app/views.current/fe/references/send_invite.js.erb +7 -0
  272. data/app/views.current/fe/references/show.html.erb +18 -0
  273. data/app/views.current/fe/references/submit.js.erb +3 -0
  274. data/app/views.current/fe/submit_pages/_errors.html.erb +1 -0
  275. data/app/views.current/fe/submit_pages/_thankyou.html.erb +2 -0
  276. data/app/views.current/fe/submit_pages/edit.html.erb +36 -0
  277. data/app/views.current/fe/submit_pages/error.js.erb +1 -0
  278. data/app/views.current/fe/submit_pages/submit.js.erb +3 -0
  279. data/app/views.current/layouts/fe/_error_messages_for.html.erb +7 -0
  280. data/app/views.current/layouts/fe/application.html.erb +47 -0
  281. data/app/{views/layouts/fe/fe.admin.html.erb → views.current/layouts/fe/fe_admin.html.erb} +4 -4
  282. data/config/initializers/paper_trail.rb +3 -0
  283. data/config/routes.rb +3 -1
  284. data/db/migrate/20131003041856_core.rb +23 -23
  285. data/db/migrate/20131003044250_create_reference_sheets.rb +1 -1
  286. data/db/migrate/20131003044436_add_element_and_answer_fields.rb +3 -3
  287. data/db/migrate/20131003044518_create_email_templates.rb +2 -2
  288. data/db/migrate/20131003044621_add_max_lengths.rb +1 -1
  289. data/db/migrate/20131003044714_create_join_table.rb +1 -1
  290. data/db/migrate/20131016162128_remove_question_id_from_element.rb +1 -1
  291. data/db/migrate/20140623153424_create_fe_people.rb +1 -1
  292. data/db/migrate/20140624180246_create_fe_addresses.rb +1 -1
  293. data/db/migrate/20140624182216_create_fe_phone_numbers.rb +1 -1
  294. data/db/migrate/20140625160545_create_fe_users.rb +1 -1
  295. data/db/migrate/20140808202507_add_conditional_type_to_elements.rb +1 -1
  296. data/db/migrate/20140808203609_add_conditional_answer_to_elements.rb +1 -1
  297. data/db/migrate/20141103204704_remove_short_value_column.rb +1 -1
  298. data/db/migrate/20141109154522_move_conditional_ids_used_for_choice_field_to_their_own_column.rb +1 -1
  299. data/db/migrate/20150504221439_add_all_element_ids_to_pages.rb +1 -1
  300. data/db/migrate/20150713022326_add_locale_columns.rb +1 -1
  301. data/db/migrate/20150714220730_add_locale_to_answer_sheet.rb +1 -1
  302. data/db/migrate/20150925181652_add_share_to_elements.rb +5 -0
  303. data/db/migrate/20150928085325_change_pages_all_element_ids_to_text.rb +1 -1
  304. data/db/migrate/20150930191538_add_locale_to_reference_sheets.rb +1 -1
  305. data/db/migrate/20151021181928_switch_conditional_answer_separator_to_semicolon.rb +7 -0
  306. data/db/migrate/20151021184250_add_question_sheet_id_in_refs.rb +12 -0
  307. data/db/migrate/20160201185838_add_visible_and_visibility_cache_key_to_reference_sheets.rb +6 -0
  308. data/db/migrate/20160805221415_add_rating_extra_labels.rb +10 -0
  309. data/db/migrate/20181108201746_create_versions.rb +80 -0
  310. data/db/migrate/20181218201130_increase_slug_length.rb +5 -0
  311. data/lib/fe/engine.rb +10 -10
  312. data/lib/fe/version.rb +1 -1
  313. data/lib/fe.rb +7 -1
  314. data/spec/controllers/fe/admin/elements_controller_spec.rb +30 -20
  315. data/spec/controllers/fe/admin/email_templates_controller_spec.rb +2 -2
  316. data/spec/controllers/fe/admin/question_pages_controller_spec.rb +1 -1
  317. data/spec/controllers/fe/admin/question_sheets_controller_spec.rb +4 -4
  318. data/spec/controllers/fe/answer_pages_controller_spec.rb +86 -30
  319. data/spec/controllers/fe/answer_sheets_controller_spec.rb +65 -9
  320. data/spec/dummy/app/assets/config/manifest.js +0 -0
  321. data/spec/dummy/app/models/user.rb +1 -1
  322. data/spec/dummy/app/views/layouts/application.html.erb +2 -2
  323. data/spec/dummy/config/application.rb +1 -0
  324. data/spec/dummy/config/environments/test.rb +3 -3
  325. data/spec/dummy/config/initializers/assets.rb +5 -2
  326. data/spec/dummy/config/initializers/fast_gettext.rb +1 -1
  327. data/spec/dummy/config/initializers/to_unsafe_h.rb +5 -0
  328. data/spec/dummy/config/initializers/to_unsafe_h.rb.new +5 -0
  329. data/spec/dummy/db/migrate/20141203214017_core.fe_engine.rb +23 -23
  330. data/spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb +1 -1
  331. data/spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb +3 -3
  332. data/spec/dummy/db/migrate/20141203214020_create_email_templates.fe_engine.rb +2 -2
  333. data/spec/dummy/db/migrate/20141203214021_add_max_lengths.fe_engine.rb +1 -1
  334. data/spec/dummy/db/migrate/20141203214022_create_join_table.fe_engine.rb +1 -1
  335. data/spec/dummy/db/migrate/20141203214023_remove_question_id_from_element.fe_engine.rb +1 -1
  336. data/spec/dummy/db/migrate/20141203214024_create_fe_people.fe_engine.rb +1 -1
  337. data/spec/dummy/db/migrate/20141203214025_create_fe_addresses.fe_engine.rb +1 -1
  338. data/spec/dummy/db/migrate/20141203214027_create_fe_users.fe_engine.rb +1 -1
  339. data/spec/dummy/db/migrate/20141203214028_add_conditional_type_to_elements.fe_engine.rb +1 -1
  340. data/spec/dummy/db/migrate/20141203214029_add_conditional_answer_to_elements.fe_engine.rb +1 -1
  341. data/spec/dummy/db/migrate/20141203214030_remove_short_value_column.fe_engine.rb +1 -1
  342. data/spec/dummy/db/migrate/20141203214031_move_conditional_ids_used_for_choice_field_to_their_own_column.fe_engine.rb +1 -1
  343. data/spec/dummy/db/migrate/20150123215803_create_users.rb +1 -1
  344. data/spec/dummy/db/migrate/20150504222619_add_all_element_ids_to_pages.fe_engine.rb +1 -1
  345. data/spec/dummy/db/migrate/20150925192557_add_share_to_elements.fe_engine.rb +6 -0
  346. data/spec/dummy/db/migrate/20150930190001_create_fe_phone_numbers.fe_engine.rb +1 -1
  347. data/spec/dummy/db/migrate/20150930190002_add_locale_columns.fe_engine.rb +1 -1
  348. data/spec/dummy/db/migrate/20150930190003_add_locale_to_answer_sheet.fe_engine.rb +1 -1
  349. data/spec/dummy/db/migrate/20150930190004_change_pages_all_element_ids_to_text.fe_engine.rb +1 -1
  350. data/spec/dummy/db/migrate/20150930191756_add_locale_to_reference_sheets.fe_engine.rb +1 -1
  351. data/spec/dummy/db/migrate/20151021190027_add_question_sheet_id_in_refs.fe_engine.rb +13 -0
  352. data/spec/dummy/db/migrate/20160204164612_switch_conditional_answer_separator_to_semicolon.fe_engine.rb +8 -0
  353. data/spec/dummy/db/migrate/20160204164613_add_visible_and_visibility_cache_key_to_reference_sheets.fe_engine.rb +7 -0
  354. data/spec/dummy/db/migrate/20181108201746_create_versions.rb +80 -0
  355. data/spec/dummy/db/schema.rb +71 -79
  356. data/spec/dummy/log/test.log +101278 -419
  357. data/spec/factories/answer_sheet_question_sheets.rb +1 -1
  358. data/spec/factories/answer_sheets.rb +2 -2
  359. data/spec/factories/answers.rb +1 -1
  360. data/spec/factories/applications.rb +3 -3
  361. data/spec/factories/dummy_applications.rb +3 -3
  362. data/spec/factories/dummy_people.rb +3 -3
  363. data/spec/factories/dummy_users.rb +3 -3
  364. data/spec/factories/elements.rb +21 -21
  365. data/spec/factories/email_templates.rb +3 -3
  366. data/spec/factories/fe_addresses.rb +10 -10
  367. data/spec/factories/fe_email_addresses.rb +3 -3
  368. data/spec/factories/fe_email_templates.rb +4 -4
  369. data/spec/factories/fe_people.rb +5 -5
  370. data/spec/factories/fe_phone_numbers.rb +3 -3
  371. data/spec/factories/fe_user.rb +3 -3
  372. data/spec/factories/page.rb +1 -1
  373. data/spec/factories/page_elements.rb +1 -1
  374. data/spec/factories/paragraphs.rb +1 -1
  375. data/spec/factories/question_sheet.rb +2 -2
  376. data/spec/factories/reference_questions.rb +1 -1
  377. data/spec/factories/reference_sheets.rb +1 -1
  378. data/spec/jobs/fe/update_reference_sheet_visibility_job_spec.rb +40 -0
  379. data/spec/models/fe/answer_sheet_question_sheet_spec.rb +1 -1
  380. data/spec/models/fe/answer_spec.rb +2 -2
  381. data/spec/models/fe/application_spec.rb +94 -1
  382. data/spec/models/fe/choice_field_spec.rb +47 -1
  383. data/spec/models/fe/condition_spec.rb +2 -2
  384. data/spec/models/fe/element_spec.rb +252 -60
  385. data/spec/models/fe/email_template_spec.rb +1 -1
  386. data/spec/models/fe/page_element_spec.rb +1 -1
  387. data/spec/models/fe/page_spec.rb +57 -12
  388. data/spec/models/fe/person_spec.rb +1 -1
  389. data/spec/models/fe/question_set_spec.rb +91 -0
  390. data/spec/models/fe/question_sheet_spec.rb +11 -15
  391. data/spec/models/fe/question_spec.rb +73 -6
  392. data/spec/models/fe/reference_question_spec.rb +20 -0
  393. data/spec/models/fe/reference_sheet_spec.rb +287 -4
  394. data/spec/models/fe/text_field_spec.rb +22 -0
  395. data/spec/rails_helper.rb +79 -76
  396. metadata +195 -57
  397. data/app/assets/javascripts/fe/jquery.scrollTo-min.js +0 -7
  398. data/app/controllers/fe/concerns/answer_pages_controller_concern.rb +0 -84
  399. data/app/models/fe/concerns/answer_sheet_concern.rb +0 -85
  400. data/spec/dummy/db/migrate/20141203214026_create_create_fe_phone_numbers.fe_engine.rb +0 -17
  401. data/spec/dummy/log/development.log +0 -5
  402. /data/app/{assets/stylesheets/360front.css → views.current/fe/admin/elements/reorder.js.erb} +0 -0
@@ -0,0 +1,12 @@
1
+ class AddQuestionSheetIdInRefs < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column Fe::ReferenceSheet.table_name, :question_sheet_id, :integer
4
+
5
+ # set initial question_sheet_id on all refs
6
+ # NOTE: doing an update on a join query is a pain to do in both mysql and postgres
7
+ # and since there's not that many reference questions, this should be fine
8
+ Fe::ReferenceQuestion.all.each do |rq|
9
+ Fe::ReferenceSheet.where(question_id: rq.id).update_all(question_sheet_id: rq.related_question_sheet_id)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ class AddVisibleAndVisibilityCacheKeyToReferenceSheets < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column Fe::ReferenceSheet.table_name, :visible, :boolean
4
+ add_column Fe::ReferenceSheet.table_name, :visibility_cache_key, :string
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ class AddRatingExtraLabels < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column Fe::Element.table_name, :rating_before_label, :text
4
+ add_column Fe::Element.table_name, :rating_after_label, :text
5
+ add_column Fe::Element.table_name, :rating_na_label, :text
6
+ add_column Fe::Element.table_name, :rating_before_label_translations, :text
7
+ add_column Fe::Element.table_name, :rating_after_label_translations, :text
8
+ add_column Fe::Element.table_name, :rating_na_label_translations, :text
9
+ end
10
+ end
@@ -0,0 +1,80 @@
1
+ # This migration creates the `versions` table, the only schema PT requires.
2
+ # All other migrations PT provides are optional.
3
+ class CreateVersions < ActiveRecord::Migration[4.2]
4
+ # Class names of MySQL adapters.
5
+ # - `MysqlAdapter` - Used by gems: `mysql`, `activerecord-jdbcmysql-adapter`.
6
+ # - `Mysql2Adapter` - Used by `mysql2` gem.
7
+ MYSQL_ADAPTERS = [
8
+ "ActiveRecord::ConnectionAdapters::MysqlAdapter",
9
+ "ActiveRecord::ConnectionAdapters::Mysql2Adapter"
10
+ ].freeze
11
+
12
+ # The largest text column available in all supported RDBMS is
13
+ # 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
14
+ # so that MySQL will use `longtext` instead of `text`. Otherwise,
15
+ # when serializing very large objects, `text` might not be big enough.
16
+ TEXT_BYTES = 1_073_741_823
17
+
18
+ def change
19
+ create_table :versions, versions_table_options do |t|
20
+ t.string :item_type, item_type_options
21
+ t.integer :item_id, null: false
22
+ t.string :event, null: false
23
+ t.string :whodunnit
24
+ t.text :object, limit: TEXT_BYTES
25
+
26
+ # Known issue in MySQL: fractional second precision
27
+ # -------------------------------------------------
28
+ #
29
+ # MySQL timestamp columns do not support fractional seconds unless
30
+ # defined with "fractional seconds precision". MySQL users should manually
31
+ # add fractional seconds precision to this migration, specifically, to
32
+ # the `created_at` column.
33
+ # (https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html)
34
+ #
35
+ # MySQL users should also upgrade to rails 4.2, which is the first
36
+ # version of ActiveRecord with support for fractional seconds in MySQL.
37
+ # (https://github.com/rails/rails/pull/14359)
38
+ #
39
+ t.datetime :created_at
40
+ end
41
+ add_index :versions, [:item_type, :item_id]
42
+ end
43
+
44
+ private
45
+
46
+ # MySQL 5.6 utf8mb4 limit is 191 chars for keys used in indexes.
47
+ # See https://github.com/airblade/paper_trail/issues/651
48
+ def item_type_options
49
+ opt = { null: false }
50
+ opt[:limit] = 191 if mysql?
51
+ opt
52
+ end
53
+
54
+ def mysql?
55
+ MYSQL_ADAPTERS.include?(connection.class.name)
56
+ end
57
+
58
+ # Even modern versions of MySQL still use `latin1` as the default character
59
+ # encoding. Many users are not aware of this, and run into trouble when they
60
+ # try to use PaperTrail in apps that otherwise tend to use UTF-8. Postgres, by
61
+ # comparison, uses UTF-8 except in the unusual case where the OS is configured
62
+ # with a custom locale.
63
+ #
64
+ # - https://dev.mysql.com/doc/refman/5.7/en/charset-applications.html
65
+ # - http://www.postgresql.org/docs/9.4/static/multibyte.html
66
+ #
67
+ # Furthermore, MySQL's original implementation of UTF-8 was flawed, and had
68
+ # to be fixed later by introducing a new charset, `utf8mb4`.
69
+ #
70
+ # - https://mathiasbynens.be/notes/mysql-utf8mb4
71
+ # - https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html
72
+ #
73
+ def versions_table_options
74
+ if mysql?
75
+ { options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" }
76
+ else
77
+ {}
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,5 @@
1
+ class IncreaseSlugLength < ActiveRecord::Migration
2
+ def change
3
+ change_column Fe::Question.table_name, :slug, :string, limit: 128
4
+ end
5
+ end
data/lib/fe/engine.rb CHANGED
@@ -8,7 +8,7 @@ module Fe
8
8
  # Using the si as an example:
9
9
  #
10
10
  # si/app/controllers/fe/test_controller.rb
11
- #
11
+ #
12
12
  # class Fe::TestController < ApplicationController
13
13
  # def index
14
14
  # end
@@ -22,15 +22,15 @@ module Fe
22
22
  # http://crypt.codemancers.com/posts/2013-09-22-isolate-namespace-in-rails-engines/
23
23
  # it's a real pain to extend an isolated namespace engine from the app:
24
24
  #
25
- # "Other issues include extending models and controllers. Rails
25
+ # "Other issues include extending models and controllers. Rails
26
26
  # guides gives two options here. One to use class_eval, and other
27
- # to use concerns introduced in Rails 4. Both are kind of hacky.
27
+ # to use concerns introduced in Rails 4. Both are kind of hacky.
28
28
  # Hope there is a better solution."
29
- #
29
+ #
30
30
  # and as per a user comment on that page:
31
31
  #
32
32
  # "I've had a similar experience with `isolate_namespace`, if the engines
33
- # need to be truely isolated it works, but if you need to extend the engine
33
+ # need to be truely isolated it works, but if you need to extend the engine
34
34
  # from the client app its best to remove it and just namespace manually.
35
35
  #
36
36
  # I'm disabling the isolate_namespace
@@ -59,18 +59,18 @@ module Fe
59
59
  end
60
60
 
61
61
  config.generators do |g|
62
- g.test_framework :rspec, :fixture => false
63
- g.fixture_replacement :factory_girl, :dir => 'spec/factories'
62
+ g.test_framework :rspec, fixture: false
63
+ g.fixture_replacement :factory_bot, dir: 'spec/factories'
64
64
  g.assets false
65
65
  g.helper false
66
66
  end
67
67
 
68
68
  initializer "fe.asset_precompile_paths" do |app|
69
69
  app.config.assets.precompile += %w(fe/admin.js fe/fe.screen.css)
70
- end
70
+ end
71
71
 
72
- initializer "model_core.factories", :after => "factory_girl.set_factory_paths" do
73
- FactoryGirl.definition_file_paths << File.expand_path('../../../spec/factories', __FILE__) if defined?(FactoryGirl)
72
+ initializer "model_core.factories", after: "factory_bot.set_factory_paths" do
73
+ FactoryBot.definition_file_paths << File.expand_path('../../../spec/factories', __FILE__) if defined?(FactoryBot)
74
74
  end
75
75
  end
76
76
  end
data/lib/fe/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fe
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
data/lib/fe.rb CHANGED
@@ -5,7 +5,7 @@ module Fe
5
5
  # prefix for database tables
6
6
  mattr_accessor :table_name_prefix
7
7
  self.table_name_prefix ||= 'fe_'
8
-
8
+
9
9
  mattr_accessor :answer_sheet_class
10
10
  self.answer_sheet_class ||= 'Fe::Application'
11
11
 
@@ -23,4 +23,10 @@ module Fe
23
23
 
24
24
  "#{prefix} #{max.next}"
25
25
  end
26
+
27
+ mattr_accessor :date_format
28
+ self.date_format = 'yy-mm-dd'
29
+
30
+ mattr_accessor :bootstrap
31
+ self.bootstrap = false
26
32
  end
@@ -10,7 +10,7 @@ describe Fe::Admin::ElementsController, type: :controller do
10
10
  element = create(:text_field_element)
11
11
  create(:page_element, element: element, page: page)
12
12
 
13
- xhr :get, :edit, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id
13
+ get :edit, params: {question_sheet_id: question_sheet.id, page_id: page.id, id: element.id}, xhr: true
14
14
  expect(assigns(:element)).to eq(element)
15
15
  end
16
16
  end
@@ -20,11 +20,13 @@ describe Fe::Admin::ElementsController, type: :controller do
20
20
  page = create(:page)
21
21
  question_sheet = page.question_sheet
22
22
  create(:answer_sheet_question_sheet, answer_sheet: answer_sheet, question_sheet: question_sheet)
23
- element = create(:text_field_element, style: 'style')
24
- create(:page_element, element: element, page: page)
23
+ element1 = create(:text_field_element, style: 'style', share: true)
24
+ element2 = create(:text_field_element, style: 'style', share: false)
25
+ create(:page_element, element: element1, page: page)
26
+ create(:page_element, element: element2, page: page)
25
27
 
26
- xhr :get, :new, element_type: 'Fe::TextField', element: { style: 'style' }, question_sheet_id: question_sheet.id, page_id: page.id
27
- expect(assigns(:questions)).to eq([element])
28
+ get :new, params: {element_type: 'Fe::TextField', element: { style: 'style' }, question_sheet_id: question_sheet.id, page_id: page.id}, xhr: true
29
+ expect(assigns(:questions)).to eq([element1])
28
30
  end
29
31
  end
30
32
  context '#use_existing' do
@@ -35,19 +37,27 @@ describe Fe::Admin::ElementsController, type: :controller do
35
37
  create(:answer_sheet_question_sheet, answer_sheet: answer_sheet, question_sheet: question_sheet)
36
38
  element = create(:text_field_element, style: 'style')
37
39
 
38
- xhr :get, :use_existing, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id
40
+ get :use_existing, params: {question_sheet_id: question_sheet.id, page_id: page.id, id: element.id}, xhr: true
39
41
  expect(assigns(:page_element)).to_not be_nil
42
+ expect(assigns(:page_element)).to_not be_nil
43
+ expect(assigns(:page)).to eq(page)
44
+ expect(assigns(:page_element).element).to eq(element)
40
45
  end
41
- it 'should not put the same question on a questionnaire twice' do
46
+ end
47
+ context '#copy_existing' do
48
+ it 'should work' do
42
49
  answer_sheet = create(:answer_sheet)
43
50
  page = create(:page)
44
51
  question_sheet = page.question_sheet
45
52
  create(:answer_sheet_question_sheet, answer_sheet: answer_sheet, question_sheet: question_sheet)
46
- element = create(:text_field_element, style: 'style')
47
- create(:page_element, element: element, page: page)
53
+ element = create(:text_field_element, style: 'style', share: true)
48
54
 
49
- xhr :get, :use_existing, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id
50
- expect(assigns(:page_element)).to be_nil
55
+ get :copy_existing, params: {question_sheet_id: question_sheet.id, page_id: page.id, id: element.id}, xhr: true
56
+ expect(assigns(:page_element)).to_not be_nil
57
+ expect(assigns(:page_element)).to_not be_nil
58
+ expect(assigns(:page)).to eq(page)
59
+ expect(assigns(:page_element).element).to_not eq(element)
60
+ expect(assigns(:page_element).element.share).to be false
51
61
  end
52
62
  end
53
63
  context '#create' do
@@ -58,7 +68,7 @@ describe Fe::Admin::ElementsController, type: :controller do
58
68
  create(:answer_sheet_question_sheet, answer_sheet: answer_sheet, question_sheet: question_sheet)
59
69
 
60
70
  expect {
61
- xhr :post, :create, element_type: 'Fe::TextField', element: { style: 'style' }, question_sheet_id: question_sheet.id, page_id: page.id
71
+ post :create, params: {element_type: 'Fe::TextField', element: { style: 'style' }, question_sheet_id: question_sheet.id, page_id: page.id}, xhr: true
62
72
  }.to change{Fe::Element.count}.by(1)
63
73
 
64
74
  expect(assigns(:page_element)).to_not be_nil
@@ -73,7 +83,7 @@ describe Fe::Admin::ElementsController, type: :controller do
73
83
  create(:answer_sheet_question_sheet, answer_sheet: answer_sheet, question_sheet: question_sheet)
74
84
 
75
85
  expect {
76
- xhr :post, :create, element_type: 'Fe::TextField', element: { slug: "Illegal Chars: #@$!" }, question_sheet_id: question_sheet.id, page_id: page.id
86
+ post :create, params: {element_type: 'Fe::TextField', element: { slug: "Illegal Chars: #@$!" }, question_sheet_id: question_sheet.id, page_id: page.id}, xhr: true
77
87
  }.to change{Fe::Element.count}.by(0)
78
88
 
79
89
  expect(assigns(:page_element)).to be_nil
@@ -89,7 +99,7 @@ describe Fe::Admin::ElementsController, type: :controller do
89
99
  element = create(:text_field_element, style: 'style')
90
100
  create(:page_element, element: element, page: page)
91
101
 
92
- xhr :put, :update, element: { style: 'style' }, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id
102
+ put :update, params: {element: { style: 'style' }, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id}, xhr: true
93
103
 
94
104
  expect(assigns(:element)).to eq(element)
95
105
  expect(assigns(:element).style).to eq('style')
@@ -102,7 +112,7 @@ describe Fe::Admin::ElementsController, type: :controller do
102
112
  element = create(:text_field_element, style: 'style')
103
113
  create(:page_element, element: element, page: page)
104
114
 
105
- xhr :put, :update, element: { slug: "Illegal Chars: #@$!" }, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id
115
+ put :update, params: {element: { slug: "Illegal Chars: #@$!" }, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id}, xhr: true
106
116
  expect(assigns(:element)).to eq(element)
107
117
  expect(response).to render_template('error.js.erb')
108
118
  end
@@ -116,7 +126,7 @@ describe Fe::Admin::ElementsController, type: :controller do
116
126
  element = create(:text_field_element, style: 'style')
117
127
  create(:page_element, element: element, page: page)
118
128
 
119
- xhr :delete, :destroy, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id
129
+ delete :destroy, params: {question_sheet_id: question_sheet.id, page_id: page.id, id: element.id}, xhr: true
120
130
 
121
131
  expect(Fe::PageElement.find_by(page_id: page.id, element_id: element.id)).to be_nil
122
132
  expect(Fe::Element.find_by(id: element.id)).to be_nil
@@ -130,7 +140,7 @@ describe Fe::Admin::ElementsController, type: :controller do
130
140
  create(:page_element, element: element, page: page)
131
141
  create(:answer, question: element, value: 'answer here', answer_sheet: answer_sheet)
132
142
 
133
- xhr :delete, :destroy, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id
143
+ delete :destroy, params: {question_sheet_id: question_sheet.id, page_id: page.id, id: element.id}, xhr: true
134
144
 
135
145
  expect(Fe::PageElement.find_by(page_id: page.id, element_id: element.id)).to be_nil
136
146
  expect(Fe::Element.find_by(id: element.id)).to_not be_nil
@@ -145,7 +155,7 @@ describe Fe::Admin::ElementsController, type: :controller do
145
155
  create(:page_element, element: element, page: page)
146
156
  create(:page_element, element: element, page: page2)
147
157
 
148
- xhr :delete, :destroy, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id
158
+ delete :destroy, params: {question_sheet_id: question_sheet.id, page_id: page.id, id: element.id}, xhr: true
149
159
 
150
160
  expect(Fe::PageElement.find_by(page_id: page.id, element_id: element.id)).to be_nil
151
161
  expect(Fe::Element.find_by(id: element.id)).to_not be_nil
@@ -169,7 +179,7 @@ describe Fe::Admin::ElementsController, type: :controller do
169
179
 
170
180
  page_element_positions_before = Fe::PageElement.all.pluck(:position)
171
181
 
172
- xhr :post, :reorder, question_sheet_id: question_sheet.id, page_id: page.id, "questions_list_#{element3.id}" => [ element5.id, element4.id ]
182
+ post :reorder, params: {question_sheet_id: question_sheet.id, page_id: page.id, "questions_list_#{element3.id}" => [ element5.id, element4.id ]}, xhr: true
173
183
  # it shouldn't touch the page elements
174
184
  expect(Fe::PageElement.all.pluck(:position)).to eq(page_element_positions_before)
175
185
  # it should put a new order on the question grid elements
@@ -192,7 +202,7 @@ describe Fe::Admin::ElementsController, type: :controller do
192
202
 
193
203
  question_grid_elements_positions_before = element3.reload.elements.pluck(:position)
194
204
 
195
- xhr :post, :reorder, question_sheet_id: question_sheet.id, page_id: page.id, "questions_list" => [ element3.id, element.id, element2.id ]
205
+ post :reorder, params: {question_sheet_id: question_sheet.id, page_id: page.id, "questions_list" => [ element3.id, element.id, element2.id ]}, xhr: true
196
206
  # it shouldn't touch the question grid positions
197
207
  expect(element3.reload.elements.pluck(:position)).to eq(question_grid_elements_positions_before)
198
208
  # it should put a new order on the page elements
@@ -10,7 +10,7 @@ describe Fe::Admin::EmailTemplatesController, type: :controller do
10
10
  expect(assigns(:email_templates)).to eq([email_template])
11
11
  end
12
12
  end
13
-
13
+
14
14
  context '#new' do
15
15
  it 'should work' do
16
16
  get :new
@@ -21,7 +21,7 @@ describe Fe::Admin::EmailTemplatesController, type: :controller do
21
21
  context '#create' do
22
22
  it 'should work' do
23
23
  expect {
24
- post :create, email_template: { name: 'Name', subject: 'Subject', content: 'Content' }
24
+ post :create, params: {email_template: { name: 'Name', subject: 'Subject', content: 'Content' }}
25
25
  }.to change{Fe::EmailTemplate.count}.by(1)
26
26
  expect(assigns(:email_template)).to_not be_nil
27
27
  end
@@ -5,7 +5,7 @@ describe Fe::Admin::QuestionPagesController, type: :controller do
5
5
  it 'should work' do
6
6
  page = create(:page)
7
7
  question_sheet = page.question_sheet
8
- xhr :get, :show, question_sheet_id: question_sheet.id, id: page.id
8
+ get :show, params: {question_sheet_id: question_sheet.id, id: page.id}, xhr: true
9
9
  end
10
10
  end
11
11
  end
@@ -16,7 +16,7 @@ describe Fe::Admin::QuestionSheetsController, type: :controller do
16
16
  it 'should work' do
17
17
  active_qs = create(:question_sheet, archived: false)
18
18
  request.env["HTTP_REFERER"] = '/'
19
- post :archive, id: active_qs.id
19
+ post :archive, params: {id: active_qs.id}
20
20
  expect(active_qs.reload.archived).to be true
21
21
  end
22
22
  end
@@ -24,7 +24,7 @@ describe Fe::Admin::QuestionSheetsController, type: :controller do
24
24
  it 'should work' do
25
25
  active_qs = create(:question_sheet, archived: true)
26
26
  request.env["HTTP_REFERER"] = '/'
27
- post :unarchive, id: active_qs.id
27
+ post :unarchive, params: {id: active_qs.id}
28
28
  expect(active_qs.reload.archived).to be false
29
29
  end
30
30
  end
@@ -33,7 +33,7 @@ describe Fe::Admin::QuestionSheetsController, type: :controller do
33
33
  qs = create(:question_sheet)
34
34
  request.env["HTTP_REFERER"] = '/'
35
35
  expect {
36
- post :duplicate, id: qs.id
36
+ post :duplicate, params: {id: qs.id}
37
37
  }.to change{Fe::QuestionSheet.count}.by(1)
38
38
  expect(Fe::QuestionSheet.last.label).to eq("#{qs.label} - COPY")
39
39
  end
@@ -43,7 +43,7 @@ describe Fe::Admin::QuestionSheetsController, type: :controller do
43
43
  qs = create(:question_sheet)
44
44
  p1 = create(:page, question_sheet: qs)
45
45
  p2 = create(:page, question_sheet: qs)
46
- get :show, id: qs.id
46
+ get :show, params: {id: qs.id}
47
47
  expect(assigns(:all_pages)).to eq([p1, p2])
48
48
  expect(assigns(:page)).to eq(p1)
49
49
  end
@@ -2,53 +2,82 @@ require 'rails_helper'
2
2
 
3
3
  describe Fe::AnswerPagesController, type: :controller do
4
4
  context '#edit' do
5
+ let(:answer_sheet) { create(:answer_sheet) }
6
+ let(:page) { create(:page) }
7
+
5
8
  it 'should work' do
6
- answer_sheet = create(:answer_sheet)
7
- page = create(:page)
8
9
  question_sheet = page.question_sheet
9
10
  create(:answer_sheet_question_sheet, answer_sheet: answer_sheet, question_sheet: question_sheet)
10
- get :edit, id: page.id, answer_sheet_id: answer_sheet.id
11
+ get :edit, params: {id: page.id, answer_sheet_id: answer_sheet.id}
11
12
  expect(response).to render_template('fe/answer_pages/_answer_page')
12
13
  end
14
+ context 'filtering' do
15
+ let(:el_confidential) { create(:text_field_element, is_confidential: true) }
16
+ let(:el_visible) { create(:text_field_element, is_confidential: false) }
17
+ let(:el_visible2) { create(:text_field_element, is_confidential: false) }
18
+
19
+ before do
20
+ page.elements << el_confidential << el_visible << el_visible2
21
+ question_sheet = page.question_sheet
22
+ create(:answer_sheet_question_sheet, answer_sheet: answer_sheet, question_sheet: question_sheet)
23
+ end
24
+
25
+ it 'should filter out elements' do
26
+ allow_any_instance_of(Fe::AnswerPagesController).to receive(:get_filter).and_return(filter_default: :show, filter: [ :is_confidential ])
27
+ get :edit, params: {id: page.id, answer_sheet_id: answer_sheet.id}
28
+ expect(assigns(:elements)).to_not include(el_confidential)
29
+ expect(assigns(:elements)).to include(el_visible)
30
+ expect(assigns(:elements)).to include(el_visible2)
31
+ end
32
+ it 'should filter in elements' do
33
+ allow_any_instance_of(Fe::AnswerPagesController).to receive(:get_filter).and_return(filter_default: :hide, filter: [ :is_confidential ])
34
+ get :edit, params: {id: page.id, answer_sheet_id: answer_sheet.id}
35
+ expect(assigns(:elements)).to include(el_confidential)
36
+ expect(assigns(:elements)).to_not include(el_visible)
37
+ expect(assigns(:elements)).to_not include(el_visible2)
38
+ end
39
+ end
13
40
  end
41
+
14
42
  context '#update' do
15
- it 'should work' do
16
- answer_sheet = create(:answer_sheet)
17
- page = create(:page)
18
- question_sheet = page.question_sheet
43
+ let(:answer_sheet) { create(:answer_sheet) }
44
+ let(:page) { create(:page) }
45
+ let(:question_sheet) { question_sheet = page.question_sheet }
46
+ let(:element) { create(:text_field_element) }
47
+
48
+ before do
19
49
  create(:answer_sheet_question_sheet, answer_sheet: answer_sheet, question_sheet: question_sheet)
20
- element = create(:text_field_element)
21
50
  create(:page_element, element: element, page: page)
51
+ end
52
+
53
+ it 'should work' do
22
54
  # ref
23
55
  reference_question = create(:reference_question)
24
56
  reference_sheet = create(:reference_sheet, applicant_answer_sheet_id: answer_sheet.id, email: 'initial@ref.com')
25
57
 
26
- xhr :put, :update, {
27
- answers: { "#{element.id}" => 'answer here' },
28
- reference: { "#{reference_sheet.id}" => {
29
- relationship: 'roommate',
30
- title: 'A',
31
- first_name: 'FN',
32
- last_name: 'LN',
33
- phone: 'phone',
34
- email: 'email@reference.com'
35
- } },
36
- id: page.id,
37
- answer_sheet_id: answer_sheet.id
38
- }
58
+ expect {
59
+ put :update, params: {
60
+ answers: { "#{element.id}" => 'answer here' },
61
+ reference: { "#{reference_sheet.id}" => {
62
+ relationship: 'roommate',
63
+ title: 'A',
64
+ first_name: 'FN',
65
+ last_name: 'LN',
66
+ phone: 'phone',
67
+ email: 'email@reference.com'
68
+ } },
69
+ id: page.id,
70
+ answer_sheet_id: answer_sheet.id
71
+ }, xhr: true
72
+ }.to have_enqueued_job(Fe::UpdateReferenceSheetVisibilityJob)
39
73
 
40
74
  expect(response).to render_template('fe/answer_pages/update')
41
75
  expect(Fe::Answer.find_by(answer_sheet_id: answer_sheet.id, question_id: element.id).value).to eq('answer here')
42
76
  expect(reference_sheet.reload.email).to eq('email@reference.com')
43
77
  end
78
+
44
79
  it 'should store a reference sheet answer' do
45
80
  # create a normal applicant sheet to make sure the answer isn't saved to that
46
- answer_sheet = create(:answer_sheet)
47
- page = create(:page)
48
- question_sheet = page.question_sheet
49
- create(:answer_sheet_question_sheet, answer_sheet: answer_sheet, question_sheet: question_sheet)
50
- element = create(:text_field_element)
51
- create(:page_element, element: element, page: page)
52
81
  # ref
53
82
  ref_page = create(:page, label: 'Ref Page')
54
83
  ref_question_sheet = ref_page.question_sheet
@@ -57,12 +86,12 @@ describe Fe::AnswerPagesController, type: :controller do
57
86
  reference_question = create(:reference_question, related_question_sheet_id: ref_question_sheet.id)
58
87
  reference_sheet = create(:reference_sheet, question_id: reference_question.id, applicant_answer_sheet_id: answer_sheet.id, email: 'initial@ref.com')
59
88
 
60
- xhr :put, :update, {
89
+ put :update, params: {
61
90
  answers: { "#{ref_element.id}" => 'ref answer here' },
62
91
  id: ref_page.id,
63
92
  answer_sheet_id: reference_sheet.id,
64
93
  answer_sheet_type: 'Fe::ReferenceSheet'
65
- }
94
+ }, xhr: true
66
95
 
67
96
  expect(response).to render_template('fe/answer_pages/update')
68
97
  expect(Fe::Answer.find_by(answer_sheet_id: reference_sheet.id, question_id: ref_element.id).value).to eq('ref answer here')
@@ -71,6 +100,33 @@ describe Fe::AnswerPagesController, type: :controller do
71
100
  expect(reference_sheet.reload.answers.collect(&:value)).to eq(['ref answer here'])
72
101
  expect(answer_sheet.reload.answers).to eq([])
73
102
  end
74
- end
103
+ context 'when filling out a reference' do
104
+ it 'should not reset the reference even when the email changes' do
105
+ # ref
106
+ ref_page = create(:page, label: 'Ref Page')
107
+ ref_question_sheet = ref_page.question_sheet
108
+ ref_element = create(:text_field_element, object_name: 'answer_sheet', attribute_name: 'email')
109
+ create(:page_element, element: ref_element, page: ref_page)
110
+ reference_question = create(:reference_question, related_question_sheet_id: ref_question_sheet.id)
111
+ reference_sheet = create(:reference_sheet, question_id: reference_question.id, applicant_answer_sheet_id: answer_sheet.id, email: 'initial@ref.com')
112
+ reference_sheet.generate_access_key
113
+ reference_sheet.save!
114
+ key_before = reference_sheet.access_key
115
+
116
+ put :update, params: {
117
+ answers: { "#{ref_element.id}" => 'other@email.com' },
118
+ id: ref_page.id,
119
+ answer_sheet_id: reference_sheet.id,
120
+ answer_sheet_type: 'Fe::ReferenceSheet',
121
+ a: reference_sheet.access_key
122
+ }, xhr: true
75
123
 
124
+ expect(response).to render_template('fe/answer_pages/update')
125
+ reference_sheet.reload
126
+ expect(reference_sheet.email).to eq('other@email.com')
127
+ # make sure the access key isn't reset
128
+ expect(reference_sheet.access_key).to eq(key_before)
129
+ end
130
+ end
131
+ end
76
132
  end