upgrade_surveyor_gui 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +44 -0
  3. data/.travis.yml +17 -0
  4. data/CHANGELOG.md +46 -0
  5. data/Gemfile +8 -0
  6. data/LICENSE +21 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +244 -0
  9. data/Rakefile +66 -0
  10. data/app/controllers/surveyor_controller.rb +89 -0
  11. data/app/controllers/surveyor_gui/answers_controller.rb +3 -0
  12. data/app/controllers/surveyor_gui/application_controller.rb +3 -0
  13. data/app/controllers/surveyor_gui/dependencys_controller.rb +286 -0
  14. data/app/controllers/surveyor_gui/question_groups_controller.rb +90 -0
  15. data/app/controllers/surveyor_gui/questions_controller.rb +187 -0
  16. data/app/controllers/surveyor_gui/reports_controller.rb +339 -0
  17. data/app/controllers/surveyor_gui/responses_controller.rb +41 -0
  18. data/app/controllers/surveyor_gui/survey_controller.rb +16 -0
  19. data/app/controllers/surveyor_gui/survey_sections_controller.rb +80 -0
  20. data/app/controllers/surveyor_gui/surveyforms_controller.rb +4 -0
  21. data/app/facades/report_formatter.rb +46 -0
  22. data/app/facades/report_preview_wrapper.rb +11 -0
  23. data/app/facades/report_response_generator.rb +147 -0
  24. data/app/helpers/surveyor_gui/application_helper.rb +2 -0
  25. data/app/helpers/surveyor_gui/dependencys_helper.rb +5 -0
  26. data/app/helpers/surveyor_gui/question_groups_helper.rb +3 -0
  27. data/app/helpers/surveyor_gui/questions_helper.rb +22 -0
  28. data/app/helpers/surveyor_gui/reports_helper.rb +19 -0
  29. data/app/helpers/surveyor_gui/surveyforms_helper.rb +164 -0
  30. data/app/helpers/surveyor_helper.rb +4 -0
  31. data/app/inputs/currency_input.rb +5 -0
  32. data/app/inputs/date_picker_input.rb +7 -0
  33. data/app/inputs/datetime_picker_input.rb +5 -0
  34. data/app/inputs/percent_input.rb +5 -0
  35. data/app/inputs/time_picker_input.rb +5 -0
  36. data/app/mailers/.gitkeep +0 -0
  37. data/app/models/.gitkeep +0 -0
  38. data/app/models/answer.rb +4 -0
  39. data/app/models/column.rb +3 -0
  40. data/app/models/dependency.rb +4 -0
  41. data/app/models/dependency_condition.rb +4 -0
  42. data/app/models/permitted_params_decorator.rb +80 -0
  43. data/app/models/question.rb +4 -0
  44. data/app/models/question_group.rb +4 -0
  45. data/app/models/question_group_tracker.rb +19 -0
  46. data/app/models/question_type.rb +7 -0
  47. data/app/models/response.rb +4 -0
  48. data/app/models/response_set.rb +4 -0
  49. data/app/models/row.rb +3 -0
  50. data/app/models/survey.rb +4 -0
  51. data/app/models/survey_section.rb +4 -0
  52. data/app/models/surveyform.rb +103 -0
  53. data/app/uploaders/blob_uploader.rb +48 -0
  54. data/app/views/layouts/surveyor_gui/application.html.erb +14 -0
  55. data/app/views/layouts/surveyor_gui/surveyor_gui_blank.html.erb +13 -0
  56. data/app/views/layouts/surveyor_gui/surveyor_gui_default.html.erb +17 -0
  57. data/app/views/layouts/surveyor_gui/surveyor_modified.html.erb +14 -0
  58. data/app/views/partials/_answer.html.haml +33 -0
  59. data/app/views/partials/_question.html.haml +33 -0
  60. data/app/views/partials/_question_group.html.haml +73 -0
  61. data/app/views/partials/_section.html.haml +13 -0
  62. data/app/views/surveyor/edit.html.haml +21 -0
  63. data/app/views/surveyor_gui/dependencys/_column.html.erb +1 -0
  64. data/app/views/surveyor_gui/dependencys/_dependency.html.erb +22 -0
  65. data/app/views/surveyor_gui/dependencys/_dependency_condition_fields.html.erb +48 -0
  66. data/app/views/surveyor_gui/dependencys/_form.html.erb +20 -0
  67. data/app/views/surveyor_gui/dependencys/blank.html.erb +0 -0
  68. data/app/views/surveyor_gui/dependencys/edit.html.erb +1 -0
  69. data/app/views/surveyor_gui/dependencys/new.html.erb +1 -0
  70. data/app/views/surveyor_gui/partials/_url_helpers.html.erb +5 -0
  71. data/app/views/surveyor_gui/question_groups/_form.html.erb +57 -0
  72. data/app/views/surveyor_gui/question_groups/_group_inline_field.html.erb +21 -0
  73. data/app/views/surveyor_gui/question_groups/_group_inline_fields.html.erb +25 -0
  74. data/app/views/surveyor_gui/question_groups/blank.html.erb +0 -0
  75. data/app/views/surveyor_gui/question_groups/edit.html.erb +1 -0
  76. data/app/views/surveyor_gui/question_groups/new.html.erb +1 -0
  77. data/app/views/surveyor_gui/questions/_answer_fields.html.erb +23 -0
  78. data/app/views/surveyor_gui/questions/_answer_options.html.erb +28 -0
  79. data/app/views/surveyor_gui/questions/_form.html.erb +66 -0
  80. data/app/views/surveyor_gui/questions/_grid_dropdown_columns.html.erb +10 -0
  81. data/app/views/surveyor_gui/questions/_grid_dropdown_fields.html.erb +42 -0
  82. data/app/views/surveyor_gui/questions/_grid_fields.html.erb +9 -0
  83. data/app/views/surveyor_gui/questions/_no_picks.html.erb +29 -0
  84. data/app/views/surveyor_gui/questions/_pick.html +21 -0
  85. data/app/views/surveyor_gui/questions/_picks.html.erb +12 -0
  86. data/app/views/surveyor_gui/questions/blank.html.erb +0 -0
  87. data/app/views/surveyor_gui/questions/edit.html.erb +1 -0
  88. data/app/views/surveyor_gui/questions/new.html.erb +1 -0
  89. data/app/views/surveyor_gui/reports/_graphs.html.haml +21 -0
  90. data/app/views/surveyor_gui/reports/_grid.html.haml +42 -0
  91. data/app/views/surveyor_gui/reports/_grid_dropdown.html.haml +56 -0
  92. data/app/views/surveyor_gui/reports/_repeater.html.haml +27 -0
  93. data/app/views/surveyor_gui/reports/_show_report.html.haml +33 -0
  94. data/app/views/surveyor_gui/reports/_single_question.html.haml +70 -0
  95. data/app/views/surveyor_gui/reports/show.html.erb +14 -0
  96. data/app/views/surveyor_gui/responses/_grid.html.haml +20 -0
  97. data/app/views/surveyor_gui/responses/_grid_dropdown.html.haml +20 -0
  98. data/app/views/surveyor_gui/responses/_repeater.html.haml +22 -0
  99. data/app/views/surveyor_gui/responses/_survey_results.html.haml +40 -0
  100. data/app/views/surveyor_gui/responses/index.html.haml +24 -0
  101. data/app/views/surveyor_gui/responses/show.html.haml +42 -0
  102. data/app/views/surveyor_gui/shared/_grid_comments.html.haml +10 -0
  103. data/app/views/surveyor_gui/shared/_new_line.html.haml +2 -0
  104. data/app/views/surveyor_gui/shared/_pick_comments.html.haml +15 -0
  105. data/app/views/surveyor_gui/shared/_question_number.html.haml +11 -0
  106. data/app/views/surveyor_gui/shared/_report_data.html.haml +27 -0
  107. data/app/views/surveyor_gui/shared/_stars_report_data.html.haml +14 -0
  108. data/app/views/surveyor_gui/survey_sections/_form.html.erb +13 -0
  109. data/app/views/surveyor_gui/survey_sections/blank.html.erb +0 -0
  110. data/app/views/surveyor_gui/survey_sections/edit.html.erb +1 -0
  111. data/app/views/surveyor_gui/survey_sections/new.html.erb +1 -0
  112. data/app/views/surveyor_gui/surveyforms/_form.html.erb +50 -0
  113. data/app/views/surveyor_gui/surveyforms/_question_field.html.erb +148 -0
  114. data/app/views/surveyor_gui/surveyforms/_question_group.html.erb +116 -0
  115. data/app/views/surveyor_gui/surveyforms/_question_group_fields.html.erb +3 -0
  116. data/app/views/surveyor_gui/surveyforms/_question_name_and_number.html.erb +6 -0
  117. data/app/views/surveyor_gui/surveyforms/_question_section.html.erb +15 -0
  118. data/app/views/surveyor_gui/surveyforms/_question_wrapper.html.erb +108 -0
  119. data/app/views/surveyor_gui/surveyforms/_survey_section_fields.html.erb +137 -0
  120. data/app/views/surveyor_gui/surveyforms/clone_survey.html.erb +13 -0
  121. data/app/views/surveyor_gui/surveyforms/edit.html.erb +5 -0
  122. data/app/views/surveyor_gui/surveyforms/index.html.erb +40 -0
  123. data/app/views/surveyor_gui/surveyforms/new.html.erb +1 -0
  124. data/app/views/surveyor_gui/surveyforms/show.html.erb +5 -0
  125. data/config/environment.rb +0 -0
  126. data/config/routes.rb +71 -0
  127. data/config.ru +4 -0
  128. data/db/migrate/20140307204049_add_template_to_surveys.rb +5 -0
  129. data/db/migrate/20140307235607_add_test_data_to_response_sets.rb +5 -0
  130. data/db/migrate/20140308171947_add_original_choice_to_answers.rb +5 -0
  131. data/db/migrate/20140308172118_add_blob_to_responses.rb +5 -0
  132. data/db/migrate/20140308172417_add_modifiable_to_survey_section.rb +5 -0
  133. data/db/migrate/20140308174532_add_modifiable_to_question.rb +5 -0
  134. data/db/migrate/20140308175305_add_dynamically_generate_to_questions.rb +5 -0
  135. data/db/migrate/20140311032923_add_dummy_blob_to_questions.rb +5 -0
  136. data/db/migrate/20140311160609_add_dynamic_source_to_questions.rb +5 -0
  137. data/db/migrate/20140311161714_add_report_code_to_questions.rb +5 -0
  138. data/db/migrate/20140530181134_add_is_comment_to_questions.rb +5 -0
  139. data/db/migrate/20140531012006_add_is_comment_to_answers.rb +5 -0
  140. data/db/migrate/20140531225529_create_rows.rb +9 -0
  141. data/db/migrate/20140601011151_create_columns.rb +11 -0
  142. data/db/migrate/20140602030330_add_column_id_to_answers.rb +5 -0
  143. data/db/migrate/20140603155606_add_column_id_to_responses.rb +5 -0
  144. data/db/migrate/20140606023527_add_column_id_to_dependency_conditions.rb +5 -0
  145. data/db/migrate/20140815165307_add_user_id_to_survey.rb +5 -0
  146. data/lib/assets/.gitkeep +0 -0
  147. data/lib/assets/images/addicon.png +0 -0
  148. data/lib/assets/images/datepicker.gif +0 -0
  149. data/lib/assets/images/delete.gif +0 -0
  150. data/lib/assets/images/delete.png +0 -0
  151. data/lib/assets/images/images/border.png +0 -0
  152. data/lib/assets/images/images/controls.png +0 -0
  153. data/lib/assets/images/images/loading.gif +0 -0
  154. data/lib/assets/images/images/loading_background.png +0 -0
  155. data/lib/assets/images/images/overlay.png +0 -0
  156. data/lib/assets/images/rails.png +0 -0
  157. data/lib/assets/images/star.gif +0 -0
  158. data/lib/assets/javascripts/.gitkeep +0 -0
  159. data/lib/assets/javascripts/surveyor_gui/jquery.MetaData.js +121 -0
  160. data/lib/assets/javascripts/surveyor_gui/jquery.blockUI.js +619 -0
  161. data/lib/assets/javascripts/surveyor_gui/jquery.rating.js +377 -0
  162. data/lib/assets/javascripts/surveyor_gui/jquery.validate.js +1188 -0
  163. data/lib/assets/javascripts/surveyor_gui/surveyor_add_ons.js +10 -0
  164. data/lib/assets/javascripts/surveyor_gui/surveyor_gui.js +1428 -0
  165. data/lib/assets/stylesheets/.gitkeep +0 -0
  166. data/lib/assets/stylesheets/surveyor_gui/jquery.rating.css +12 -0
  167. data/lib/assets/stylesheets/surveyor_gui/surveyor_add_ons.css +3 -0
  168. data/lib/assets/stylesheets/surveyor_gui/surveyor_gui.sass +652 -0
  169. data/lib/enumerable_extenders.rb +31 -0
  170. data/lib/generators/surveyor_gui/install_generator.rb +57 -0
  171. data/lib/generators/surveyor_gui/templates/app/assets/javascripts/surveyor_add_ons.js +2 -0
  172. data/lib/generators/surveyor_gui/templates/app/assets/javascripts/surveyor_gui_all.js +24 -0
  173. data/lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_add_ons.css.sass +1 -0
  174. data/lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_gui_all.css.sass +8 -0
  175. data/lib/generators/surveyor_gui/templates/app/helpers/surveyor_helper.rb +4 -0
  176. data/lib/generators/surveyor_gui/templates/app/models/response_set_user.rb +13 -0
  177. data/lib/generators/surveyor_gui/templates/app/views/layouts/surveyor_gui/surveyor_gui_default.html.erb +17 -0
  178. data/lib/generators/surveyor_gui/templates/config/initializers/simple_form.rb +140 -0
  179. data/lib/generators/surveyor_gui/templates/config/locales/en.yml +5 -0
  180. data/lib/surveyor_gui/engine.rb +31 -0
  181. data/lib/surveyor_gui/helpers/surveyor_helper_methods.rb +19 -0
  182. data/lib/surveyor_gui/models/answer_methods.rb +24 -0
  183. data/lib/surveyor_gui/models/column_methods.rb +43 -0
  184. data/lib/surveyor_gui/models/dependency_condition_methods.rb +53 -0
  185. data/lib/surveyor_gui/models/dependency_methods.rb +83 -0
  186. data/lib/surveyor_gui/models/question_and_group_shared_methods.rb +11 -0
  187. data/lib/surveyor_gui/models/question_group_methods.rb +55 -0
  188. data/lib/surveyor_gui/models/question_methods.rb +435 -0
  189. data/lib/surveyor_gui/models/question_type_methods.rb +493 -0
  190. data/lib/surveyor_gui/models/response_methods.rb +71 -0
  191. data/lib/surveyor_gui/models/response_set_methods.rb +56 -0
  192. data/lib/surveyor_gui/models/row_methods.rb +11 -0
  193. data/lib/surveyor_gui/models/survey_methods.rb +32 -0
  194. data/lib/surveyor_gui/models/survey_section_methods.rb +32 -0
  195. data/lib/surveyor_gui/surveyforms_controller_methods.rb +258 -0
  196. data/lib/surveyor_gui/version.rb +3 -0
  197. data/lib/surveyor_gui.rb +17 -0
  198. data/lib/tasks/.gitkeep +0 -0
  199. data/lib/tasks/surveyor_gui_tasks.rake +4 -0
  200. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  201. data/spec/controllers/surveyforms_controller_spec.rb +362 -0
  202. data/spec/controllers/surveyor_controller_spec.rb +303 -0
  203. data/spec/factories.rb +181 -0
  204. data/spec/features/create_survey_spec.rb +417 -0
  205. data/spec/features/dependencies_spec.rb +65 -0
  206. data/spec/features/make_and_take_spec.rb +187 -0
  207. data/spec/features/rearrange_survey_spec.rb +118 -0
  208. data/spec/features/ui_spec.rb +469 -0
  209. data/spec/fixtures/REDCapDemoDatabase_DataDictionary.csv +127 -0
  210. data/spec/fixtures/chinese_survey.rb +14 -0
  211. data/spec/fixtures/everything.rb +215 -0
  212. data/spec/fixtures/favorites-ish.rb +22 -0
  213. data/spec/fixtures/favorites.rb +22 -0
  214. data/spec/fixtures/feelings.rb +38 -0
  215. data/spec/fixtures/lifestyle.rb +55 -0
  216. data/spec/fixtures/numbers.rb +21 -0
  217. data/spec/fixtures/redcap_new_headers.csv +1 -0
  218. data/spec/fixtures/redcap_siblings.csv +1 -0
  219. data/spec/fixtures/redcap_whitespace.csv +1 -0
  220. data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
  221. data/spec/helpers/surveyor_helper_spec.rb +116 -0
  222. data/spec/lib/common_spec.rb +37 -0
  223. data/spec/lib/parser_spec.rb +393 -0
  224. data/spec/lib/rake_kitchen_sink.rb +42 -0
  225. data/spec/lib/redcap_parser_spec.rb +129 -0
  226. data/spec/lib/unparser_spec.rb +126 -0
  227. data/spec/models/answer_spec.rb +144 -0
  228. data/spec/models/dependency_condition_spec.rb +428 -0
  229. data/spec/models/dependency_spec.rb +90 -0
  230. data/spec/models/question_group_spec.rb +66 -0
  231. data/spec/models/question_spec.rb +176 -0
  232. data/spec/models/response_set_spec.rb +452 -0
  233. data/spec/models/response_spec.rb +208 -0
  234. data/spec/models/survey_section_spec.rb +58 -0
  235. data/spec/models/survey_spec.rb +155 -0
  236. data/spec/models/surveyor_gui/question_spec.rb +60 -0
  237. data/spec/models/surveyor_gui/question_type_spec.rb +268 -0
  238. data/spec/models/validation_condition_spec.rb +98 -0
  239. data/spec/models/validation_spec.rb +64 -0
  240. data/spec/spec.opts +4 -0
  241. data/spec/spec_helper.rb +119 -0
  242. data/spec/support/scenario_outline_helper.rb +39 -0
  243. data/spec/support/shared.rb +10 -0
  244. data/spec/support/surveyforms_creation_helpers.rb +313 -0
  245. data/spec/support/surveyforms_rearrangement_helpers.rb +170 -0
  246. data/spec/support/surveyor_api_helpers.rb +15 -0
  247. data/spec/support/surveyor_ui_helpers.rb +108 -0
  248. data/spec/support/wait_for_ajax.rb +11 -0
  249. data/spec/views/questions/edit.html.erb_spec.rb +74 -0
  250. data/spec/views/surveyforms/edit.html.erb_spec.rb +126 -0
  251. data/surveyor_gui.gemspec +52 -0
  252. data/test/dummy/README.rdoc +261 -0
  253. data/test/dummy/Rakefile +7 -0
  254. data/test/dummy/app/assets/javascripts/application.js +15 -0
  255. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  256. data/test/dummy/app/controllers/application_controller.rb +3 -0
  257. data/test/dummy/app/helpers/application_helper.rb +2 -0
  258. data/test/dummy/app/mailers/.gitkeep +0 -0
  259. data/test/dummy/app/models/.gitkeep +0 -0
  260. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  261. data/test/dummy/config/application.rb +59 -0
  262. data/test/dummy/config/boot.rb +10 -0
  263. data/test/dummy/config/database.yml +25 -0
  264. data/test/dummy/config/environment.rb +5 -0
  265. data/test/dummy/config/environments/development.rb +37 -0
  266. data/test/dummy/config/environments/production.rb +67 -0
  267. data/test/dummy/config/environments/test.rb +37 -0
  268. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  269. data/test/dummy/config/initializers/inflections.rb +15 -0
  270. data/test/dummy/config/initializers/mime_types.rb +5 -0
  271. data/test/dummy/config/initializers/secret_token.rb +7 -0
  272. data/test/dummy/config/initializers/session_store.rb +8 -0
  273. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  274. data/test/dummy/config/locales/en.yml +5 -0
  275. data/test/dummy/config/routes.rb +58 -0
  276. data/test/dummy/config.ru +4 -0
  277. data/test/dummy/lib/assets/.gitkeep +0 -0
  278. data/test/dummy/log/.gitkeep +0 -0
  279. data/test/dummy/public/404.html +26 -0
  280. data/test/dummy/public/422.html +26 -0
  281. data/test/dummy/public/500.html +25 -0
  282. data/test/dummy/public/favicon.ico +0 -0
  283. data/test/dummy/script/rails +6 -0
  284. data/test/surveyor-gui_test.rb +7 -0
  285. data/test/test_helper.rb +15 -0
  286. data/tmp/cache/assets/CF0/DA0/sprockets%2Fd7d5b37686831d37c4dd75e645f5e016 +0 -0
  287. data/tmp/cache/assets/E25/4C0/sprockets%2Fde2fd9fd11c04a582cdbbe3d84a35ae6 +0 -0
  288. data/vendor/assets/stylesheets/.gitkeep +0 -0
  289. data/vendor/assets/stylesheets/custom.sass +5 -0
  290. data/vendor/plugins/.gitkeep +0 -0
  291. metadata +600 -0
