rapidfire 4.0.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +120 -96
  3. data/app/assets/config/manifest.js +3 -0
  4. data/app/controllers/rapidfire/application_controller.rb +6 -2
  5. data/app/controllers/rapidfire/attempts_controller.rb +2 -2
  6. data/app/controllers/rapidfire/questions_controller.rb +1 -1
  7. data/app/controllers/rapidfire/surveys_controller.rb +30 -13
  8. data/app/helpers/rapidfire/application_helper.rb +25 -0
  9. data/app/models/rapidfire/answer.rb +6 -1
  10. data/app/models/rapidfire/attempt.rb +1 -1
  11. data/app/models/rapidfire/question.rb +33 -3
  12. data/app/models/rapidfire/questions/checkbox.rb +1 -1
  13. data/app/models/rapidfire/questions/file.rb +6 -0
  14. data/app/models/rapidfire/questions/information.rb +6 -0
  15. data/app/models/rapidfire/questions/multi_file.rb +6 -0
  16. data/app/models/rapidfire/survey.rb +42 -2
  17. data/app/services/rapidfire/attempt_builder.rb +14 -2
  18. data/app/services/rapidfire/question_form.rb +5 -1
  19. data/app/services/rapidfire/survey_results.rb +38 -4
  20. data/app/views/rapidfire/answers/_checkbox.html.erb +1 -1
  21. data/app/views/rapidfire/answers/_date.html.erb +1 -1
  22. data/app/views/rapidfire/answers/_file.html.erb +5 -0
  23. data/app/views/rapidfire/answers/_information.html.erb +4 -0
  24. data/app/views/rapidfire/answers/_long.html.erb +1 -1
  25. data/app/views/rapidfire/answers/_multifile.html.erb +5 -0
  26. data/app/views/rapidfire/answers/_numeric.html.erb +1 -1
  27. data/app/views/rapidfire/answers/_radio.html.erb +1 -1
  28. data/app/views/rapidfire/answers/_select.html.erb +1 -1
  29. data/app/views/rapidfire/answers/_short.html.erb +1 -1
  30. data/app/views/rapidfire/attempts/_form.html.erb +1 -1
  31. data/app/views/rapidfire/attempts/edit.html.erb +1 -1
  32. data/app/views/rapidfire/attempts/new.html.erb +1 -1
  33. data/app/views/rapidfire/questions/_form.html.erb +1 -1
  34. data/app/views/rapidfire/surveys/_survey.html.erb +6 -0
  35. data/app/views/rapidfire/surveys/index.html.erb +7 -2
  36. data/app/views/rapidfire/surveys/results.html.erb +3 -1
  37. data/db/migrate/20190701274749_add_active_to_surveys.rb +12 -0
  38. data/lib/generators/rapidfire/active_survey_migration_generator.rb +18 -0
  39. data/lib/generators/rapidfire/templates/migrations/add_active_to_survey.rb +5 -0
  40. data/lib/rapidfire/version.rb +1 -1
  41. data/lib/tasks/change_delimiter_to_srsn.rake +1 -1
  42. data/lib/tasks/rapidfire.rake +10 -0
  43. data/spec/dummy/README.rdoc +1 -1
  44. data/spec/dummy/app/assets/config/mainfest.js +2 -0
  45. data/spec/dummy/app/models/application_record.rb +3 -0
  46. data/spec/dummy/app/models/user.rb +2 -0
  47. data/spec/dummy/app/views/layouts/application.html.erb +0 -2
  48. data/spec/dummy/config/application.rb +22 -3
  49. data/spec/dummy/config/environments/test.rb +5 -0
  50. data/spec/dummy/config/storage.yml +7 -0
  51. data/spec/dummy/db/migrate/20170701191422_create_users.rb +15 -0
  52. data/spec/dummy/db/migrate/20230402174122_create_active_storage_tables.active_storage.rb +67 -0
  53. data/spec/dummy/db/schema.rb +53 -17
  54. data/spec/dummy/db/test.sqlite3 +0 -0
  55. data/spec/dummy/log/test.log +76140 -14034
  56. data/spec/dummy/tmp/capybara/capybara-202304042341376066162578.html +29 -0
  57. data/spec/dummy/tmp/capybara/capybara-202304042343302647462912.html +29 -0
  58. data/spec/dummy/tmp/capybara/capybara-202304042343539524195351.html +29 -0
  59. data/spec/dummy/tmp/capybara/capybara-202304042344039569698410.html +29 -0
  60. data/spec/dummy/tmp/capybara/capybara-202304042344107081227684.html +29 -0
  61. data/spec/dummy/tmp/capybara/capybara-202304042346131668826835.html +29 -0
  62. data/spec/dummy/tmp/capybara/capybara-202304042346251478672095.html +29 -0
  63. data/spec/dummy/tmp/capybara/capybara-202304042346382011987550.html +29 -0
  64. data/spec/dummy/tmp/capybara/capybara-20230404234755589239852.html +29 -0
  65. data/spec/dummy/tmp/capybara/capybara-202304042348377947112508.html +29 -0
  66. data/spec/dummy/tmp/capybara/capybara-202304042348502970551073.html +55 -0
  67. data/spec/dummy/tmp/capybara/capybara-202304042351403473706214.html +29 -0
  68. data/spec/dummy/tmp/capybara/capybara-202304042352069122239363.html +29 -0
  69. data/spec/dummy/tmp/capybara/capybara-202304042353148433036065.html +29 -0
  70. data/spec/dummy/tmp/capybara/capybara-202304042353383278368450.html +29 -0
  71. data/spec/dummy/tmp/capybara/capybara-202304042358431743077504.html +20 -0
  72. data/spec/dummy/tmp/capybara/capybara-202304042358433434523512.html +20 -0
  73. data/spec/dummy/tmp/capybara/capybara-202304042358434379121493.html +20 -0
  74. data/spec/dummy/tmp/capybara/capybara-202304042358492996621343.html +20 -0
  75. data/spec/dummy/tmp/storage/2e/vk/2evksypp3ct4p9cjihfxwomru17i +1 -0
  76. data/spec/dummy/tmp/storage/9k/xt/9kxth5brdkw4huy7lciesekum0pt +1 -0
  77. data/spec/dummy/tmp/storage/cu/44/cu4452jrce4gd0ebcqop1d22kwbs +1 -0
  78. data/spec/dummy/tmp/storage/dl/oy/dloy0dbuquwe0f48bhugjca71pbv +1 -0
  79. data/spec/dummy/tmp/storage/h5/vc/h5vcb12f2cviqinrckfmmz4wtsa7 +1 -0
  80. data/spec/dummy/tmp/storage/ht/4x/ht4xma120asy3gd0fpeseddjzb2l +1 -0
  81. data/spec/dummy/tmp/storage/ip/au/ipauutuc5vy678hrwz4jx3rvm0n6 +1 -0
  82. data/spec/dummy/tmp/storage/j1/uy/j1uyrkrosby81sgq1mf59bs7oqee +1 -0
  83. data/spec/dummy/tmp/storage/nj/vv/njvvpx93zptrmlwbwiuxmxyh1jnf +1 -0
  84. data/spec/dummy/tmp/storage/nv/nx/nvnxlyvw3vd8xsq2sa4eazqepgbn +1 -0
  85. data/spec/dummy/tmp/storage/of/b4/ofb41sjj1mp33qs3wsivadhuts3p +1 -0
  86. data/spec/dummy/tmp/storage/og/ee/ogeerywp2y4szmnlrc5fnuya2evl +1 -0
  87. data/spec/dummy/tmp/storage/wz/oc/wzocvk4ahpp7kwc951u7f78nj259 +1 -0
  88. data/spec/dummy/tmp/storage/z3/vx/z3vxuitmnxld08m0qvt9057uyglc +1 -0
  89. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/1b/cx/1bcxhbuf0bwp8uduq76gye1v11al +1 -0
  90. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/40/x5/40x5xe5nmit9ngld2lngzfjp6r6x +1 -0
  91. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/7h/za/7hza4otjknyyo14szs2az8wiu7ai +1 -0
  92. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/ad/ct/adct5ysy5mq6kyptqk5q3fzfpwui +1 -0
  93. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/bl/yo/blyo13wkf0l9igpyq4anaqbomz0h +1 -0
  94. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/cc/g8/ccg8282dt6ixi4yvvwjt4noqa6pj +1 -0
  95. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/d3/gj/d3gjt0qoinigrbao1anp4hmvedjm +1 -0
  96. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/f2/bv/f2bvz6ws3xfrk17dpzhyacx3kys2 +1 -0
  97. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/f8/3z/f83z2f041tfpu39ygi0gu32wai8x +1 -0
  98. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/gt/rc/gtrco13ij0i2vi27t6wm1jhcve5p +1 -0
  99. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/k8/br/k8br0vtpgmpqxrl8mdsceymh3c8d +1 -0
  100. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/mw/le/mwle6olsgsk8h2pxvklj5q0yr9sc +1 -0
  101. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/n7/ja/n7jacvu07s9z9ai7acjq8kovdh02 +1 -0
  102. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/o1/2w/o12whqlkt6rc0yaq3b6fsowmewdp +1 -0
  103. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/o9/2g/o92go6wavds5oht0dso6m1ybvbh4 +1 -0
  104. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/om/7f/om7frlle7xz8pybxbydeq1q20hro +1 -0
  105. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/q6/78/q678f1u8v1nv07dbtm85knmw3b9q +1 -0
  106. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/qq/kc/qqkciwi2vymum1556755n85po1j9 +1 -0
  107. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/r4/wp/r4wpzje2mix0dtl8r2f4akh18fm1 +1 -0
  108. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/v1/h9/v1h9cuuwtwvz8p6fl574qum6k4ig +1 -0
  109. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/vb/mw/vbmwrl014lccj3jo61vojqscfxha +1 -0
  110. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/wn/q4/wnq49hhhxvh4gnc2782lf4zzlz46 +1 -0
  111. data/spec/dummy/tmp/storage-7.0.0-ruby-3.2.0/ya/go/yago1kn4o7p8jfob0cxetrif714s +1 -0
  112. data/spec/factories/questions_factory.rb +6 -0
  113. data/spec/factories/users_factory.rb +5 -0
  114. data/spec/features/rapidfire/answering_questions_spec.rb +47 -7
  115. data/spec/fixtures/files/one.txt +1 -0
  116. data/spec/fixtures/files/two.txt +1 -0
  117. data/spec/models/rapidfire/attempt_spec.rb +5 -1
  118. data/spec/models/rapidfire/questions/file_spec.rb +57 -0
  119. data/spec/models/rapidfire/questions/multi_file_spec.rb +60 -0
  120. data/spec/services/rapidfire/attempt_builder_spec.rb +61 -13
  121. metadata +184 -232
  122. data/spec/dummy/db/development.sqlite3 +0 -0
  123. data/spec/dummy/log/development.log +0 -200
  124. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-N/-Nnl5LNk36kVPJf_3kuN5xu7Ebj5HCbnrsyxphSIsdg.cache +0 -0
  125. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-o/-ojJ77Tf5UKdeHBEDmWtQ_3tnTJqQ0nd-YsKamqADUE.cache +0 -1
  126. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2b/2bErzwvSRmQv4cAljE5MLyihOZ0NcAw3J8cE3Lt0e4Q.cache +0 -0
  127. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4C/4CJwpaeIKdXtjEAju7_wQgXuYrzr55ARwRJeVKN7CPM.cache +0 -0
  128. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4U/4UispN4bfPqEzViX3T416Fr-T-7awbayU5fSryvLFNw.cache +0 -0
  129. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4k/4kH3sikLuE3o4jE_TNDlBNrlF7XAo_qYtBA6ckHGa5I.cache +0 -0
  130. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7d/7drzegBZRzthT8NYQjAVcg1mCXgXUj5USwB8GQ1o23Y.cache +0 -1
  131. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/80/80TT8hyotZ8-XWzQe7ELHNN8U6Mp2oGKwqa6Ckoksx0.cache +0 -1
  132. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8F/8FRx5PWf5mlaMlBnq_oPScrqvzB2csCEVlQ-FbB7Jy8.cache +0 -0
  133. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8M/8MNahq2o0fNDjjgT-erC9ZV3sFYg4ifFZqlLkcifOSA.cache +0 -1
  134. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8W/8WURt7NXtVdx9vbcRVtNXo2mqrL-0LPzw609oR1ZXnk.cache +0 -0
  135. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8k/8kFdViWjxSCYCA00vzJCIk-Hl7Dv6xCJ_Ce3jZALweg.cache +0 -1
  136. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9-/9-6v3_GF1yDfksWqHBJ96NiduUWyrW5R3k6MQzVpork.cache +0 -0
  137. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/94/94L1rKpX0k77vTIGtqElUDP4dpQXrCmvpI9CmQcZ_aM.cache +0 -1
  138. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9s/9s2S3Z_vncpN-gwuV05kcjhELi_kX-saO8shiQRx8cU.cache +0 -0
  139. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/AS/AS1POBxm-FJcvGXfKUC02RI960YWQRZP6B5bJ9Pc8qU.cache +0 -1
  140. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/AS/Asy0YwmSFpm-OyM4_Lb9v5CTPAePa74fljOfWyS3SJY.cache +0 -0
  141. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/AY/AYSNFEx7wRHtwbVh3cNGid6wCMdfgyk9ocorMLfRqx4.cache +0 -0
  142. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Bk/BkxzEgJOpM-iCKaxrcsZlyRZeZKYVDlUj0C-sPXVGPc.cache +0 -0
  143. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/CW/CW8uYbA8W5LQ0T8Bo2ygunrwYuaHB0kJJuXlPlGA5F8.cache +0 -1
  144. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Co/CooYsvCeOgtDx9ZKSzQADfurwS4WGsVpyNXMlWum68U.cache +0 -0
  145. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DC/DCdg25PhcFibsQItx9ofgOr68CacLQumta_lSKJCoOg.cache +0 -1
  146. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Db/DbmLC3wtG7ztEvkzmVAubW8vf37XdD0bT3Kh73oed1A.cache +0 -0
  147. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Db/dBQCcGB2fmK2CTrjrkLGxVmGKqBC2AZAx2C6TUMa1XY.cache +0 -0
  148. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Dn/Dn7Jw00mRZVDDxhjSg9300HJb_1875nlul_DHMMinn8.cache +0 -1
  149. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/IH/IHV1NrIJaxcdliBIo7Z7i28Nqm-8xd7RplmATbQZysI.cache +0 -0
  150. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ie/IemA55SqXkoyW_cD7FDwSk834ZydXI6UJpy7QsD-H5Q.cache +0 -0
  151. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/K7/K7SHc_erMPqr16VuAuVxvKfOUmN9Xf9zCR5Mmr6jOTo.cache +0 -0
  152. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/KG/KGhjc0Py_DB3csmx7Y7NGPUOfnsPXP_KJc94bFEIZls.cache +0 -1
  153. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Lz/LzA8Mm_F0jmw6BK_4ca5scIcIGc6RjWV54G-BeQv8cA.cache +0 -0
  154. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/MP/MPTz2thdBdQPKUgb5k1oYWT6cmJYgRTEz_NEYDQt7E0.cache +0 -0
  155. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Mt/MtTjUV8qKCTEH961LJhYQWADgVragV9D9xWWiCmxyNc.cache +0 -1
  156. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/O9/O9WxLI48Zh1ES7ZCQC-cX2C7A_-Wg_c_kUOsIHodXW0.cache +0 -0
  157. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Qo/QoZwnBtkSf3joyR1_5FKACUOgfoO35xMFOfLJkJqFD8.cache +0 -1
  158. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/R6/R6G-TFFztlxL5XDMIFX62wKkfUfmib6oV93z-xCZWsU.cache +0 -1
  159. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ry/Ry0Py6y0kHcEYq6qNWzUVQaMeP_p4kGPbD3ZchhmvEA.cache +0 -1
  160. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SD/SDy6hVbUInn62jE9aAJObZ8NmVkGE5sF7KxhzNEwjys.cache +0 -0
  161. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SD/sdxeRQBFEvjbUw-k3jsefKcslmEkm88PryW_XDPfOWU.cache +0 -0
  162. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SH/SHUtigN8XJz-0yTSrOMb-kFlv8iOSvIKmMU76EwSoY0.cache +0 -0
  163. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Tg/TgTcVvqf5KTGti25aDSVdPzdEFSzFCA7TIgv36nVcSw.cache +0 -0
  164. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Tj/TjvztGCZ2bx84O9DtrIqlbV9f36XZWuZRucFAwvdgJI.cache +0 -0
  165. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Tw/Twx5_JY_0JVEAdweDWUNH8zBfK8PB6OnwROdMaXHv98.cache +0 -1
  166. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/UD/UD9ueo8syy1g__X14lIaWY51JAsI5nkxjvn4iz7-B68.cache +0 -1
  167. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/VY/VYOSVFxELVZ_dWFjIfo96exB1iYypEPPaE0U-NYUk3I.cache +0 -0
  168. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Vq/VqF69IHPfaZOy6Wd3s10PIQmt2iWbU7UKgi7gGhoY6c.cache +0 -1
  169. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/W3/W3k3ezbkIWPsSAffgGGMKKSe_1CPV2jCUAXtFPSKTjE.cache +0 -0
  170. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/XY/XYnyPDtRIxqi5PSIcR0DKovMSyfgt-vquXm2oF4YcYU.cache +0 -0
  171. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Xe/Xez_IMQeyfLa4U_cntyZgtqAxc9P-spYMcKOwgwqfUk.cache +0 -1
  172. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Xp/XpKq_V1bVRTt2Dm9n2LFly2fc7rc63m5n0TkruAIT9U.cache +0 -1
  173. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YQ/YQ07c7yZvQDkWCDNv-r_m3MczWVJMkpDlY6mItSQvDI.cache +0 -0
  174. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_D/_Du4UKNyRoKp1L8GangzMxQuHGRXv9UNLRFzUUG-8Mo.cache +0 -0
  175. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_i/_ioj978qaHpKe71YAPRTMr52bYBz1jBQH_a9jnVNxto.cache +0 -1
  176. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/a9/a9w-3USbjccL8aE_56A0EsenyNCD6btCxgmr4_s-LVk.cache +0 -0
  177. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/c6/c6TDdHnqxfaHueLdYt538jXw_7RBFpECFkp7A4pWUfs.cache +0 -1
  178. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dH/dH4Xkqb5rV9DHHmRa_ODseSEFnlwS0AXeHgoCYqkkZ8.cache +0 -0
  179. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dU/dUHj3xc9qlZfXc7VP69mfddx5l1sXwlfejSWXIdb1JQ.cache +0 -1
  180. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/de/derm8VJMOzbaRf2rY8Vz6WSHk5w-XAKJIsAIHU5Ng58.cache +0 -1
  181. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/e6/e6jkUzONoMPGAC7nyZsGla8Zm7wPlhXwijdHIYF-FTo.cache +0 -0
  182. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fJ/fJ5wsH-IHhi_3Wg-4Yk01_O8Bw8SpcxPh-PaN6n38CQ.cache +0 -0
  183. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/g3/g3XXzOg1WKmExnfECaHxaHbjrF8feoJ60TwJJQzWlhI.cache +0 -0
  184. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/g4/g4tbfWjrt8uCm6WfFre4E1yEp4WC9rV9pFrA_9VHQys.cache +0 -0
  185. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gm/gmSFGhfFSAm1wrLyyGXOUXMn-kygBbG7Zf3unPKzEWw.cache +0 -1
  186. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gz/gz6bIRfuHgLuNBVVsocUuzLbEU4gEneTbmvzi27eoho.cache +0 -0
  187. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hM/hMgVzrZus4Z8I8AXg5NPYgizKLI5WwSbt5NKdK00slk.cache +0 -0
  188. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iw/iwQwbZENFRwrGzETXtK_2_3aqWyAENDNwJAdJu1RoBg.cache +0 -1
  189. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/kJ/kJSsmIsKQHNWdfJ2rMMpTZQ6DeAipIUyiXdftUlXr4I.cache +0 -0
  190. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ky/ky_7gNCiNp9E5HHXqszipoMZuSpcxD9ceXe46g_5VzI.cache +0 -1
  191. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/lJ/lJf_GZ6JzbMPq2WIEKNQKFh5vI9T8ylMDcZQMcgj1fg.cache +0 -1
  192. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/lo/lo0mbuMJiW9QksbTzvZ6N6aknuNrk1sJCprfNsMJw50.cache +0 -0
  193. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m8/m801v81Cvh2CcUpw7286U_9CC2tO0z4XBKhfVx8OabE.cache +0 -1
  194. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mY/mYUyrqDItAnpMyLO7mNA7gPs93yNLb7Hr66jqh-aJmk.cache +0 -1
  195. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oT/oT7WJVi5xRK0iTbo-MPPVRF3__YNxLiK-kG2oSzeHgA.cache +0 -1
  196. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pr/prpHKLWY8kH_ZR0CBQBubKTbYRVzUx-u2RzceRwSedM.cache +0 -0
  197. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/py/py8m2jF8ezxgbkf0QTl2FPU21gpWQgvz96UpLr4JCbQ.cache +0 -1
  198. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/q3/q3AuG3GbIVzhGBdYCriWe8FktR40JLxYfJyauA0-CCs.cache +0 -1
  199. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/q6/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +0 -0
  200. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/q7/q7yl5Q_Rk3hQdNI2dKzooG6EkbWvfGaywsvHDtNBX3E.cache +0 -0
  201. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/rc/rcasFMX-bUWsjC8vmfqpoKL6LDbNyRqjBOBJn6KxQrM.cache +0 -1
  202. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/rh/rh0ehR00zu0AmhmksJoUmSMhi6eKb30JpiSLU1Y7vGY.cache +0 -0
  203. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/t6/t6ve2uEx0ZpKYVPLJkiSm3_3nVj8hVs0ouPs-j1Y-Lw.cache +0 -0
  204. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/tF/tFs-J47Vhauit7rJvH6_RG3NydHacSvI1Wn_BPK8OBs.cache +0 -1
  205. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/uU/uUfexZe40_0TvILVKPsXUS5gjsc4iul3OZCrWoXS0Qo.cache +0 -1
  206. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/vF/vFj_rUSzkEPWTAvaVnIUzkZIbfolIXH2bitACRZYWAU.cache +0 -1
  207. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/vk/vk-e_ORxd49RmmTia4r2ajyVw0p-xcUuz8uz8Nx_LUw.cache +0 -1
  208. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wa/wab9PO75nglTE-rq2pVPg22CRkZW_yTq_WcZ6BEp8T0.cache +0 -0
  209. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wd/wdHNDzQjfQYx2VQbObEoz4iNxGhcuum4uypNBmnuNpA.cache +0 -1
  210. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wu/wuO0z3wuhphrqHOHqZdrZd6lFv2u0_Gq7BkDoc_8cEw.cache +0 -1
  211. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/x7/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +0 -0
  212. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xg/xge95XbE6Me8MVp8Pnz9FbKOZhvzndxHzh-uOjZV5_s.cache +0 -0
  213. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xz/Xz-wkd5XTDRNs5mNRhBpx4RSe0LN9ajplnuDcli51jE.cache +0 -1
  214. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xz/xzFhuo3m7qD5I9Xc85aP9j6kR-iAOB0najl9uu7hdMc.cache +0 -1
  215. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yn/ynGH6ruy4vPfFCwXOH8rgd3f-UWmo05h37jjH0cii8E.cache +0 -1
  216. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yw/yw6SDVVxzUeXqN9VX1eCGWTN809mt05p0JnedEBCZ7w.cache +0 -0
  217. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zg/zg53gL5TWyca4nbWc_d4pFhJ7huiu6zm1BTDcALsP8c.cache +0 -1
@@ -1,9 +1,49 @@
1
+ require 'csv'
1
2
  module Rapidfire
2
- class Survey < ActiveRecord::Base
3
+ class Survey < ApplicationRecord
3
4
  has_many :attempts
4
5
  has_many :questions
5
- has_many :attempts
6
6
 
7
7
  validates :name, :presence => true
8
+
9
+
10
+ if Rails::VERSION::MAJOR == 3
11
+ attr_accessible :name, :introduction, :after_survey_content
12
+ end
13
+
14
+ def self.csv_user_attributes=(attributes)
15
+ @@csv_user_attributes = Array(attributes)
16
+ end
17
+
18
+ def self.csv_user_attributes
19
+ @@csv_user_attributes || []
20
+ end
21
+
22
+ def results_to_csv(filter)
23
+ CSV.generate do |csv|
24
+ header = []
25
+ header += Rapidfire::Survey.csv_user_attributes
26
+ questions.each do |question|
27
+ header << ActionView::Base.full_sanitizer.sanitize(question.question_text, :tags => [], :attributes => [])
28
+ end
29
+ header << "results updated at"
30
+ csv << header
31
+ attempts.where(SurveyResults.filter(filter, 'id')).each do |attempt|
32
+ this_attempt = []
33
+
34
+ Survey.csv_user_attributes.each do |attribute|
35
+ this_attempt << attempt.user.try(attribute)
36
+ end
37
+
38
+ questions.each do |question|
39
+ answer = attempt.answers.detect{|a| a.question_id == question.id }.try(:answer_text)
40
+ this_attempt << answer
41
+ end
42
+
43
+ this_attempt << attempt.updated_at
44
+ csv << this_attempt
45
+ end
46
+ end
47
+ end
8
48
  end