data/spec/factories.rb ADDED
@@ -0,0 +1,181 @@
1
+ # encoding: utf-8
2
+ # http://github.com/thoughtbot/factory_girl/tree/master
3
+ require 'rubygems'
4
+ require 'factory_girl'
5
+
6
+ FactoryGirl.define do
7
+ sequence(:unique_survey_access_code){|n| "simple survey #{UUIDTools::UUID.random_create.to_s}" }
8
+
9
+ factory :survey do |s|
10
+ s.title "Simple survey"
11
+ s.description "A simple survey for testing"
12
+ s.access_code { FactoryGirl.generate :unique_survey_access_code }
13
+ s.survey_version 0
14
+ end
15
+
16
+ factory :surveyform do |s|
17
+ s.title "Simple survey"
18
+ s.description "A simple survey for testing"
19
+ s.access_code { FactoryGirl.generate :unique_survey_access_code }
20
+ s.survey_version 0
21
+ end
22
+
23
+ factory :template, parent: :surveyform do |s|
24
+ s.template true
25
+ end
26
+
27
+ factory :survey_translation do |t|
28
+ t.locale "es"
29
+ t.translation %(title: "Un idioma nunca es suficiente"
30
+ survey_sections:
31
+ one:
32
+ title: "Uno"
33
+ questions:
34
+ hello:
35
+ text: "¡Hola!"
36
+ name:
37
+ text: "¿Cómo se llama Usted?"
38
+ answers:
39
+ name:
40
+ help_text: "Mi nombre es...")
41
+ end
42
+
43
+ sequence(:survey_section_display_order){|n| n }
44
+
45
+ factory :survey_section do |s|
46
+ s.association :survey # s.survey_id {}
47
+ s.title {"Demographics"}
48
+ s.description {"Asking you about your personal data"}
49
+ s.display_order {FactoryGirl.generate :survey_section_display_order}
50
+ s.reference_identifier {"demographics"}
51
+ s.data_export_identifier {"demographics"}
52
+ end
53
+
54
+ sequence(:question_display_order){|n| n }
55
+
56
+ factory :question do |q|
57
+ q.association :survey_section # s.survey_section_id {}
58
+ # q.question_group_id {}
59
+ q.text "What is your favorite color?"
60
+ q.short_text "favorite_color"
61
+ q.help_text "just write it in the box"
62
+ q.pick :none
63
+ q.reference_identifier {|me| "q_#{me.object_id}"}
64
+ # q.data_export_identifier {}
65
+ # q.common_namespace {}
66
+ # q.common_identifier {}
67
+ q.display_order {FactoryGirl.generate :question_display_order}
68
+ # q.display_type {} # nil is default
69
+ q.is_mandatory false
70
+ # q.display_width {}
71
+ q.correct_answer_id nil
72
+ end
73
+
74
+ factory :question_group do |g|
75
+ g.text {"Describe your family"}
76
+ g.help_text {}
77
+ g.reference_identifier {|me| "g_#{me.object_id}"}
78
+ g.data_export_identifier {}
79
+ g.common_namespace {}
80
+ g.common_identifier {}
81
+ g.display_type {}
82
+ g.custom_class {}
83
+ g.custom_renderer {}
84
+ end
85
+
86
+ sequence(:answer_display_order){|n| n }
87
+
88
+ factory :answer do |a|
89
+ a.association :question # a.question_id {}
90
+ a.text "My favorite color is clear"
91
+ a.short_text "clear"
92
+ a.help_text "Clear is the absense of color"
93
+ # a.weight
94
+ a.response_class "string"
95
+ # a.reference_identifier {}
96
+ # a.data_export_identifier {}
97
+ # a.common_namespace {}
98
+ # a.common_identifier {}
99
+ a.display_order {FactoryGirl.generate :answer_display_order}
100
+ # a.is_exclusive {}
101
+ a.display_type "default"
102
+ # a.display_length {}
103
+ # a.custom_class {}
104
+ # a.custom_renderer {}
105
+ end
106
+
107
+ factory :dependency do |d|
108
+ # the dependent question
109
+ d.association :question # d.question_id {}
110
+ d.question_group_id {}
111
+ d.rule {"A"}
112
+ end
113
+
114
+ factory :dependency_condition do |d|
115
+ d.association :dependency # d.dependency_id {}
116
+ d.rule_key {"A"}
117
+ # the conditional question
118
+ d.question_id {}
119
+ d.operator {"=="}
120
+ d.answer_id {}
121
+ d.datetime_value {}
122
+ d.integer_value {}
123
+ d.float_value {}
124
+ d.unit {}
125
+ d.text_value {}
126
+ d.string_value {}
127
+ d.response_other {}
128
+ end
129
+
130
+ factory :response_set do |r|
131
+ r.user_id {}
132
+ r.association :survey # r.survey_id {}
133
+ r.access_code {Surveyor::Common.make_tiny_code}
134
+ r.started_at {Time.now}
135
+ r.completed_at {}
136
+ r.test_data {false}
137
+ end
138
+
139
+ factory :response do |r|
140
+ r.association :response_set # r.response_set_id {}
141
+ r.survey_section_id {}
142
+ r.question_id {}
143
+ r.answer_id {}
144
+ r.datetime_value {}
145
+ r.integer_value {}
146
+ r.float_value {}
147
+ r.unit {}
148
+ r.text_value {}
149
+ r.string_value {}
150
+ r.response_other {}
151
+ r.response_group {}
152
+ end
153
+
154
+ factory :validation do |v|
155
+ v.association :answer # v.answer_id {}
156
+ v.rule {"A"}
157
+ v.message {}
158
+ end
159
+
160
+ factory :validation_condition do |v|
161
+ v.association :validation # v.validation_id {}
162
+ v.rule_key {"A"}
163
+ v.question_id {}
164
+ v.operator {"=="}
165
+ v.answer_id {}
166
+ v.datetime_value {}
167
+ v.integer_value {}
168
+ v.float_value {}
169
+ v.unit {}
170
+ v.text_value {}
171
+ v.string_value {}
172
+ v.response_other {}
173
+ v.regexp {}
174
+ end
175
+
176
+ factory :column do |c|
177
+ c.association :question_group
178
+ c.text {}
179
+ c.answers_textbox {}
180
+ end
181
+ end
@@ -0,0 +1,417 @@
1
+ require 'spec_helper'
2
+
3
+ #from spec/support/surveyforms_helpers.rb
4
+ include SurveyFormsCreationHelpers::CreateSurvey
5
+ include SurveyFormsCreationHelpers::BuildASurvey
6
+
7
+ feature "User creates a new survey using a browser", %q{
8
+ As a user
9
+ I want to create a new survey using a browser
10
+ So that I don't have to learn the Surveyor DSL or dive into technical weeds} do
11
+ #force a cr/lf to make the output look better
12
+ scenario " " do
13
+ end
14
+
15
+ context "User has not yet started a new survey" do
16
+ scenario "User starts a new survey" do
17
+ #Given I'm on the surveyform web page
18
+ visit surveyor_gui.surveyforms_path
19
+
20
+ #When I click "New Survey"
21
+ click_link "New Survey"
22
+
23
+ #Then I see the "Create New Survey" page
24
+ expect(page).to have_content("Create New Survey")
25
+ end
26
+
27
+ scenario "User gives the survey a title" do
28
+ #Given I'm on the "Create New Survey" page
29
+ visit surveyor_gui.new_surveyform_path
30
+
31
+ #When I fill in a title
32
+ fill_in "Title", with: "How was Boston?"
33
+
34
+ #And I save the survey
35
+ click_button "Save Changes"
36
+
37
+ #Then I can start entering more details, like sections
38
+ expect(page).to have_button "Add Section"
39
+
40
+ #And questions
41
+ expect(page).to have_button "Add Question"
42
+ end
43
+ end
44
+
45
+ context "User started a new survey" do
46
+ before :each do
47
+ start_a_new_survey
48
+ end
49
+
50
+ scenario "User gives the section a title", :js=>true do
51
+ #Given I've started a new survey
52
+ #When I click the "Edit Section Title" button
53
+ click_button "Edit Section Title"
54
+
55
+ #Then I see a window pop-up
56
+ expect(page).to have_css('iframe')
57
+ within_frame 0 do
58
+
59
+ #And I see a new form for "Edit Survey Section"
60
+ find('form')
61
+ expect(find('h1')).to have_content("Edit Survey Section")
62
+
63
+ #And I enter a title
64
+ fill_in "Title", with: "Accommodations"
65
+
66
+ #And I save the title
67
+ click_button "Save Changes"
68
+
69
+ #Then the window goes away
70
+ end
71
+
72
+ #And I can see the correctly titled section in my survey
73
+ expect(first_section_title).to have_content("Accommodations")
74
+ end
75
+
76
+ scenario "User adds a text question", :js=>true do
77
+ #Given I've started a new survey
78
+ #When I click the "Add Question" button
79
+ click_button "Add Question"
80
+
81
+ #Then I see a window pop-up
82
+ expect(page).to have_css('iframe')
83
+ within_frame 0 do
84
+
85
+ #And I see a new form for "Add Question"
86
+ find('form')
87
+ expect(find('h1')).to have_content("Add Question")
88
+
89
+ #And I frame the question
90
+ fill_in "question_text", with: "Where did you stay?"
91
+
92
+ #And I select the "text" question type
93
+ select_question_type "Text"
94
+
95
+ #And I save the question
96
+ click_button "Save Changes"
97
+
98
+ #Then the window goes away
99
+ end
100
+
101
+ #And I can see the question in my survey
102
+ expect(first_question).to have_content("1) Where did you stay?")
103
+ expect(page).to have_css("input[type='text']")
104
+ end
105
+
106
+ context "User adds questions of each type to the survey" do
107
+ before :each do
108
+ start_a_new_survey
109
+ end
110
+ scenario "User adds a number question", :js=>true do
111
+ #Given I've added a new question
112
+ add_question do
113
+
114
+ #Then I select the "number" question type
115
+ select_question_type "Number"
116
+
117
+ #And I frame the question
118
+ fill_in "question_text", with: "How many days did you stay?"
119
+
120
+ #And I add the suffix, "Stayed"
121
+ fill_in "question_prefix", with: "Stayed"
122
+
123
+ #And I add the suffix, "days"
124
+ fill_in "question_suffix", with: "days at hotel"
125
+
126
+ #And I sav the question
127
+ click_button "Save Changes"
128
+
129
+ #Then the window goes away
130
+ end
131
+
132
+ #And I can see the question in my survey
133
+ expect(first_question).to have_content("1) How many days did you stay?")
134
+ expect(page).to have_css("input[type='text']")
135
+ expect(page).to have_content(/Stayed.*days at hotel/)
136
+ end
137
+
138
+
139
+ scenario "User adds a multiple choice question", :js=>true do
140
+ #Given I've added a new question
141
+ add_question do
142
+
143
+ #Then I select the "multiple choice" question type
144
+ select_question_type "Multiple Choice (only one answer)"
145
+
146
+ #And I frame the question
147
+ fill_in "question_text", with: "What type of room did you get?"
148
+
149
+ #And I add some choices"
150
+ fill_in "question_answers_textbox", with: """Deluxe King
151
+ Standard Queen
152
+ Standard Double"""
153
+
154
+ #And I save the question
155
+ click_button "Save Changes"
156
+
157
+ #Then the window goes away
158
+ end
159
+
160
+ #And I can see the question in my survey
161
+ expect(first_question).to have_content("1) What type of room did you get?")
162
+ expect(page).to have_css("input[type='radio'][value='Deluxe King']")
163
+ expect(page).to have_css("input[type='radio'][value='Standard Queen']")
164
+ expect(page).to have_css("input[type='radio'][value='Standard Double']")
165
+ end
166
+
167
+
168
+ scenario "User adds a choose any question", :js=>true do
169
+ #Given I've added a new question
170
+ add_question do
171
+
172
+ #Then I select the "multiple choice, multiple answers" question type
173
+ select_question_type "Multiple Choice (multiple answers)"
174
+
175
+ #And I frame the question
176
+ fill_in "question_text", with: "What did you order from the minibar?"
177
+
178
+ #And I add some choices"
179
+ fill_in "question_answers_textbox", with: """Bottled Water
180
+ Kit Kats
181
+ Scotch"""
182
+
183
+ #And I save the question
184
+ click_button "Save Changes"
185
+
186
+ #Then the window goes away
187
+ end
188
+
189
+ #And I can see the question in my survey
190
+ expect(first_question).to have_content("1) What did you order from the minibar?")
191
+ expect(page).to have_css("input[type='checkbox'][value='Bottled Water']")
192
+ expect(page).to have_css("input[type='checkbox'][value='Kit Kats']")
193
+ expect(page).to have_css("input[type='checkbox'][value='Scotch']")
194
+ end
195
+
196
+
197
+ scenario "User adds a dropdown list", :js=>true do
198
+ #Given I've added a new question
199
+ add_question do
200
+
201
+ #Then I select the "Dropdown" question type
202
+ select_question_type "Dropdown List"
203
+
204
+ #And I frame the question
205
+ fill_in "question_text", with: "1) What neighborhood were you in?"
206
+
207
+ #And I add some choices"
208
+ fill_in "question_answers_textbox", with: """ Financial District
209
+ Back Bay
210
+ North End"""
211
+
212
+ #And I save the question
213
+ click_button "Save Changes"
214
+
215
+ #Then the window goes away
216
+ end
217
+
218
+ #And I can see the question in my survey
219
+ expect(first_question).to have_content("1) What neighborhood were you in?")
220
+ expect(page).to have_css("option[value='Financial District']")
221
+ expect(page).to have_css("option[value='Back Bay']")
222
+ expect(page).to have_css("option[value='North End']")
223
+ end
224
+
225
+
226
+ scenario "User adds a date question", :js=>true do
227
+ #Given I've added a new question
228
+ add_question do
229
+
230
+ #Then I select the "Date" question type
231
+ select_question_type "Date"
232
+
233
+ #And I frame the question
234
+ fill_in "question_text", with: "When did you checkout?"
235
+
236
+ #And I save the question
237
+ click_button "Save Changes"
238
+
239
+ #Then the window goes away
240
+ end
241
+
242
+ #And I can see the question in my survey
243
+ expect(first_question).to have_content("1) When did you checkout?")
244
+ expect(page).to have_css("div.ui-datepicker",:visible=>false)
245
+
246
+ #Then I click on the question
247
+ 1.times {page.execute_script "$('input.date_picker').trigger('focus')"}
248
+
249
+ #And I see a datepicker popup
250
+ expect(page).to have_css("div.ui-datepicker", :visible=>true)
251
+ end
252
+
253
+ scenario "User adds a label", :js=>true do
254
+ #Given I've added a new question
255
+ add_question do
256
+
257
+ #Then I select the "Label" question type
258
+ select_question_type "Label"
259
+
260
+ #And I frame the question
261
+ fill_in "question_text", with: "You don't need to answer the following questions if you are not comfortable."
262
+
263
+ #And I save the question
264
+ click_button "Save Changes"
265
+
266
+ #Then the window goes away
267
+ end
268
+
269
+ #And I can see the label in my survey and it has no question number
270
+ expect(page).to have_content(/(?<!1\)\s)You don't need to answer the following questions if you are not comfortable./)
271
+ end
272
+
273
+ scenario "User adds a text box question", :js=>true do
274
+ #Given I've added a new question
275
+ add_question do
276
+
277
+ #Then I select the "Text Box" question type
278
+ select_question_type "Text Box (for extended text, like notes, etc.)"
279
+
280
+ #And I frame the question
281
+ fill_in "question_text", with: "What did you think of the staff?"
282
+
283
+ #And I save the question
284
+ click_button "Save Changes"
285
+
286
+ #Then the window goes away
287
+ end
288
+
289
+ #And I can see the question in my survey
290
+ expect(first_question).to have_content("1) What did you think of the staff?")
291
+ expect(page).to have_css("textarea")
292
+ end
293
+
294
+ scenario "User adds a slider question", :js=>true do
295
+ #Given I've added a new question
296
+ add_question do
297
+
298
+ #Then I select the "Slider" question type
299
+ select_question_type "Slider"
300
+
301
+ #And I frame the question
302
+ fill_in "question_text", with: "What did you think of the food?"
303
+
304
+ #And I add some choices"
305
+ fill_in "question_answers_textbox", with: """Sucked!
306
+ Meh
307
+ Good
308
+ Wicked good!"""
309
+
310
+
311
+ #And I save the question
312
+ click_button "Save Changes"
313
+
314
+ #Then the window goes away
315
+ end
316
+
317
+ #And I can see the slider in my survey
318
+ expect(first_question).to have_content("1) What did you think of the food?")
319
+ expect(page).to have_css(".ui-slider")
320
+
321
+ #And I can see the text for both ends of the slider (but not the middle)
322
+ expect(page).to have_content("Sucked!")
323
+ expect(page).not_to have_content("Meh")
324
+ expect(page).not_to have_content("Good")
325
+ expect(page).to have_content("Wicked good!")
326
+ end
327
+
328
+ scenario "User adds a star question", :js=>true do
329
+ #Given I've added a new question
330
+ add_question do
331
+
332
+ #Then I select the "Star" question type
333
+ select_question_type "Star"
334
+
335
+ #And I frame the question
336
+ fill_in "question_text", with: "How would you rate your stay?"
337
+
338
+ #And I save the question
339
+ click_button "Save Changes"
340
+
341
+ #Then the window goes away
342
+ end
343
+
344
+ #And I can see the question in my survey
345
+ expect(first_question).to have_content("1) How would you rate your stay?")
346
+
347
+ #And I see stars!
348
+ expect(page).to have_css('div.star-rating a')
349
+ end
350
+
351
+
352
+ scenario "User includes a file upload in the survey", :js=>true do
353
+ #Given I've added a new question
354
+ add_question do
355
+ #Then I select the "Star" question type
356
+ select_question_type "File Upload"
357
+
358
+ #And I frame the question
359
+ fill_in "question_text", with: "Please upload a copy of your bill."
360
+
361
+ #And I save the question
362
+ click_button "Save Changes"
363
+
364
+ #Then the window goes away
365
+ end
366
+
367
+ #And I can see the question in my survey
368
+ expect(first_question).to have_content("1) Please upload a copy of your bill.")
369
+
370
+ #And I can browse my files
371
+ expect(page).to have_css("input[type='file']")
372
+ end
373
+
374
+ scenario "User adds a grid - pick one question", :js=>true do
375
+ #Given I've added a new question
376
+ add_question do
377
+
378
+ #And I frame the question
379
+ fill_in "question_text", with: "Rate the service:"
380
+
381
+ #Then I select the "Star" question type
382
+ select_question_type "Grid (pick one)"
383
+
384
+ #And I add columns to the grid
385
+ expect(page).to have_css("#question_grid_columns_textbox")
386
+ fill_in "question_grid_columns_textbox", with: "Poor\nOk\nGood\nOutstanding"
387
+
388
+ #And I add columns to the grid
389
+ fill_in "question_grid_rows_textbox", with: "Front Desk\nConcierge\nRoom Service\nValet"
390
+
391
+ #And I save the question
392
+ click_button "Save Changes"
393
+
394
+ #Then the window goes away
395
+ end
396
+
397
+ #And I can see the question in my survey
398
+ expect(first_question).to have_content("1) Rate the service:")
399
+
400
+ #And I see a nice grid of radio buttons
401
+ expect(page).to have_content(/1\) Rate the service.*Poor.*Ok.*Good.*Outstanding.*(?<!\d\)\s)Front Desk.*(?<!\d\)\s)Concierge.*(?<!\d\)\s)Room Service.*(?<!\d\)\s)Valet/m)
402
+
403
+ expect(page).to have_css("input[type='radio'][value='Poor']")
404
+ expect(page).to have_css("input[type='radio'][value='Ok']")
405
+ expect(page).to have_css("input[type='radio'][value='Good']")
406
+ expect(page).to have_css("input[type='radio'][value='Outstanding']")
407
+ end
408
+ end
409
+ end #end context "user has started a new survey"
410
+
411
+ scenario "User saves a survey with all the different question types", :js=>true do
412
+ build_a_survey
413
+ click_button "Save Changes"
414
+ expect(page).to have_content(/[Ss]uccessfully update/)
415
+ expect(page).to have_content("How was Boston?")
416
+ end
417
+ end #end feature