9
49
  end
@@ -28,14 +28,25 @@ module Rapidfire
28
28
  else
29
29
  text
30
30
  end
31
+
32
+ case answer.question
33
+ when Rapidfire::Questions::MultiFile
34
+ answer.files = answer_attributes[:files]
35
+ when Rapidfire::Questions::File
36
+ answer.file = answer_attributes[:file]
37
+ end
31
38
  end
32
39
 
33
- @attempt.save!(options)
40
+ if Rails::VERSION::MAJOR >= 5
41
+ @attempt.save!
42
+ else
43
+ @attempt.save!(options)
44
+ end
34
45
  end
35
46
 
36
47
  def save(options = {})
37
48
  save!(options)
38
- rescue ActiveRecord::ActiveRecordError => e
49
+ rescue ActiveRecord::ActiveRecordError => _e
39
50
  # repopulate answers here in case of failure as they are not getting updated
40
51
  @answers = @survey.questions.collect do |question|
41
52
  @attempt.answers.find { |a| a.question_id == question.id }
@@ -44,6 +55,7 @@ module Rapidfire
44
55
  end
45
56
 
46
57
  private
58
+
47
59
  def build_attempt(attempt_id)
48
60
  if attempt_id.present?
49
61
  @attempt = Attempt.find(attempt_id)
@@ -9,6 +9,9 @@ module Rapidfire
9
9
  Rapidfire::Questions::Radio,
10
10
  Rapidfire::Questions::Select,
11
11
  Rapidfire::Questions::Short,
12
+ Rapidfire::Questions::Information,
13
+ Rapidfire::Questions::File,
14
+ Rapidfire::Questions::MultiFile,
12
15
  ]
13
16
 
14
17
  QUESTION_TYPES = AVAILABLE_QUESTIONS.inject({}) do |result, question|
@@ -48,11 +51,12 @@ module Rapidfire
48
51
  end
49
52
 
50
53
  def update_question
51
- @question.update_attributes(to_question_params)
54
+ @question.update(to_question_params)
52
55
  end
53
56
 
54
57
  def to_question_params
55
58
  {
59
+ :type => type,
56
60
  :survey => survey,
57
61
  :question_text => question_text,
58
62
  :position => position,
@@ -8,24 +8,58 @@ module Rapidfire
8
8
  # 2. question text
9
9
  # 3. if aggregatable, return each option with value
10
10
  # 4. else return an array of all the answers given
11
- def extract
11
+ def extract(filter_params = {})
12
12
  @survey.questions.collect do |question|
13
13
  results =
14
14
  case question
15
15
  when Rapidfire::Questions::Select, Rapidfire::Questions::Radio,
16
16
  Rapidfire::Questions::Checkbox
17
- answers = question.answers.map(&:answer_text).map do |text|
17
+ answers = question.answers.where(*filter(filter_params)).map(&:answer_text).map do |text|
18
18
  text.to_s.split(Rapidfire.answers_delimiter)
19
19
  end.flatten
20
20
 
21
- answers.inject(Hash.new(0)) { |total, e| total[e] += 1; total }
21
+ count_hash = Hash.new(0)
22
+ question.options.map{|o| count_hash[o] = 0 }
23
+
24
+ answers.inject(count_hash) { |total, e| total[e] += 1; total }
22
25
  when Rapidfire::Questions::Short, Rapidfire::Questions::Date,
23
26
  Rapidfire::Questions::Long, Rapidfire::Questions::Numeric
24
- question.answers.pluck(:answer_text)
27
+ question.answers.where(*filter(filter_params)).pluck(:answer_text)
25
28
  end
26
29
 
27
30
  QuestionResult.new(question: question, results: results)
28
31
  end
29
32
  end
33
+
34
+ def filter(filter_params, column = 'attempt_id')
35
+ @filter_result ||= begin
36
+ return ["0=0"] unless Array(filter_params[:question_ids]).compact.count == Array(filter_params[:options]).compact.count
37
+ return ["0=0"] unless %w(id attempt_id).include?(column)
38
+ return ["0=0"] if Array(filter_params[:question_ids]).compact.count == 0
39
+
40
+ collected_filters = {}
41
+ Array(filter_params[:question_ids]).each_with_index do |question_id, i|
42
+ collected_filters[question_id] ||= []
43
+ collected_filters[question_id] << filter_params[:options][i]
44
+ end
45
+
46
+ attempt_ids = nil
47
+
48
+ collected_filters.each do |question_id, options|
49
+ these_matches = Answer.where("question_id = ? and answer_text in (?)", question_id, options).pluck(:attempt_id)
50
+ if attempt_ids.nil?
51
+ attempt_ids = these_matches
52
+ else
53
+ attempt_ids = attempt_ids & these_matches
54
+ end
55
+ end
56
+
57
+ ["#{column} in (?)", attempt_ids]
58
+ end
59
+ end
60
+
61
+ def self.filter(filter_params, column)
62
+ self.new.filter(filter_params, column)
63
+ end
30
64
  end
31
65
  end
@@ -1,7 +1,7 @@
1
1
  <%= render partial: "rapidfire/answers/errors", locals: {answer: answer} %>
2
2
 
3
3
  <div class="form-group">
4
- <%= f.label :answer_text, answer.question.question_text %>
4
+ <%= f.label :answer_text, answer.question.question_text.html_safe %>
5
5
  <%= f.fields_for :answer_text do |af| %>
6
6
  <%- answer.question.options.each_with_index do |option, index| %>
7
7
  <%= af.label index do %>
@@ -1,5 +1,5 @@
1
1
  <%= render partial: "rapidfire/answers/errors", locals: {answer: answer} %>
2
2
  <div class="form-group">
3
- <%= f.label :answer_text, answer.question.question_text %>
3
+ <%= f.label :answer_text, answer.question.question_text.html_safe %>
4
4
  <%= f.text_field :answer_text %>
5
5
  </div>
@@ -0,0 +1,5 @@
1
+ <%= render partial: "rapidfire/answers/errors", locals: {answer: answer} %>
2
+ <div class="form-group">
3
+ <%= f.label :answer_text, answer.question.question_text.html_safe %>
4
+ <%= f.file_field :file %>
5
+ </div>
@@ -0,0 +1,4 @@
1
+ <%= render partial: "rapidfire/answers/errors", locals: {answer: answer} %>
2
+ <div class="form-group">
3
+ <%= f.label :answer_text, answer.question.question_text.html_safe %>
4
+ </div>
@@ -1,5 +1,5 @@
1
1
  <%= render partial: "rapidfire/answers/errors", locals: {answer: answer} %>
2
2
  <div class="form-group">
3
- <%= f.label :answer_text, answer.question.question_text %>
3
+ <%= f.label :answer_text, answer.question.question_text.html_safe %>
4
4
  <%= f.text_area :answer_text, value: answer.answer_text || answer.question.default_text, :rows => 5, placeholder: answer.question.placeholder %>
5
5
  </div>
@@ -0,0 +1,5 @@
1
+ <%= render partial: "rapidfire/answers/errors", locals: {answer: answer} %>
2
+ <div class="form-group">
3
+ <%= f.label :answer_text, answer.question.question_text.html_safe %>
4
+ <%= f.file_field :files, multiple: true %>
5
+ </div>
@@ -1,5 +1,5 @@
1
1
  <%= render partial: "rapidfire/answers/errors", locals: {answer: answer} %>
2
2
  <div class="form-group">
3
- <%= f.label :answer_text, answer.question.question_text %>
3
+ <%= f.label :answer_text, answer.question.question_text.html_safe %>
4
4
  <%= f.text_field :answer_text %>
5
5
  </div>
@@ -1,7 +1,7 @@
1
1
  <%= render partial: "rapidfire/answers/errors", locals: {answer: answer} %>
2
2
 
3
3
  <div class="form-group">
4
- <%= f.label :answer_text, answer.question.question_text %>
4
+ <%= f.label :answer_text, answer.question.question_text.html_safe %>
5
5
  <%- answer.question.options.each_with_index do |option, index| %>
6
6
  <span class="form-group sub">
7
7
  <%= f.label "answer_text_#{index}" do %>
@@ -1,5 +1,5 @@
1
1
  <%= render partial: "rapidfire/answers/errors", locals: {answer: answer} %>
2
2
  <div class="form-group">
3
- <%= f.label :answer_text, answer.question.question_text %>
3
+ <%= f.label :answer_text, answer.question.question_text.html_safe %>
4
4
  <%= f.select :answer_text, answer.question.options, include_blank: true %>
5
5
  </div>
@@ -1,5 +1,5 @@
1
1
  <%= render partial: "rapidfire/answers/errors", locals: {answer: answer} %>
2
2
  <div class="form-group">
3
- <%= f.label :answer_text, answer.question.question_text %>
3
+ <%= f.label :answer_text, answer.question.question_text.html_safe %>
4
4
  <%= f.text_field :answer_text, value: answer.answer_text || answer.question.default_text, placeholder: answer.question.placeholder %>
5
5
  </div>
@@ -3,7 +3,7 @@
3
3
 
4
4
  <p><%= @survey.introduction %></p>
5
5
 
6
- <%= form_for([@survey, @attempt_builder]) do |f| %>
6
+ <%= form_for([@survey, @attempt_builder], method: method) do |f| %>
7
7
  <%- @attempt_builder.answers.each do |answer| %>
8
8
  <%= f.fields_for("#{answer.question.id}", answer) do |answer_form| %>
9
9
  <%= render_answer_form_helper(answer, answer_form) %>
@@ -1 +1 @@
1
- <%= render partial: 'form', locals: { submit_text: 'Update' } %>
1
+ <%= render partial: 'form', locals: { submit_text: 'Update', method: :put } %>
@@ -1 +1 @@
1
- <%= render partial: 'form', locals: { submit_text: t('rapidfire.attempts.save') } %>
1
+ <%= render partial: 'form', locals: { submit_text: t('rapidfire.attempts.save'), method: :post } %>
@@ -16,7 +16,7 @@
16
16
 
17
17
  <div class="form-group">
18
18
  <%= f.label :question_text %>
19
- <%= f.text_field :question_text %>
19
+ <%= f.text_area :question_text, rows: 5 %>
20
20
  </div>
21
21
 
22
22
  <div class="form-group">
@@ -12,7 +12,13 @@
12
12
  <% if can_administer? %>
13
13
  <li><%= link_to "Results", [:results, survey] %></li>
14
14
  <li><%= link_to "Edit", edit_survey_path(survey) %></li>
15
+ <li><%= link_to "Copy", surveys_path(copy_survey_id: survey), method: :post %></li>
15
16
  <li><%= link_to "Delete", survey, method: :delete %></li>
17
+ <% if survey.active? %>
18
+ <li><%= link_to "De-activate", survey_path(survey, survey: { active: 0 }), method: :patch %></li>
19
+ <% else %>
20
+ <li><%= link_to "Activate", survey_path(survey, survey: { active: 1 }), method: :patch %></li>
21
+ <% end %>
16
22
  <% end %>
17
23
  </ul>
18
24
  </td>
@@ -1,9 +1,14 @@
1
1
  <h2>
2
- Surveys
2
+ <%= params[:active].to_i == 0 ? "In-A" : "A" %>ctive Surveys
3
3
  </h2>
4
4
  <h3>
5
5
  <% if can_administer? %>
6
- <%= link_to "New Survey", new_survey_path %>
6
+ <%= link_to "New Survey", new_survey_path %> |
7
+ <% if params[:active].to_i == 0 %>
8
+ <%= link_to "View Active Surveys", surveys_path(active: 1) %>
9
+ <% else %>
10
+ <%= link_to "View Inactive Surveys", surveys_path(active: 0) %>
11
+ <% end %>
7
12
  <% end %>
8
13
  </h3>
9
14
  <h4>
@@ -1,5 +1,5 @@
1
1
  <h1>Results</h1>
2
-
2
+ <%= link_to "Download CSV", results_survey_path(id: params[:id], format: :csv) %>
3
3
  <%- @survey_results.each do |result| %>
4
4
  <div>
5
5
  <h4><%= result.question.question_text %></h4>
@@ -16,6 +16,7 @@
16
16
  <tr>
17
17
  <th>Option</th>
18
18
  <th>Count</th>
19
+ <th>Filter</th>
19
20
  </tr>
20
21
  </thead>
21
22
  <tbody>
@@ -23,6 +24,7 @@
23
24
  <tr>
24
25
  <td><%= option %></td>
25
26
  <td><%= count %></td>
27
+ <td><%= filter_link(result.question.id, option) %></th>
26
28
  </tr>
27
29
  <% end %>
28
30
  </tbody>
@@ -0,0 +1,12 @@
1
+ if Rails::VERSION::MAJOR >= 5
2
+ version = [Rails::VERSION::MAJOR, Rails::VERSION::MINOR].join('.').to_f
3
+ base = ActiveRecord::Migration[version]
4
+ else
5
+ base = ActiveRecord::Migration
6
+ end
7
+
8
+ class AddActiveToSurveys < base
9
+ def change
10
+ add_column :rapidfire_surveys, :active, :boolean
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ module Rapidfire
2
+ module Generators
3
+ class ActiveSurveyMigrationGenerator < ::Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def self.next_migration_number(dir)
9
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
10
+ end
11
+
12
+ def copy_migrations
13
+ migration_template "migrations/add_active_to_survey.rb", "db/migrate/add_active_to_survey.rapidfire.rb"
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ class AddActiveToSurvey < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :rapidfire_surveys, :active, :boolean, default: 1
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Rapidfire
2
- VERSION = '4.0.0'
2
+ VERSION = '5.0.0'
3
3
  end
@@ -8,7 +8,7 @@ namespace :rapidfire do
8
8
 
9
9
  new_answer_options = question.answer_options.split(',')
10
10
  .join(Rapidfire.answers_delimiter)
11
- question.update_attributes!(answer_options: new_answer_options)
11
+ question.update!(answer_options: new_answer_options)
12
12
  end
13
13
  end
14
14
  end
@@ -6,10 +6,20 @@ namespace :rapidfire do
6
6
  `rails generate rapidfire:upgrade_migration`
7
7
  end
8
8
 
9
+ desc "Adding multitenancy support to Rapidfire"
10
+ task multitenancy: :environment do
11
+ `rails generate rapidfire:multitenant_migration`
12
+ end
13
+
9
14
  desc "Adds a field to show the user after they take a survey"
10
15
  task after_survey_page: :environment do
11
16
  `rails generate rapidfire:after_survey_content_migration`
12
17
  end
18
+
19
+ desc "Adds a field to make a survey active/inactive"
20
+ task active_inactive_surveys: :environment do
21
+ `rails generate rapidfire:active_survey_migration`
22
+ end
13
23
  end
14
24
  end
15
25
  end
@@ -206,7 +206,7 @@ app/controllers
206
206
 
207
207
  app/models
208
208
  Holds models that should be named like post.rb. Models descend from
209
- ActiveRecord::Base by default.
209
+ ApplicationRecord by default.
210
210
 
211
211
  app/views
212
212
  Holds the template files for the view that should be named like
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts .js
2
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,2 @@
1
+ class User < ApplicationRecord
2
+ end
@@ -2,8 +2,6 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", :media => "all" %>
6
- <%= javascript_include_tag "application" %>
7
5
  <%= csrf_meta_tags %>
8
6
  </head>
9
7
  <body>
@@ -1,6 +1,21 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- require 'rails/all'
3
+ require "rails"
4
+ require "active_model/railtie"
5
+ # require "active_job/railtie"
6
+ require "active_record/railtie"
7
+ if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" >= "5.2"
8
+ require "active_storage/engine"
9
+ end
10
+ require "action_controller/railtie"
11
+ require "action_mailer/railtie"
12
+ # require "action_mailbox/engine"
13
+ # require "action_text/engine"
14
+ require "action_view/railtie"
15
+ # require "action_cable/engine"
16
+ # require "sprockets/railtie"
17
+ require "rails/test_unit/railtie"
18
+
4
19
 
5
20
  Bundler.require(*Rails.groups)
6
21
 
@@ -44,10 +59,14 @@ module Dummy
44
59
  # config.active_record.schema_format = :sql
45
60
 
46
61
  # Enable the asset pipeline
47
- config.assets.enabled = true
62
+ # config.assets.enabled = true
48
63
 
49
64
  # Version of your assets, change this if you want to expire all your assets
50
- config.assets.version = '1.0'
65
+ # config.assets.version = '1.0'
66
+
67
+ if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" >= "5.1"
68
+ config.load_defaults "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}"
69
+ end
51
70
  end
52
71
  end
53
72
 
@@ -30,4 +30,9 @@ Dummy::Application.configure do
30
30
 
31
31
  # Print deprecation notices to the stderr
32
32
  config.active_support.deprecation = :stderr
33
+
34
+ if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" >= "5.2"
35
+ # Store uploaded files on the local file system in a temporary directory.
36
+ config.active_storage.service = :test
37
+ end
33
38
  end
@@ -0,0 +1,7 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage-#{ENV['RAILS_VERSION']}-#{ENV['RUBY_VERSION']}") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
@@ -0,0 +1,15 @@
1
+ if Rails::VERSION::MAJOR >= 5
2
+ version = [Rails::VERSION::MAJOR, Rails::VERSION::MINOR].join('.').to_f
3
+ base = ActiveRecord::Migration[version]
4
+ else
5
+ base = ActiveRecord::Migration
6
+ end
7
+
8
+ class CreateUsers < base
9
+ def change
10
+ create_table :users do |t|
11
+ t.string :name
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,67 @@
1
+ if Rails::VERSION::MAJOR >= 5
2
+ version = [Rails::VERSION::MAJOR, Rails::VERSION::MINOR].join('.').to_f
3
+ base = ActiveRecord::Migration[version]
4
+ else
5
+ base = ActiveRecord::Migration
6
+ end
7
+
8
+
9
+ # This migration comes from active_storage (originally 20170806125915)
10
+ class CreateActiveStorageTables < base
11
+ def change
12
+ # Use Active Record's configured type for primary and foreign keys
13
+ primary_key_type, foreign_key_type = primary_and_foreign_key_types
14
+
15
+ create_table :active_storage_blobs, id: primary_key_type do |t|
16
+ t.string :key, null: false
17
+ t.string :filename, null: false
18
+ t.string :content_type
19
+ t.text :metadata
20
+ if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" >= "6.1"
21
+ t.string :service_name, null: false
22
+ end
23
+ t.bigint :byte_size, null: false
24
+ t.string :checksum
25
+
26
+ if connection.supports_datetime_with_precision?
27
+ t.datetime :created_at, precision: 6, null: false
28
+ else
29
+ t.datetime :created_at, null: false
30
+ end
31
+
32
+ t.index [ :key ], unique: true
33
+ end
34
+
35
+ create_table :active_storage_attachments, id: primary_key_type do |t|
36
+ t.string :name, null: false
37
+ t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
38
+ t.references :blob, null: false, type: foreign_key_type
39
+
40
+ if connection.supports_datetime_with_precision?
41
+ t.datetime :created_at, precision: 6, null: false
42
+ else
43
+ t.datetime :created_at, null: false
44
+ end
45
+
46
+ t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
47
+ t.foreign_key :active_storage_blobs, column: :blob_id
48
+ end
49
+
50
+ create_table :active_storage_variant_records, id: primary_key_type do |t|
51
+ t.belongs_to :blob, null: false, index: false, type: foreign_key_type
52
+ t.string :variation_digest, null: false
53
+
54
+ t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
55
+ t.foreign_key :active_storage_blobs, column: :blob_id
56
+ end
57
+ end
58
+
59
+ private
60
+ def primary_and_foreign_key_types
61
+ config = Rails.configuration.generators
62
+ setting = config.options[config.orm][:primary_key_type]
63
+ primary_key_type = setting || :primary_key
64
+ foreign_key_type = setting || :bigint
65
+ [primary_key_type, foreign_key_type]
66
+ end
67
+ end