card 1.19.0 → 1.19.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (424) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +3 -3
  4. data/config/initializers/{02_extensions → 02_patches}/kaminari.rb +16 -5
  5. data/config/initializers/patches.rb +7 -0
  6. data/config/locales/en.yml +15 -6
  7. data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +11 -11
  8. data/db/migrate_core_cards/data/themes/bootstrap_default/_variables.scss +2 -1
  9. data/db/seed/new/card_actions.yml +915 -443
  10. data/db/seed/new/card_acts.yml +348 -186
  11. data/db/seed/new/card_changes.yml +4409 -3329
  12. data/db/seed/new/card_references.yml +220 -3
  13. data/db/seed/new/cards.yml +6687 -3445
  14. data/db/seed/test/fixtures/card_actions.yml +1953 -1513
  15. data/db/seed/test/fixtures/card_acts.yml +615 -453
  16. data/db/seed/test/fixtures/card_changes.yml +7596 -6516
  17. data/db/seed/test/fixtures/card_references.yml +892 -675
  18. data/db/seed/test/fixtures/cards.yml +8803 -5561
  19. data/db/seeds.rb +8 -0
  20. data/lib/card.rb +10 -0
  21. data/lib/card/auth/setup.rb +6 -6
  22. data/lib/card/mod/dirs.rb +13 -3
  23. data/lib/card/set/advanced_api.rb +5 -4
  24. data/lib/cardio.rb +7 -3
  25. data/mod/Modfile +2 -2
  26. data/mod/admin/set/self/admin.rb +47 -30
  27. data/mod/admin/set/self/admin_info.rb +11 -11
  28. data/mod/basic_formats/set/self/head.rb +1 -1
  29. data/mod/{basic_types → basic_formats}/spec/set/all/all_css_spec.rb +0 -0
  30. data/mod/{basic_types → basic_formats}/spec/set/all/all_csv_spec.rb +0 -0
  31. data/mod/{basic_types → basic_formats}/spec/set/all/base_spec.rb +0 -0
  32. data/mod/{basic_types → basic_formats}/spec/set/all/file_spec.rb +0 -0
  33. data/mod/{basic_types → basic_formats}/spec/set/all/json_spec.rb +0 -0
  34. data/mod/{basic_types → basic_formats}/spec/set/all/rss_spec.rb +0 -0
  35. data/mod/{basic_types → basic_formats}/spec/set/all/text_spec.rb +0 -0
  36. data/mod/bootstrap/lib/stylesheets/bootstrap/_variables.scss +1 -1
  37. data/mod/bootstrap/set/all/bootstrap/table.rb +1 -1
  38. data/mod/bootstrap/set/self/bootswatch_shared.rb +1 -1
  39. data/mod/carrierwave/Gemfile +4 -0
  40. data/mod/carrierwave/lib/carrier_wave/cardmount.rb +24 -13
  41. data/mod/carrierwave/lib/carrier_wave/file_card_uploader.rb +189 -57
  42. data/mod/carrierwave/lib/carrier_wave/image_card_uploader.rb +5 -0
  43. data/mod/carrierwave/set/abstract/attachment.rb +26 -190
  44. data/mod/carrierwave/set/abstract/attachment/paths.rb +50 -0
  45. data/mod/carrierwave/set/abstract/attachment/storage_type.rb +319 -0
  46. data/mod/carrierwave/set/abstract/attachment/upload_cache.rb +77 -0
  47. data/mod/carrierwave/set/all/file_utils.rb +28 -0
  48. data/mod/carrierwave/set/self/admin.rb +23 -0
  49. data/mod/carrierwave/set/type/file.rb +26 -23
  50. data/mod/carrierwave/set/type/image.rb +1 -0
  51. data/mod/carrierwave/spec/lib/carrier_wave/file_card_uploader_spec.rb +67 -0
  52. data/mod/carrierwave/spec/set/type/file_spec.rb +557 -0
  53. data/mod/{standard → carrierwave}/spec/set/type/image_spec.rb +22 -4
  54. data/mod/core/set/abstract/code_file.rb +3 -3
  55. data/mod/core/set/all/debug.rb +23 -0
  56. data/mod/core/set/all/name.rb +1 -1
  57. data/mod/core/set/all/permissions.rb +22 -12
  58. data/mod/core/set/all/tracked_attributes.rb +0 -76
  59. data/mod/core/set/all/trash.rb +50 -0
  60. data/mod/core/set/all/update_read_rules.rb +84 -0
  61. data/mod/core/set/all/utils.rb +1 -75
  62. data/mod/email/set/type_plus_right/user/follow.rb +4 -8
  63. data/mod/history/lib/card/act.rb +3 -1
  64. data/mod/history/lib/card/action.rb +3 -1
  65. data/mod/history/lib/card/action/differ.rb +12 -1
  66. data/mod/history/set/all/history.rb +2 -1
  67. data/mod/machines/file/all_script_machine_output/file.js +211 -0
  68. data/mod/machines/file/all_style_machine_output/file.css +19 -0
  69. data/mod/machines/set/abstract/machine.rb +270 -0
  70. data/mod/machines/set/abstract/machine_input.rb +76 -0
  71. data/mod/machines/set/right/machine_output.rb +9 -1
  72. data/mod/machines/set/type/coffee_script.rb +2 -6
  73. data/mod/machines/set/type/css.rb +2 -2
  74. data/mod/machines/set/type/java_script.rb +2 -2
  75. data/mod/machines/set/type/skin.rb +2 -2
  76. data/mod/machines/spec/set/abstract/machine_spec.rb +10 -0
  77. data/mod/{basic_types → pointer}/spec/set/type/pointer_spec.rb +10 -26
  78. data/mod/settings/set/right/script.rb +1 -1
  79. data/mod/settings/set/right/style.rb +1 -1
  80. data/mod/solid_cache/set/all/solid_cache.rb +1 -1
  81. data/mod/standard/file/credit_image/image-icon.png +0 -0
  82. data/mod/standard/file/credit_image/image-large.png +0 -0
  83. data/mod/standard/file/credit_image/image-medium.png +0 -0
  84. data/mod/standard/file/credit_image/image-small.png +0 -0
  85. data/mod/standard/file/favicon/image-icon.png +0 -0
  86. data/mod/standard/file/favicon/image-large.png +0 -0
  87. data/mod/standard/file/favicon/image-medium.png +0 -0
  88. data/mod/standard/file/favicon/image-small.png +0 -0
  89. data/mod/standard/file/logo/image-icon.png +0 -0
  90. data/mod/standard/file/logo/image-large.png +0 -0
  91. data/mod/standard/file/logo/image-medium.png +0 -0
  92. data/mod/standard/file/logo/image-small.png +0 -0
  93. data/mod/standard/set/all/links.rb +2 -2
  94. data/spec/spec_helper.rb +15 -3
  95. data/tmpsets/set/{mod014-admin → mod001-admin}/self/admin.rb +47 -30
  96. data/tmpsets/set/{mod014-admin → mod001-admin}/self/admin_info.rb +11 -11
  97. data/tmpsets/set/{mod014-admin → mod001-admin}/self/version.rb +0 -0
  98. data/tmpsets/set/{mod001-core → mod002-core}/abstract/code_file.rb +0 -0
  99. data/tmpsets/set/{mod001-core → mod002-core}/all/actify.rb +6 -5
  100. data/tmpsets/set/{mod001-core → mod002-core}/all/active_card.rb +0 -0
  101. data/tmpsets/set/{mod001-core → mod002-core}/all/collection.rb +0 -0
  102. data/tmpsets/set/{mod001-core → mod002-core}/all/content.rb +0 -0
  103. data/tmpsets/set/mod002-core/all/debug.rb +30 -0
  104. data/tmpsets/set/{mod001-core → mod002-core}/all/erb.rb +0 -0
  105. data/tmpsets/set/{mod001-core → mod002-core}/all/event.rb +0 -0
  106. data/tmpsets/set/{mod001-core → mod002-core}/all/export.rb +0 -0
  107. data/tmpsets/set/{mod001-core → mod002-core}/all/fetch.rb +0 -0
  108. data/tmpsets/set/{mod001-core → mod002-core}/all/haml.rb +0 -0
  109. data/tmpsets/set/{mod001-core → mod002-core}/all/initialize.rb +0 -0
  110. data/tmpsets/set/{mod001-core → mod002-core}/all/location_history.rb +0 -0
  111. data/tmpsets/set/{mod001-core → mod002-core}/all/name.rb +1 -1
  112. data/tmpsets/set/{mod001-core → mod002-core}/all/name_validations.rb +0 -0
  113. data/tmpsets/set/{mod001-core → mod002-core}/all/pattern.rb +0 -0
  114. data/tmpsets/set/{mod001-core → mod002-core}/all/permissions.rb +22 -12
  115. data/tmpsets/set/{mod001-core → mod002-core}/all/phases.rb +0 -0
  116. data/tmpsets/set/{mod001-core → mod002-core}/all/references.rb +0 -0
  117. data/tmpsets/set/{mod001-core → mod002-core}/all/rules.rb +0 -0
  118. data/tmpsets/set/{mod001-core → mod002-core}/all/stages.rb +0 -0
  119. data/tmpsets/set/{mod001-core → mod002-core}/all/states.rb +0 -0
  120. data/tmpsets/set/{mod001-core → mod002-core}/all/subcards.rb +0 -0
  121. data/tmpsets/set/{mod001-core → mod002-core}/all/templating.rb +0 -0
  122. data/tmpsets/set/mod002-core/all/tracked_attributes.rb +78 -0
  123. data/tmpsets/set/{mod001-core → mod002-core}/all/trash.rb +50 -0
  124. data/tmpsets/set/{mod001-core → mod002-core}/all/type.rb +0 -0
  125. data/tmpsets/set/mod002-core/all/update_read_rules.rb +91 -0
  126. data/tmpsets/set/mod002-core/all/utils.rb +62 -0
  127. data/tmpsets/set/{mod001-core → mod002-core}/all/view_cache.rb +0 -0
  128. data/tmpsets/set/{mod002-history → mod003-history}/all/actions.rb +0 -0
  129. data/tmpsets/set/{mod002-history → mod003-history}/all/content_history.rb +0 -0
  130. data/tmpsets/set/{mod002-history → mod003-history}/all/history.rb +2 -1
  131. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_css.rb +0 -0
  132. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_csv.rb +0 -0
  133. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_js.rb +0 -0
  134. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/base.rb +0 -0
  135. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/file.rb +0 -0
  136. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/json.rb +0 -0
  137. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/rss.rb +0 -0
  138. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/text.rb +0 -0
  139. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/self/01_head/javascript.rb +0 -0
  140. data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/self/head.rb +1 -1
  141. data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/01_pointer.rb +0 -0
  142. data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/01_pointer/edit.rb +0 -0
  143. data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/code_pointer.rb +0 -0
  144. data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_editors.rb +0 -0
  145. data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_mods.rb +0 -0
  146. data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_pointer_config.rb +0 -0
  147. data/tmpsets/set/{mod004-pointer → mod005-pointer}/type/pointer.rb +0 -0
  148. data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/abstract/ace_editor.rb +0 -0
  149. data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/self/script_ace.rb +0 -0
  150. data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/self/script_ace_config.rb +0 -0
  151. data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/abstract/prosemirror_editor.rb +0 -0
  152. data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/self/script_prosemirror.rb +0 -0
  153. data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/self/script_prosemirror_config.rb +0 -0
  154. data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/abstract/solid_cache.rb +0 -0
  155. data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/all/solid_cache.rb +0 -0
  156. data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/right/solid_cache.rb +0 -0
  157. data/tmpsets/set/{mod009-basic_types → mod010-basic_types}/type/html.rb +0 -0
  158. data/tmpsets/set/{mod009-basic_types → mod010-basic_types}/type/plain_text.rb +0 -0
  159. data/tmpsets/set/mod011-machines/abstract/machine.rb +277 -0
  160. data/tmpsets/set/mod011-machines/abstract/machine_input.rb +83 -0
  161. data/tmpsets/set/{mod010-machines → mod011-machines}/abstract/script.rb +0 -0
  162. data/tmpsets/set/{mod010-machines → mod011-machines}/all/reset_machines.rb +0 -0
  163. data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_cache.rb +0 -0
  164. data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_input.rb +0 -0
  165. data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_output.rb +9 -1
  166. data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_card_menu.rb +0 -0
  167. data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_html5shiv_printshiv.rb +0 -0
  168. data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_jquery.rb +0 -0
  169. data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_jquery_helper.rb +0 -0
  170. data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_slot.rb +0 -0
  171. data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_bootstrap_compatible.rb +0 -0
  172. data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_cards.rb +0 -0
  173. data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_jquery_ui_smoothness.rb +0 -0
  174. data/tmpsets/set/{mod010-machines → mod011-machines}/type/coffee_script.rb +2 -6
  175. data/tmpsets/set/{mod010-machines → mod011-machines}/type/css.rb +2 -2
  176. data/tmpsets/set/{mod010-machines → mod011-machines}/type/java_script.rb +2 -2
  177. data/tmpsets/set/{mod010-machines → mod011-machines}/type/scss.rb +0 -0
  178. data/tmpsets/set/{mod010-machines → mod011-machines}/type/skin.rb +2 -2
  179. data/tmpsets/set/{mod011-settings → mod012-settings}/abstract/permission.rb +0 -0
  180. data/tmpsets/set/{mod011-settings → mod012-settings}/right/add_help.rb +0 -0
  181. data/tmpsets/set/{mod011-settings → mod012-settings}/right/comment.rb +0 -0
  182. data/tmpsets/set/{mod011-settings → mod012-settings}/right/create.rb +0 -0
  183. data/tmpsets/set/{mod011-settings → mod012-settings}/right/default.rb +0 -0
  184. data/tmpsets/set/{mod011-settings → mod012-settings}/right/delete.rb +0 -0
  185. data/tmpsets/set/{mod011-settings → mod012-settings}/right/help.rb +0 -0
  186. data/tmpsets/set/{mod011-settings → mod012-settings}/right/read.rb +0 -0
  187. data/tmpsets/set/{mod011-settings → mod012-settings}/right/script.rb +1 -1
  188. data/tmpsets/set/{mod011-settings → mod012-settings}/right/structure.rb +0 -0
  189. data/tmpsets/set/{mod011-settings → mod012-settings}/right/style.rb +1 -1
  190. data/tmpsets/set/{mod011-settings → mod012-settings}/right/update.rb +0 -0
  191. data/tmpsets/set/{mod011-settings → mod012-settings}/self/accountable.rb +0 -0
  192. data/tmpsets/set/{mod011-settings → mod012-settings}/self/add_help.rb +0 -0
  193. data/tmpsets/set/{mod011-settings → mod012-settings}/self/autoname.rb +0 -0
  194. data/tmpsets/set/{mod011-settings → mod012-settings}/self/captcha.rb +0 -0
  195. data/tmpsets/set/{mod011-settings → mod012-settings}/self/create.rb +0 -0
  196. data/tmpsets/set/{mod011-settings → mod012-settings}/self/default.rb +0 -0
  197. data/tmpsets/set/{mod011-settings → mod012-settings}/self/default_html_view.rb +0 -0
  198. data/tmpsets/set/{mod011-settings → mod012-settings}/self/delete.rb +0 -0
  199. data/tmpsets/set/{mod011-settings → mod012-settings}/self/follow_fields.rb +0 -0
  200. data/tmpsets/set/{mod011-settings → mod012-settings}/self/help.rb +0 -0
  201. data/tmpsets/set/{mod011-settings → mod012-settings}/self/input.rb +0 -0
  202. data/tmpsets/set/{mod011-settings → mod012-settings}/self/layout.rb +0 -0
  203. data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_create.rb +0 -0
  204. data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_delete.rb +0 -0
  205. data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_update.rb +0 -0
  206. data/tmpsets/set/{mod011-settings → mod012-settings}/self/options.rb +0 -0
  207. data/tmpsets/set/{mod011-settings → mod012-settings}/self/options_label.rb +0 -0
  208. data/tmpsets/set/{mod011-settings → mod012-settings}/self/read.rb +0 -0
  209. data/tmpsets/set/{mod011-settings → mod012-settings}/self/recent_settings.rb +0 -0
  210. data/tmpsets/set/{mod011-settings → mod012-settings}/self/script.rb +0 -0
  211. data/tmpsets/set/{mod011-settings → mod012-settings}/self/structure.rb +0 -0
  212. data/tmpsets/set/{mod011-settings → mod012-settings}/self/style.rb +0 -0
  213. data/tmpsets/set/{mod011-settings → mod012-settings}/self/table_of_contents.rb +0 -0
  214. data/tmpsets/set/{mod011-settings → mod012-settings}/self/thanks.rb +0 -0
  215. data/tmpsets/set/{mod011-settings → mod012-settings}/self/update.rb +0 -0
  216. data/tmpsets/set/{mod011-settings → mod012-settings}/type/setting.rb +0 -0
  217. data/tmpsets/set/{mod012-email → mod013-email}/all/email_html.rb +0 -0
  218. data/tmpsets/set/{mod012-email → mod013-email}/all/email_text.rb +0 -0
  219. data/tmpsets/set/{mod012-email → mod013-email}/all/follow.rb +0 -0
  220. data/tmpsets/set/{mod012-email → mod013-email}/all/notify.rb +0 -0
  221. data/tmpsets/set/{mod012-email → mod013-email}/all/observer.rb +0 -0
  222. data/tmpsets/set/{mod012-email → mod013-email}/right/bcc.rb +0 -0
  223. data/tmpsets/set/{mod012-email → mod013-email}/right/cc.rb +0 -0
  224. data/tmpsets/set/{mod012-email → mod013-email}/right/follow.rb +0 -0
  225. data/tmpsets/set/{mod012-email → mod013-email}/right/follow_fields.rb +0 -0
  226. data/tmpsets/set/{mod012-email → mod013-email}/right/followers.rb +0 -0
  227. data/tmpsets/set/{mod012-email → mod013-email}/right/following.rb +0 -0
  228. data/tmpsets/set/{mod012-email → mod013-email}/right/from.rb +0 -0
  229. data/tmpsets/set/{mod012-email → mod013-email}/right/html_message.rb +0 -0
  230. data/tmpsets/set/{mod012-email → mod013-email}/right/to.rb +0 -0
  231. data/tmpsets/set/{mod012-email → mod013-email}/self/always.rb +0 -0
  232. data/tmpsets/set/{mod012-email → mod013-email}/self/created.rb +0 -0
  233. data/tmpsets/set/{mod012-email → mod013-email}/self/edited.rb +0 -0
  234. data/tmpsets/set/{mod012-email → mod013-email}/self/follow.rb +0 -0
  235. data/tmpsets/set/{mod012-email → mod013-email}/self/follow_defaults.rb +0 -0
  236. data/tmpsets/set/{mod012-email → mod013-email}/self/never.rb +0 -0
  237. data/tmpsets/set/{mod012-email → mod013-email}/type/email_template.rb +0 -0
  238. data/tmpsets/set/{mod012-email → mod013-email}/type_plus_right/user/follow.rb +4 -8
  239. data/tmpsets/set/{mod015-developer → mod014-developer}/all/event_viz.rb +0 -0
  240. data/tmpsets/set/{mod015-developer → mod014-developer}/all/view_viz.rb +0 -0
  241. data/tmpsets/set/{mod015-developer → mod014-developer}/right/debug.rb +0 -0
  242. data/tmpsets/set/mod015-carrierwave/abstract/attachment.rb +118 -0
  243. data/tmpsets/set/mod015-carrierwave/abstract/attachment/paths.rb +57 -0
  244. data/tmpsets/set/mod015-carrierwave/abstract/attachment/storage_type.rb +326 -0
  245. data/tmpsets/set/mod015-carrierwave/abstract/attachment/upload_cache.rb +84 -0
  246. data/tmpsets/set/mod015-carrierwave/all/file_utils.rb +35 -0
  247. data/tmpsets/set/mod015-carrierwave/self/admin.rb +30 -0
  248. data/tmpsets/set/{mod013-carrierwave → mod015-carrierwave}/type/file.rb +27 -24
  249. data/tmpsets/set/{mod013-carrierwave → mod015-carrierwave}/type/image.rb +1 -0
  250. data/tmpsets/set/mod016-standard/all/links.rb +2 -2
  251. data/tmpsets/set/mod018-bootstrap/all/bootstrap/table.rb +1 -1
  252. data/tmpsets/set/mod018-bootstrap/self/bootswatch_shared.rb +1 -1
  253. data/vendor/carrierwave/.gitignore +19 -0
  254. data/vendor/carrierwave/.rubocop.yml +262 -0
  255. data/vendor/carrierwave/.travis.yml +58 -0
  256. data/vendor/carrierwave/CHANGELOG.md +81 -0
  257. data/vendor/carrierwave/CONTRIBUTING.md +37 -0
  258. data/vendor/carrierwave/Gemfile +5 -0
  259. data/vendor/carrierwave/README.md +995 -0
  260. data/vendor/carrierwave/Rakefile +26 -0
  261. data/vendor/carrierwave/carrierwave.gemspec +45 -0
  262. data/vendor/carrierwave/cucumber.yml +2 -0
  263. data/vendor/carrierwave/features/caching.feature +28 -0
  264. data/vendor/carrierwave/features/download.feature +20 -0
  265. data/vendor/carrierwave/features/file_storage.feature +37 -0
  266. data/vendor/carrierwave/features/file_storage_overridden_filename.feature +38 -0
  267. data/vendor/carrierwave/features/file_storage_overridden_store_dir.feature +38 -0
  268. data/vendor/carrierwave/features/file_storage_reversing_processor.feature +43 -0
  269. data/vendor/carrierwave/features/fixtures/bork.txt +1 -0
  270. data/vendor/carrierwave/features/fixtures/monkey.txt +1 -0
  271. data/vendor/carrierwave/features/fixtures/upcased_bork.txt +1 -0
  272. data/vendor/carrierwave/features/mount_activerecord.feature +46 -0
  273. data/vendor/carrierwave/features/step_definitions/activerecord_steps.rb +20 -0
  274. data/vendor/carrierwave/features/step_definitions/caching_steps.rb +12 -0
  275. data/vendor/carrierwave/features/step_definitions/datamapper_steps.rb +27 -0
  276. data/vendor/carrierwave/features/step_definitions/download_steps.rb +8 -0
  277. data/vendor/carrierwave/features/step_definitions/file_steps.rb +51 -0
  278. data/vendor/carrierwave/features/step_definitions/general_steps.rb +102 -0
  279. data/vendor/carrierwave/features/step_definitions/mount_steps.rb +17 -0
  280. data/vendor/carrierwave/features/step_definitions/store_steps.rb +16 -0
  281. data/vendor/carrierwave/features/support/activerecord.rb +18 -0
  282. data/vendor/carrierwave/features/support/env.rb +19 -0
  283. data/vendor/carrierwave/features/versions_basics.feature +50 -0
  284. data/vendor/carrierwave/features/versions_caching_from_versions.feature +32 -0
  285. data/vendor/carrierwave/features/versions_nested_versions.feature +70 -0
  286. data/vendor/carrierwave/features/versions_overridden_filename.feature +51 -0
  287. data/vendor/carrierwave/features/versions_overriden_store_dir.feature +41 -0
  288. data/vendor/carrierwave/gemfiles/rails-4-0-stable.gemfile +5 -0
  289. data/vendor/carrierwave/gemfiles/rails-4-1-stable.gemfile +5 -0
  290. data/vendor/carrierwave/gemfiles/rails-4-2-stable.gemfile +5 -0
  291. data/vendor/carrierwave/gemfiles/rails-master.gemfile +11 -0
  292. data/vendor/carrierwave/lib/carrierwave.rb +93 -0
  293. data/vendor/carrierwave/lib/carrierwave/compatibility/paperclip.rb +103 -0
  294. data/vendor/carrierwave/lib/carrierwave/error.rb +8 -0
  295. data/vendor/carrierwave/lib/carrierwave/locale/cs.yml +14 -0
  296. data/vendor/carrierwave/lib/carrierwave/locale/de.yml +14 -0
  297. data/vendor/carrierwave/lib/carrierwave/locale/el.yml +14 -0
  298. data/vendor/carrierwave/lib/carrierwave/locale/en.yml +14 -0
  299. data/vendor/carrierwave/lib/carrierwave/locale/es.yml +14 -0
  300. data/vendor/carrierwave/lib/carrierwave/locale/fr-CA.yml +14 -0
  301. data/vendor/carrierwave/lib/carrierwave/locale/fr.yml +14 -0
  302. data/vendor/carrierwave/lib/carrierwave/locale/id.yml +14 -0
  303. data/vendor/carrierwave/lib/carrierwave/locale/ja.yml +14 -0
  304. data/vendor/carrierwave/lib/carrierwave/locale/nb.yml +14 -0
  305. data/vendor/carrierwave/lib/carrierwave/locale/nl.yml +14 -0
  306. data/vendor/carrierwave/lib/carrierwave/locale/pl.yml +14 -0
  307. data/vendor/carrierwave/lib/carrierwave/locale/pt-BR.yml +14 -0
  308. data/vendor/carrierwave/lib/carrierwave/locale/pt-PT.yml +14 -0
  309. data/vendor/carrierwave/lib/carrierwave/locale/ru.yml +14 -0
  310. data/vendor/carrierwave/lib/carrierwave/locale/sk.yml +14 -0
  311. data/vendor/carrierwave/lib/carrierwave/locale/tr.yml +14 -0
  312. data/vendor/carrierwave/lib/carrierwave/locale/zh-CN.yml +14 -0
  313. data/vendor/carrierwave/lib/carrierwave/locale/zh-TW.yml +14 -0
  314. data/vendor/carrierwave/lib/carrierwave/mount.rb +444 -0
  315. data/vendor/carrierwave/lib/carrierwave/mounter.rb +163 -0
  316. data/vendor/carrierwave/lib/carrierwave/orm/activerecord.rb +103 -0
  317. data/vendor/carrierwave/lib/carrierwave/processing.rb +2 -0
  318. data/vendor/carrierwave/lib/carrierwave/processing/mini_magick.rb +328 -0
  319. data/vendor/carrierwave/lib/carrierwave/processing/rmagick.rb +379 -0
  320. data/vendor/carrierwave/lib/carrierwave/sanitized_file.rb +348 -0
  321. data/vendor/carrierwave/lib/carrierwave/storage.rb +2 -0
  322. data/vendor/carrierwave/lib/carrierwave/storage/abstract.rb +43 -0
  323. data/vendor/carrierwave/lib/carrierwave/storage/file.rb +118 -0
  324. data/vendor/carrierwave/lib/carrierwave/storage/fog.rb +462 -0
  325. data/vendor/carrierwave/lib/carrierwave/test/matchers.rb +394 -0
  326. data/vendor/carrierwave/lib/carrierwave/uploader.rb +67 -0
  327. data/vendor/carrierwave/lib/carrierwave/uploader/cache.rb +207 -0
  328. data/vendor/carrierwave/lib/carrierwave/uploader/callbacks.rb +33 -0
  329. data/vendor/carrierwave/lib/carrierwave/uploader/configuration.rb +203 -0
  330. data/vendor/carrierwave/lib/carrierwave/uploader/content_type_blacklist.rb +48 -0
  331. data/vendor/carrierwave/lib/carrierwave/uploader/content_type_whitelist.rb +48 -0
  332. data/vendor/carrierwave/lib/carrierwave/uploader/default_url.rb +17 -0
  333. data/vendor/carrierwave/lib/carrierwave/uploader/download.rb +92 -0
  334. data/vendor/carrierwave/lib/carrierwave/uploader/extension_blacklist.rb +51 -0
  335. data/vendor/carrierwave/lib/carrierwave/uploader/extension_whitelist.rb +51 -0
  336. data/vendor/carrierwave/lib/carrierwave/uploader/file_size.rb +41 -0
  337. data/vendor/carrierwave/lib/carrierwave/uploader/magic_mime_blacklist.rb +94 -0
  338. data/vendor/carrierwave/lib/carrierwave/uploader/magic_mime_whitelist.rb +94 -0
  339. data/vendor/carrierwave/lib/carrierwave/uploader/mountable.rb +38 -0
  340. data/vendor/carrierwave/lib/carrierwave/uploader/processing.rb +88 -0
  341. data/vendor/carrierwave/lib/carrierwave/uploader/proxy.rb +86 -0
  342. data/vendor/carrierwave/lib/carrierwave/uploader/remove.rb +21 -0
  343. data/vendor/carrierwave/lib/carrierwave/uploader/serialization.rb +28 -0
  344. data/vendor/carrierwave/lib/carrierwave/uploader/store.rb +93 -0
  345. data/vendor/carrierwave/lib/carrierwave/uploader/url.rb +41 -0
  346. data/vendor/carrierwave/lib/carrierwave/uploader/versions.rb +295 -0
  347. data/vendor/carrierwave/lib/carrierwave/utilities.rb +6 -0
  348. data/vendor/carrierwave/lib/carrierwave/utilities/uri.rb +21 -0
  349. data/vendor/carrierwave/lib/carrierwave/validations/active_model.rb +78 -0
  350. data/vendor/carrierwave/lib/carrierwave/version.rb +3 -0
  351. data/vendor/carrierwave/lib/generators/templates/uploader.rb +49 -0
  352. data/vendor/carrierwave/lib/generators/uploader_generator.rb +7 -0
  353. data/vendor/carrierwave/script/console +10 -0
  354. data/vendor/carrierwave/script/destroy +14 -0
  355. data/vendor/carrierwave/script/generate +14 -0
  356. data/vendor/carrierwave/spec/compatibility/paperclip_spec.rb +138 -0
  357. data/vendor/carrierwave/spec/fixtures/Uppercase.jpg +1 -0
  358. data/vendor/carrierwave/spec/fixtures/bork.ttxt +1 -0
  359. data/vendor/carrierwave/spec/fixtures/bork.txt +1 -0
  360. data/vendor/carrierwave/spec/fixtures/bork.txtt +1 -0
  361. data/vendor/carrierwave/spec/fixtures/case.JPG +1 -0
  362. data/vendor/carrierwave/spec/fixtures/landscape.jpg +0 -0
  363. data/vendor/carrierwave/spec/fixtures/multi_page.pdf +0 -0
  364. data/vendor/carrierwave/spec/fixtures/new.jpeg +1 -0
  365. data/vendor/carrierwave/spec/fixtures/new.txt +1 -0
  366. data/vendor/carrierwave/spec/fixtures/old.jpeg +1 -0
  367. data/vendor/carrierwave/spec/fixtures/old.txt +1 -0
  368. data/vendor/carrierwave/spec/fixtures/portrait.jpg +0 -0
  369. data/vendor/carrierwave/spec/fixtures/ruby.gif +0 -0
  370. data/vendor/carrierwave/spec/fixtures/sponsored.doc +1 -0
  371. data/vendor/carrierwave/spec/fixtures/test+.jpg +1 -0
  372. data/vendor/carrierwave/spec/fixtures/test.jpeg +1 -0
  373. data/vendor/carrierwave/spec/fixtures/test.jpg +1 -0
  374. data/vendor/carrierwave/spec/generators/uploader_generator_spec.rb +19 -0
  375. data/vendor/carrierwave/spec/mount_multiple_spec.rb +913 -0
  376. data/vendor/carrierwave/spec/mount_single_spec.rb +793 -0
  377. data/vendor/carrierwave/spec/orm/activerecord_spec.rb +1556 -0
  378. data/vendor/carrierwave/spec/processing/mini_magick_spec.rb +210 -0
  379. data/vendor/carrierwave/spec/processing/rmagick_spec.rb +250 -0
  380. data/vendor/carrierwave/spec/sanitized_file_spec.rb +805 -0
  381. data/vendor/carrierwave/spec/spec_helper.rb +105 -0
  382. data/vendor/carrierwave/spec/storage/file_spec.rb +82 -0
  383. data/vendor/carrierwave/spec/storage/fog_credentials.rb +46 -0
  384. data/vendor/carrierwave/spec/storage/fog_helper.rb +428 -0
  385. data/vendor/carrierwave/spec/storage/fog_spec.rb +48 -0
  386. data/vendor/carrierwave/spec/support/activerecord.rb +31 -0
  387. data/vendor/carrierwave/spec/support/file_utils_helper.rb +15 -0
  388. data/vendor/carrierwave/spec/uploader/cache_spec.rb +324 -0
  389. data/vendor/carrierwave/spec/uploader/callback_spec.rb +30 -0
  390. data/vendor/carrierwave/spec/uploader/configuration_spec.rb +133 -0
  391. data/vendor/carrierwave/spec/uploader/content_type_blacklist_spec.rb +61 -0
  392. data/vendor/carrierwave/spec/uploader/content_type_whitelist_spec.rb +63 -0
  393. data/vendor/carrierwave/spec/uploader/default_url_spec.rb +77 -0
  394. data/vendor/carrierwave/spec/uploader/download_spec.rb +204 -0
  395. data/vendor/carrierwave/spec/uploader/extension_blacklist_spec.rb +112 -0
  396. data/vendor/carrierwave/spec/uploader/extension_whitelist_spec.rb +102 -0
  397. data/vendor/carrierwave/spec/uploader/file_size_spec.rb +52 -0
  398. data/vendor/carrierwave/spec/uploader/mountable_spec.rb +26 -0
  399. data/vendor/carrierwave/spec/uploader/overrides_spec.rb +71 -0
  400. data/vendor/carrierwave/spec/uploader/paths_spec.rb +18 -0
  401. data/vendor/carrierwave/spec/uploader/processing_spec.rb +159 -0
  402. data/vendor/carrierwave/spec/uploader/proxy_spec.rb +79 -0
  403. data/vendor/carrierwave/spec/uploader/remove_spec.rb +71 -0
  404. data/vendor/carrierwave/spec/uploader/store_spec.rb +400 -0
  405. data/vendor/carrierwave/spec/uploader/url_spec.rb +273 -0
  406. data/vendor/carrierwave/spec/uploader/versions_spec.rb +633 -0
  407. metadata +339 -187
  408. data/config/initializers/extensions.rb +0 -3
  409. data/mod/05_standard/file/favicon/image-icon.png +0 -0
  410. data/mod/05_standard/file/favicon/image-large.png +0 -0
  411. data/mod/05_standard/file/favicon/image-medium.png +0 -0
  412. data/mod/05_standard/file/favicon/image-original.png +0 -0
  413. data/mod/05_standard/file/favicon/image-small.png +0 -0
  414. data/mod/machines/lib/card/machine.rb +0 -261
  415. data/mod/machines/lib/card/machine_input.rb +0 -80
  416. data/mod/standard/file/credit/icon-image.png +0 -0
  417. data/mod/standard/file/credit/large-image.png +0 -0
  418. data/mod/standard/file/credit/medium-image.png +0 -0
  419. data/mod/standard/file/credit/original-image.png +0 -0
  420. data/mod/standard/file/credit/small-image.png +0 -0
  421. data/mod/standard/spec/set/type/file_spec.rb +0 -99
  422. data/tmpsets/set/mod001-core/all/tracked_attributes.rb +0 -154
  423. data/tmpsets/set/mod001-core/all/utils.rb +0 -132
  424. data/tmpsets/set/mod013-carrierwave/abstract/attachment.rb +0 -282
@@ -0,0 +1,273 @@
1
+ require 'spec_helper'
2
+ require 'active_support/json'
3
+
4
+ describe CarrierWave::Uploader do
5
+
6
+ let(:uploader) { MyCoolUploader.new }
7
+
8
+ before { class MyCoolUploader < CarrierWave::Uploader::Base; end }
9
+
10
+ after do
11
+ FileUtils.rm_rf(public_path)
12
+ Object.send(:remove_const, "MyCoolUploader") if defined?(::MyCoolUploader)
13
+ end
14
+
15
+ let(:cache_id) { '1369894322-345-1234-2255' }
16
+ let(:test_file) { File.open(file_path(test_file_name)) }
17
+ let(:test_file_name) { 'test.jpg' }
18
+
19
+ before { allow(CarrierWave).to receive(:generate_cache_id).and_return(cache_id) }
20
+
21
+ describe '#url' do
22
+ subject(:url) { uploader.url }
23
+
24
+ it { is_expected.to be_nil }
25
+
26
+ it "doesn't raise exception when hash specified as argument" do
27
+ expect { uploader.url({}) }.not_to raise_error
28
+ end
29
+
30
+ it "encodes the path of a file without an asset host" do
31
+ uploader.cache!(File.open(file_path('test+.jpg')))
32
+ is_expected.to eq("/uploads/tmp/#{cache_id}/test%2B.jpg")
33
+ end
34
+
35
+ context "with a cached file" do
36
+ before { uploader.cache!(test_file) }
37
+
38
+ it "gets the directory relative to public, prepending a slash" do
39
+ is_expected.to eq("/uploads/tmp/#{cache_id}/#{test_file_name}")
40
+ end
41
+
42
+ describe "File#url" do
43
+ before do
44
+ allow(uploader.file).to receive(:url).and_return(file_url)
45
+ end
46
+
47
+ context "when present" do
48
+ let(:file_url) { 'http://www.example.com/someurl.jpg' }
49
+
50
+ it { is_expected.to eq(file_url) }
51
+ end
52
+
53
+ context "when blank" do
54
+ let(:file_url) { '' }
55
+
56
+ it "returns the relative path" do
57
+ is_expected.to eq("/uploads/tmp/#{cache_id}/#{test_file_name}")
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ context "when File#url method doesn't get params" do
64
+ before do
65
+ module StorageX
66
+ class File
67
+ def url
68
+ true
69
+ end
70
+ end
71
+ end
72
+
73
+ allow(uploader).to receive(:file).and_return(StorageX::File.new)
74
+ end
75
+
76
+ it "raises ArgumentError" do
77
+ expect { uploader.url }.not_to raise_error
78
+ end
79
+ end
80
+
81
+ describe "(:thumb)" do
82
+ subject { uploader.url(:thumb) }
83
+
84
+ it "raises ArgumentError when version doesn't exist" do
85
+ expect { uploader.url(:thumb) }.to raise_error(ArgumentError)
86
+ end
87
+
88
+ context "when version is specified" do
89
+ before do
90
+ MyCoolUploader.version(:thumb)
91
+ uploader.cache!(test_file)
92
+ end
93
+
94
+ it "doesn't raise ArgumentError when versions version exists" do
95
+ expect { uploader.url(:thumb) }.not_to raise_error
96
+ end
97
+
98
+ it "gets the directory relative to public for a specific version" do
99
+ is_expected.to eq("/uploads/tmp/#{cache_id}/thumb_#{test_file_name}")
100
+ end
101
+
102
+ describe "asset_host" do
103
+ before { uploader.class.configure { |config| config.asset_host = asset_host } }
104
+
105
+ context "when set as a string" do
106
+ let(:asset_host) { "http://foo.bar" }
107
+
108
+ it "prepends the string" do
109
+ is_expected.to eq("#{asset_host}/uploads/tmp/#{cache_id}/thumb_#{test_file_name}")
110
+ end
111
+
112
+ describe "encoding" do
113
+ let(:test_file_name) { 'test+.jpg' }
114
+
115
+ it "encodes the path of a file" do
116
+ is_expected.to eq("#{asset_host}/uploads/tmp/#{cache_id}/thumb_test%2B.jpg")
117
+ end
118
+
119
+ it "double-encodes the path of an available File#url" do
120
+ url = 'http://www.example.com/directory%2Bname/another%2Bdirectory/some%2Burl.jpg'
121
+ allow(uploader.file).to receive(:url).and_return(url)
122
+
123
+ expect(uploader.url).to eq(url)
124
+ end
125
+ end
126
+ end
127
+
128
+ context "when set as a proc" do
129
+ let(:asset_host) { proc { "http://foo.bar" } }
130
+
131
+ it "prepends the result of proc" do
132
+ is_expected.to eq("#{asset_host.call}/uploads/tmp/#{cache_id}/thumb_#{test_file_name}")
133
+ end
134
+
135
+ describe "encoding" do
136
+ let(:test_file_name) { 'test+.jpg' }
137
+
138
+ it { is_expected.to eq("#{asset_host.call}/uploads/tmp/#{cache_id}/thumb_test%2B.jpg") }
139
+ end
140
+ end
141
+
142
+ context "when set as nil" do
143
+ let(:asset_host) { nil }
144
+
145
+ context "when base_path is set" do
146
+ let(:base_path) { "/base_path" }
147
+
148
+ before do
149
+ uploader.class.configure do |config|
150
+ config.base_path = base_path
151
+ end
152
+ end
153
+
154
+ it "prepends the config option 'base_path'" do
155
+ is_expected.to eq("#{base_path}/uploads/tmp/#{cache_id}/thumb_#{test_file_name}")
156
+ end
157
+ end
158
+ end
159
+ end
160
+ end
161
+
162
+ context "when the version is nested" do
163
+ subject { uploader.url(:thumb, :mini) }
164
+
165
+ before do
166
+ MyCoolUploader.version(:thumb) { version(:mini) }
167
+ uploader.cache!(test_file)
168
+ end
169
+
170
+ it "gets the directory relative to public for a nested version" do
171
+ is_expected.to eq("/uploads/tmp/#{cache_id}/thumb_mini_#{test_file_name}")
172
+ end
173
+ end
174
+ end
175
+ end
176
+
177
+ describe '#to_json' do
178
+ subject(:parsed_json) { JSON.parse(to_json) }
179
+
180
+ let(:to_json) { uploader.to_json }
181
+
182
+ context "(:thumb)" do
183
+ before { MyCoolUploader.version(:thumb) }
184
+
185
+ it { expect(parsed_json.keys).to include("url") }
186
+ it { expect(parsed_json.keys).to include("thumb") }
187
+ it { expect(parsed_json["url"]).to be_nil }
188
+ it { expect(parsed_json["thumb"].keys).to include("url") }
189
+ it { expect(parsed_json["thumb"]["url"]).to be_nil }
190
+
191
+ context "with a cached_file" do
192
+ before { uploader.cache!(test_file) }
193
+
194
+ it { expect(parsed_json.keys).to include("thumb") }
195
+ it { expect(parsed_json["thumb"]).to eq({"url" => "/uploads/tmp/#{cache_id}/thumb_#{test_file_name}"}) }
196
+ end
197
+ end
198
+
199
+ context "with cached file" do
200
+ before { uploader.cache!(test_file) }
201
+
202
+ it "returns a hash including a cached URL" do
203
+ is_expected.to eq({"url" => "/uploads/tmp/#{cache_id}/#{test_file_name}"})
204
+ end
205
+ end
206
+
207
+ it "allows an options parameter to be passed in" do
208
+ expect { uploader.to_json({:some => 'options'}) }.not_to raise_error
209
+ end
210
+ end
211
+
212
+ describe '#to_xml' do
213
+ subject(:parsed_xml) { Hash.from_xml(to_xml) }
214
+
215
+ let(:to_xml) { uploader.to_xml }
216
+
217
+ it "returns a hash with a blank URL" do
218
+ is_expected.to eq({"uploader" => {"url" => nil}})
219
+ end
220
+
221
+ context "with cached file" do
222
+ before { uploader.cache!(test_file) }
223
+
224
+ it "returns a hash including a cached URL" do
225
+ is_expected.to eq({"uploader" => {"url" => "/uploads/tmp/#{cache_id}/#{test_file_name}"}})
226
+ end
227
+
228
+ context "with an array of uploaders" do
229
+ let(:to_xml) { [uploader].to_xml }
230
+
231
+ it "returns a hash including an array with a cached URL" do
232
+ is_expected.to have_value([{"url"=>"/uploads/tmp/#{cache_id}/#{test_file_name}"}])
233
+ end
234
+ end
235
+ end
236
+
237
+ describe "(:thumb)" do
238
+ before { MyCoolUploader.version(:thumb) }
239
+
240
+ context "with cached file" do
241
+ before { uploader.cache!(test_file) }
242
+
243
+ it "returns a hash including a cached URL of a version" do
244
+ expect(parsed_xml["uploader"]["thumb"]).to eq({"url" => "/uploads/tmp/#{cache_id}/thumb_#{test_file_name}"})
245
+ end
246
+ end
247
+ end
248
+ end
249
+
250
+ describe '#to_s' do
251
+ subject { uploader.to_s }
252
+
253
+ it { is_expected.to eq('') }
254
+
255
+ context "with cached file" do
256
+ before { uploader.cache!(test_file) }
257
+
258
+ it "gets the directory relative to public, prepending a slash" do
259
+ is_expected.to eq("/uploads/tmp/#{cache_id}/#{test_file_name}")
260
+ end
261
+
262
+ describe "File#url" do
263
+ before { allow(uploader.file).to receive(:url).and_return(url) }
264
+
265
+ context "when present" do
266
+ let(:url) { 'http://www.example.com/someurl.jpg' }
267
+
268
+ it { is_expected.to eq(url) }
269
+ end
270
+ end
271
+ end
272
+ end
273
+ end
@@ -0,0 +1,633 @@
1
+ require 'spec_helper'
2
+
3
+ describe CarrierWave::Uploader do
4
+
5
+ before do
6
+ @uploader_class = Class.new(CarrierWave::Uploader::Base)
7
+ @uploader = @uploader_class.new
8
+ end
9
+
10
+ after do
11
+ FileUtils.rm_rf(public_path)
12
+ end
13
+
14
+ describe '.version' do
15
+ it "should add it to .versions" do
16
+ @uploader_class.version :thumb
17
+ expect(@uploader_class.versions[:thumb]).to be_a(Class)
18
+ expect(@uploader_class.versions[:thumb].ancestors).to include(@uploader_class)
19
+ end
20
+
21
+ it "should only assign versions to parent" do
22
+ @uploader_class.version :large
23
+ @uploader_class.version :thumb do
24
+ version :mini do
25
+ version :micro
26
+ end
27
+ end
28
+ expect(@uploader_class.versions.size).to eq(2)
29
+ expect(@uploader_class.versions).to include :large
30
+ expect(@uploader_class.versions).to include :thumb
31
+ expect(@uploader.large.versions).to be_empty
32
+ expect(@uploader.thumb.versions.keys).to eq([:mini])
33
+ expect(@uploader.thumb.mini.versions.keys).to eq([:micro])
34
+ expect(@uploader.thumb.mini.micro.versions).to be_empty
35
+ end
36
+
37
+ it "should add an accessor which returns the version" do
38
+ @uploader_class.version :thumb
39
+ expect(@uploader.thumb).to be_a(@uploader_class)
40
+ end
41
+
42
+ it "should add it to #versions which returns the version" do
43
+ @uploader_class.version :thumb
44
+ expect(@uploader.versions[:thumb]).to be_a(@uploader_class)
45
+ end
46
+
47
+ it "should set the version name" do
48
+ @uploader_class.version :thumb
49
+ expect(@uploader.version_name).to eq(nil)
50
+ expect(@uploader.thumb.version_name).to eq(:thumb)
51
+ end
52
+
53
+ it "should set the version names on the class" do
54
+ @uploader_class.version :thumb
55
+ expect(@uploader.class.version_names).to eq([])
56
+ expect(@uploader.thumb.class.version_names).to eq([:thumb])
57
+ end
58
+
59
+ it "should remember mount options" do
60
+ model = double('a model')
61
+ @uploader_class.version :thumb
62
+ @uploader = @uploader_class.new(model, :gazelle)
63
+
64
+ expect(@uploader.thumb.model).to eq(model)
65
+ expect(@uploader.thumb.mounted_as).to eq(:gazelle)
66
+ end
67
+
68
+ it "should apply any overrides given in a block" do
69
+ @uploader_class.version :thumb do
70
+ def store_dir
71
+ public_path('monkey/apache')
72
+ end
73
+ end
74
+ expect(@uploader.store_dir).to eq('uploads')
75
+ expect(@uploader.thumb.store_dir).to eq(public_path('monkey/apache'))
76
+ end
77
+
78
+ it "should not initially have a value for enable processing" do
79
+ thumb = (@uploader_class.version :thumb)
80
+ expect(thumb.instance_variable_get('@enable_processing')).to be_nil
81
+ end
82
+
83
+ it "should return the enable processing value of the parent" do
84
+ @uploader_class.enable_processing = false
85
+ thumb = (@uploader_class.version :thumb)
86
+ expect(thumb.enable_processing).to be_falsey
87
+ end
88
+
89
+ it "should return its own value for enable processing if set" do
90
+ @uploader_class.enable_processing = false
91
+ thumb = @uploader_class.version :thumb
92
+ thumb.enable_processing = true
93
+ expect(thumb.enable_processing).to be_truthy
94
+ end
95
+
96
+ it "should reopen the same class when called multiple times" do
97
+ @uploader_class.version :thumb do
98
+ def self.monkey
99
+ "monkey"
100
+ end
101
+ end
102
+ @uploader_class.version :thumb do
103
+ def self.llama
104
+ "llama"
105
+ end
106
+ end
107
+ expect(@uploader_class.version(:thumb).monkey).to eq("monkey")
108
+ expect(@uploader_class.version(:thumb).llama).to eq("llama")
109
+ end
110
+
111
+ it "should reopen the same instance when called multiple times" do
112
+ @uploader_class.version :thumb do
113
+ def store_dir
114
+ public_path('monkey/apache')
115
+ end
116
+ end
117
+ @uploader_class.version :thumb do
118
+ def store_dir
119
+ public_path('monkey/apache/new')
120
+ end
121
+ end
122
+
123
+ expect(@uploader.thumb.store_dir).to eq(public_path('monkey/apache/new'))
124
+ end
125
+
126
+ it "should accept option :from_version" do
127
+ @uploader_class.version :small_thumb, :from_version => :thumb
128
+ expect(@uploader_class.version(:small_thumb).version_options[:from_version]).to eq(:thumb)
129
+ end
130
+
131
+ describe 'with nested versions' do
132
+ before do
133
+ @uploader_class.version :thumb do
134
+ version :mini
135
+ version :micro
136
+ end
137
+ end
138
+
139
+ it "should add an array of version names" do
140
+ expect(@uploader.class.version_names).to eq([])
141
+ expect(@uploader.thumb.class.version_names).to eq([:thumb])
142
+ expect(@uploader.thumb.mini.class.version_names).to eq([:thumb, :mini])
143
+ expect(@uploader.thumb.micro.class.version_names).to eq([:thumb, :micro])
144
+ end
145
+
146
+ it "should set the version name for the instances" do
147
+ expect(@uploader.version_name).to be_nil
148
+ expect(@uploader.thumb.version_name).to eq(:thumb)
149
+ expect(@uploader.thumb.mini.version_name).to eq(:thumb_mini)
150
+ expect(@uploader.thumb.micro.version_name).to eq(:thumb_micro)
151
+ end
152
+
153
+ it "should set the version name for the #versions" do
154
+ expect(@uploader.version_name).to be_nil
155
+ expect(@uploader.versions[:thumb].version_name).to eq(:thumb)
156
+ expect(@uploader.versions[:thumb].versions[:mini].version_name).to eq(:thumb_mini)
157
+ expect(@uploader.versions[:thumb].versions[:micro].version_name).to eq(:thumb_micro)
158
+ end
159
+
160
+ it "should process nested versions" do
161
+ @uploader_class.class_eval {
162
+ include CarrierWave::MiniMagick
163
+
164
+ version :rotated do
165
+ process :rotate
166
+
167
+ version :boxed do
168
+ process :resize_to_fit => [200, 200]
169
+ end
170
+ end
171
+
172
+ def rotate
173
+ manipulate! do |img|
174
+ img.rotate "90"
175
+ img
176
+ end
177
+ end
178
+ }
179
+ @uploader.cache! File.open(file_path('portrait.jpg'))
180
+
181
+ expect(@uploader).to have_dimensions(233, 337)
182
+ expect(@uploader.rotated).to have_dimensions(337, 233)
183
+ expect(@uploader.rotated.boxed).to have_dimensions(200, 138)
184
+ end
185
+ end
186
+
187
+ describe 'with inheritance' do
188
+
189
+ before do
190
+ @uploader_class.version :thumb do
191
+ def store_dir
192
+ public_path('monkey/apache')
193
+ end
194
+ end
195
+
196
+ @child_uploader_class = Class.new(@uploader_class)
197
+ @child_uploader = @child_uploader_class.new
198
+ end
199
+
200
+ it "should override parent version" do
201
+ @child_uploader_class.version :thumb do
202
+ def store_dir
203
+ public_path('monkey/apache/child')
204
+ end
205
+ end
206
+
207
+ expect(@child_uploader.thumb.store_dir).to eq(public_path('monkey/apache/child'))
208
+ end
209
+
210
+ it "shouldn't affect parent class' version" do
211
+ @child_uploader_class.version :thumb do
212
+ def store_dir
213
+ public_path('monkey/apache/child')
214
+ end
215
+ end
216
+
217
+ expect(@uploader.thumb.store_dir).to eq(public_path('monkey/apache'))
218
+ end
219
+ end
220
+ end
221
+
222
+ describe 'with a version' do
223
+ before do
224
+ @uploader_class.version(:thumb)
225
+ end
226
+
227
+ describe '#cache!' do
228
+
229
+ before do
230
+ allow(CarrierWave).to receive(:generate_cache_id).and_return('1369894322-345-1234-2255')
231
+ end
232
+
233
+ it "should set store_path with versions" do
234
+ expect(CarrierWave).to receive(:generate_cache_id).once
235
+ @uploader.cache!(File.open(file_path('test.jpg')))
236
+ expect(@uploader.store_path).to eq('uploads/test.jpg')
237
+ expect(@uploader.thumb.store_path).to eq('uploads/thumb_test.jpg')
238
+ expect(@uploader.thumb.store_path('kebab.png')).to eq('uploads/thumb_kebab.png')
239
+ end
240
+
241
+ it "should move it to the tmp dir with the filename prefixed" do
242
+ expect(CarrierWave).to receive(:generate_cache_id).once
243
+ @uploader.cache!(File.open(file_path('test.jpg')))
244
+ expect(@uploader.current_path).to eq(public_path('uploads/tmp/1369894322-345-1234-2255/test.jpg'))
245
+ expect(@uploader.thumb.current_path).to eq(public_path('uploads/tmp/1369894322-345-1234-2255/thumb_test.jpg'))
246
+ expect(@uploader.file.exists?).to be_truthy
247
+ expect(@uploader.thumb.file.exists?).to be_truthy
248
+ end
249
+
250
+ it "should cache the files based on the parent" do
251
+ expect(CarrierWave).to receive(:generate_cache_id).once
252
+ @uploader.cache!(File.open(file_path('bork.txt')))
253
+
254
+ expect(File.read(public_path(@uploader.to_s))).to eq(File.read(public_path(@uploader.thumb.to_s)))
255
+ end
256
+ end
257
+
258
+ describe "version with move_to_cache set" do
259
+ before do
260
+ FileUtils.cp(file_path('test.jpg'), file_path('test_copy.jpg'))
261
+ allow(CarrierWave).to receive(:generate_cache_id).and_return('1369894322-345-1234-2255')
262
+ @uploader_class.send(:define_method, :move_to_cache) do
263
+ true
264
+ end
265
+ end
266
+
267
+ after do
268
+ FileUtils.mv(file_path('test_copy.jpg'), file_path('test.jpg'))
269
+ end
270
+
271
+ it "should copy the parent file when creating the version" do
272
+ @uploader_class.version(:thumb)
273
+ @uploader.cache!(File.open(file_path('test.jpg')))
274
+ expect(@uploader.current_path).to eq(public_path('uploads/tmp/1369894322-345-1234-2255/test.jpg'))
275
+ expect(@uploader.thumb.current_path).to eq(public_path('uploads/tmp/1369894322-345-1234-2255/thumb_test.jpg'))
276
+ expect(@uploader.file.exists?).to be_truthy
277
+ expect(@uploader.thumb.file.exists?).to be_truthy
278
+ end
279
+
280
+ it "should allow overriding move_to_cache on versions" do
281
+ @uploader_class.version(:thumb) do
282
+ def move_to_cache
283
+ true
284
+ end
285
+ end
286
+ @uploader.cache!(File.open(file_path('test.jpg')))
287
+ expect(@uploader.current_path).to eq(public_path('uploads/tmp/1369894322-345-1234-2255/test.jpg'))
288
+ expect(@uploader.thumb.current_path).to eq(public_path('uploads/tmp/1369894322-345-1234-2255/thumb_test.jpg'))
289
+ expect(@uploader.file.exists?).to be_falsey
290
+ expect(@uploader.thumb.file.exists?).to be_truthy
291
+ end
292
+ end
293
+
294
+ describe '#retrieve_from_cache!' do
295
+ it "should set the path to the tmp dir" do
296
+ @uploader.retrieve_from_cache!('1369894322-345-1234-2255/test.jpg')
297
+ expect(@uploader.current_path).to eq(public_path('uploads/tmp/1369894322-345-1234-2255/test.jpg'))
298
+ expect(@uploader.thumb.current_path).to eq(public_path('uploads/tmp/1369894322-345-1234-2255/thumb_test.jpg'))
299
+ end
300
+
301
+ it "should set store_path with versions" do
302
+ @uploader.retrieve_from_cache!('1369894322-345-1234-2255/test.jpg')
303
+ expect(@uploader.store_path).to eq('uploads/test.jpg')
304
+ expect(@uploader.thumb.store_path).to eq('uploads/thumb_test.jpg')
305
+ expect(@uploader.thumb.store_path('kebab.png')).to eq('uploads/thumb_kebab.png')
306
+ end
307
+ end
308
+
309
+ describe '#store!' do
310
+ before do
311
+ @uploader_class.storage = mock_storage('base')
312
+ @uploader_class.version(:thumb).storage = mock_storage('thumb')
313
+ @uploader_class.version(:preview).storage = mock_storage('preview')
314
+
315
+ @file = File.open(file_path('test.jpg'))
316
+
317
+ @base_stored_file = double('a stored file')
318
+ allow(@base_stored_file).to receive(:path).and_return('/path/to/somewhere')
319
+ allow(@base_stored_file).to receive(:url).and_return('http://www.example.com')
320
+
321
+ @thumb_stored_file = double('a thumb version of a stored file')
322
+ allow(@thumb_stored_file).to receive(:path).and_return('/path/to/somewhere/thumb')
323
+ allow(@thumb_stored_file).to receive(:url).and_return('http://www.example.com/thumb')
324
+
325
+ @preview_stored_file = double('a preview version of a stored file')
326
+ allow(@preview_stored_file).to receive(:path).and_return('/path/to/somewhere/preview')
327
+ allow(@preview_stored_file).to receive(:url).and_return('http://www.example.com/preview')
328
+
329
+ @storage = double('a storage engine')
330
+ allow(@storage).to receive(:store!).and_return(@base_stored_file)
331
+
332
+ @thumb_storage = double('a storage engine for thumbnails')
333
+ allow(@thumb_storage).to receive(:store!).and_return(@thumb_stored_file)
334
+
335
+ @preview_storage = double('a storage engine for previews')
336
+ allow(@preview_storage).to receive(:store!).and_return(@preview_stored_file)
337
+
338
+ allow(@uploader_class.storage).to receive(:new).with(@uploader).and_return(@storage)
339
+ allow(@uploader_class.version(:thumb).storage).to receive(:new).and_return(@thumb_storage)
340
+ allow(@uploader_class.version(:preview).storage).to receive(:new).and_return(@preview_storage)
341
+ end
342
+
343
+ it "should set the current path for the version" do
344
+ @uploader.store!(@file)
345
+ expect(@uploader.current_path).to eq('/path/to/somewhere')
346
+ expect(@uploader.thumb.current_path).to eq('/path/to/somewhere/thumb')
347
+ end
348
+
349
+ it "should set the url" do
350
+ @uploader.store!(@file)
351
+ expect(@uploader.url).to eq('http://www.example.com')
352
+ expect(@uploader.thumb.url).to eq('http://www.example.com/thumb')
353
+ end
354
+
355
+ it "should, if a file is given as argument, set the store_path" do
356
+ @uploader.store!(@file)
357
+ expect(@uploader.store_path).to eq('uploads/test.jpg')
358
+ expect(@uploader.thumb.store_path).to eq('uploads/thumb_test.jpg')
359
+ expect(@uploader.thumb.store_path('kebab.png')).to eq('uploads/thumb_kebab.png')
360
+ end
361
+
362
+ it "should instruct the storage engine to store the file and its version" do
363
+ @uploader.cache!(@file)
364
+ expect(@storage).to receive(:store!).with(@uploader.file).and_return(:monkey)
365
+ expect(@thumb_storage).to receive(:store!).with(@uploader.thumb.file).and_return(:gorilla)
366
+ @uploader.store!
367
+ end
368
+
369
+ it "should process conditional versions if the condition method returns true" do
370
+ @uploader_class.version(:preview).version_options[:if] = :true?
371
+ expect(@uploader).to receive(:true?).at_least(:once).and_return(true)
372
+ @uploader.store!(@file)
373
+ expect(@uploader.thumb).to be_present
374
+ expect(@uploader.preview).to be_present
375
+ end
376
+
377
+ it "should not process conditional versions if the condition method returns false" do
378
+ @uploader_class.version(:preview).version_options[:if] = :false?
379
+ expect(@uploader).to receive(:false?).at_least(:once).and_return(false)
380
+ @uploader.store!(@file)
381
+ expect(@uploader.thumb).to be_present
382
+ expect(@uploader.preview).to be_blank
383
+ end
384
+
385
+ it "should process conditional version if the condition block returns true" do
386
+ @uploader_class.version(:preview).version_options[:if] = lambda{|record, args| record.true?(args[:file])}
387
+ expect(@uploader).to receive(:true?).at_least(:once).and_return(true)
388
+ @uploader.store!(@file)
389
+ expect(@uploader.thumb).to be_present
390
+ expect(@uploader.preview).to be_present
391
+ end
392
+
393
+ it "should not process conditional versions if the condition block returns false" do
394
+ @uploader_class.version(:preview).version_options[:if] = lambda{|record, args| record.false?(args[:file])}
395
+ expect(@uploader).to receive(:false?).at_least(:once).and_return(false)
396
+ @uploader.store!(@file)
397
+ expect(@uploader.thumb).to be_present
398
+ expect(@uploader.preview).to be_blank
399
+ end
400
+
401
+ it "should not cache file twice when store! called with a file" do
402
+ @uploader_class.process :banana
403
+ @uploader.thumb.class.process :banana
404
+
405
+ expect(@uploader).to receive(:banana).at_least(:once).at_most(:once).and_return(true)
406
+ expect(@uploader.thumb).to receive(:banana).at_least(:once).at_most(:once).and_return(true)
407
+
408
+ @uploader.store!(@file)
409
+ expect(@uploader.store_path).to eq('uploads/test.jpg')
410
+ expect(@uploader.thumb.store_path).to eq('uploads/thumb_test.jpg')
411
+ end
412
+ end
413
+
414
+ describe '#recreate_versions!' do
415
+ before do
416
+ @file = File.open(file_path('test.jpg'))
417
+ end
418
+
419
+ it "should overwrite all stored versions with the contents of the original file" do
420
+ @uploader.store!(@file)
421
+
422
+ File.open(@uploader.path, 'w') { |f| f.write "Contents changed" }
423
+ expect(File.read(@uploader.thumb.path)).not_to eq("Contents changed")
424
+ @uploader.recreate_versions!
425
+ expect(File.read(@uploader.thumb.path)).to eq("Contents changed")
426
+ end
427
+
428
+ it "should recreate all versions if any are missing" do
429
+ @uploader.store!(@file)
430
+
431
+ expect(File.exist?(@uploader.thumb.path)).to eq(true)
432
+ FileUtils.rm(@uploader.thumb.path)
433
+ expect(File.exist?(@uploader.thumb.path)).to eq(false)
434
+
435
+ @uploader.recreate_versions!
436
+
437
+ expect(File.exist?(@uploader.thumb.path)).to eq(true)
438
+ end
439
+
440
+ it "should recreate only specified versions if passed as args" do
441
+ @uploader_class.version(:mini)
442
+ @uploader_class.version(:maxi)
443
+ @uploader.store!(@file)
444
+
445
+ expect(File.exist?(@uploader.thumb.path)).to eq(true)
446
+ expect(File.exist?(@uploader.mini.path)).to eq(true)
447
+ expect(File.exist?(@uploader.maxi.path)).to eq(true)
448
+ FileUtils.rm(@uploader.thumb.path)
449
+ expect(File.exist?(@uploader.thumb.path)).to eq(false)
450
+ FileUtils.rm(@uploader.mini.path)
451
+ expect(File.exist?(@uploader.mini.path)).to eq(false)
452
+ FileUtils.rm(@uploader.maxi.path)
453
+ expect(File.exist?(@uploader.maxi.path)).to eq(false)
454
+
455
+ @uploader.recreate_versions!(:thumb, :maxi)
456
+
457
+ expect(File.exist?(@uploader.thumb.path)).to eq(true)
458
+ expect(File.exist?(@uploader.maxi.path)).to eq(true)
459
+ expect(File.exist?(@uploader.mini.path)).to eq(false)
460
+ end
461
+
462
+ it "should not create version if proc returns false" do
463
+ @uploader_class.version(:mini, :if => Proc.new { |*args| false } )
464
+ @uploader.store!(@file)
465
+
466
+ expect(@uploader.mini.path).to be_nil
467
+
468
+ @uploader.recreate_versions!(:mini)
469
+
470
+ expect(@uploader.mini.path).to be_nil
471
+ end
472
+
473
+ it "should not change the case of versions" do
474
+ @file = File.open(file_path('Uppercase.jpg'))
475
+ @uploader.store!(@file)
476
+ expect(@uploader.thumb.path).to eq(public_path('uploads/thumb_Uppercase.jpg'))
477
+ @uploader.recreate_versions!
478
+ expect(@uploader.thumb.path).to eq(public_path('uploads/thumb_Uppercase.jpg'))
479
+ end
480
+ end
481
+
482
+ describe '#remove!' do
483
+ before do
484
+ @uploader_class.storage = mock_storage('base')
485
+ @uploader_class.version(:thumb).storage = mock_storage('thumb')
486
+
487
+ @file = File.open(file_path('test.jpg'))
488
+
489
+ @base_stored_file = double('a stored file')
490
+ @thumb_stored_file = double('a thumb version of a stored file')
491
+
492
+ @storage = double('a storage engine')
493
+ allow(@storage).to receive(:store!).and_return(@base_stored_file)
494
+
495
+ @thumb_storage = double('a storage engine for thumbnails')
496
+ allow(@thumb_storage).to receive(:store!).and_return(@thumb_stored_file)
497
+
498
+ allow(@uploader_class.storage).to receive(:new).with(@uploader).and_return(@storage)
499
+ allow(@uploader_class.version(:thumb).storage).to receive(:new).with(@uploader.thumb).and_return(@thumb_storage)
500
+
501
+ allow(@base_stored_file).to receive(:delete)
502
+ allow(@thumb_stored_file).to receive(:delete)
503
+
504
+ @uploader.store!(@file)
505
+ end
506
+
507
+ it "should reset the current path for the version" do
508
+ @uploader.remove!
509
+ expect(@uploader.current_path).to be_nil
510
+ expect(@uploader.thumb.current_path).to be_nil
511
+ end
512
+
513
+ it "should reset the url" do
514
+ @uploader.remove!
515
+ expect(@uploader.url).to be_nil
516
+ expect(@uploader.thumb.url).to be_nil
517
+ end
518
+
519
+ it "should delete all the files" do
520
+ expect(@base_stored_file).to receive(:delete)
521
+ expect(@thumb_stored_file).to receive(:delete)
522
+ @uploader.remove!
523
+ end
524
+
525
+ end
526
+
527
+ describe '#retrieve_from_store!' do
528
+ before do
529
+ @uploader_class.storage = mock_storage('base')
530
+ @uploader_class.version(:thumb).storage = mock_storage('thumb')
531
+ @uploader_class.version(:preview).storage = mock_storage('preview')
532
+
533
+ @file = File.open(file_path('test.jpg'))
534
+
535
+ @base_stored_file = double('a stored file')
536
+ allow(@base_stored_file).to receive(:path).and_return('/path/to/somewhere')
537
+ allow(@base_stored_file).to receive(:url).and_return('http://www.example.com')
538
+
539
+ @thumb_stored_file = double('a thumb version of a stored file')
540
+ allow(@thumb_stored_file).to receive(:path).and_return('/path/to/somewhere/thumb')
541
+ allow(@thumb_stored_file).to receive(:url).and_return('http://www.example.com/thumb')
542
+
543
+ @preview_stored_file = double('a preview version of a stored file')
544
+ allow(@preview_stored_file).to receive(:path).and_return('/path/to/somewhere/preview')
545
+ allow(@preview_stored_file).to receive(:url).and_return('http://www.example.com/preview')
546
+
547
+ @storage = double('a storage engine')
548
+ allow(@storage).to receive(:retrieve!).and_return(@base_stored_file)
549
+
550
+ @thumb_storage = double('a storage engine for thumbnails')
551
+ allow(@thumb_storage).to receive(:retrieve!).and_return(@thumb_stored_file)
552
+
553
+ @preview_storage = double('a storage engine for previewnails')
554
+ allow(@preview_storage).to receive(:retrieve!).and_return(@preview_stored_file)
555
+
556
+ allow(@uploader_class.storage).to receive(:new).with(@uploader).and_return(@storage)
557
+ allow(@uploader_class.version(:thumb).storage).to receive(:new).with(@uploader.thumb).and_return(@thumb_storage)
558
+ allow(@uploader_class.version(:preview).storage).to receive(:new).with(@uploader.preview).and_return(@preview_storage)
559
+ end
560
+
561
+ it "should set the current path" do
562
+ @uploader.retrieve_from_store!('monkey.txt')
563
+ expect(@uploader.current_path).to eq('/path/to/somewhere')
564
+ expect(@uploader.thumb.current_path).to eq('/path/to/somewhere/thumb')
565
+ end
566
+
567
+ it "should set the url" do
568
+ @uploader.retrieve_from_store!('monkey.txt')
569
+ expect(@uploader.url).to eq('http://www.example.com')
570
+ expect(@uploader.thumb.url).to eq('http://www.example.com/thumb')
571
+ end
572
+
573
+ it "should pass the identifier to the storage engine" do
574
+ expect(@storage).to receive(:retrieve!).with('monkey.txt').and_return(@base_stored_file)
575
+ expect(@thumb_storage).to receive(:retrieve!).with('monkey.txt').and_return(@thumb_stored_file)
576
+ @uploader.retrieve_from_store!('monkey.txt')
577
+ expect(@uploader.file).to eq(@base_stored_file)
578
+ expect(@uploader.thumb.file).to eq(@thumb_stored_file)
579
+ end
580
+
581
+ it "should not set the filename" do
582
+ @uploader.retrieve_from_store!('monkey.txt')
583
+ expect(@uploader.filename).to be_nil
584
+ end
585
+
586
+ it "should process conditional versions if the condition method returns true" do
587
+ @uploader_class.version(:preview).version_options[:if] = :true?
588
+ expect(@uploader).to receive(:true?).at_least(:once).and_return(true)
589
+ @uploader.retrieve_from_store!('monkey.txt')
590
+ expect(@uploader.thumb).to be_present
591
+ expect(@uploader.preview).to be_present
592
+ end
593
+
594
+ it "should not process conditional versions if the condition method returns false" do
595
+ @uploader_class.version(:preview).version_options[:if] = :false?
596
+ expect(@uploader).to receive(:false?).at_least(:once).and_return(false)
597
+ @uploader.retrieve_from_store!('monkey.txt')
598
+ expect(@uploader.thumb).to be_present
599
+ expect(@uploader.preview).to be_blank
600
+ end
601
+ end
602
+ end
603
+
604
+ describe 'with a version with option :from_version' do
605
+ before do
606
+ @uploader_class.class_eval do
607
+ def upcase
608
+ content = File.read(current_path)
609
+ File.open(current_path, 'w') { |f| f.write content.upcase }
610
+ end
611
+ end
612
+
613
+ @uploader_class.version(:thumb) do
614
+ process :upcase
615
+ end
616
+
617
+ @uploader_class.version(:small_thumb, :from_version => :thumb)
618
+ end
619
+
620
+ describe '#cache!' do
621
+ before do
622
+ allow(CarrierWave).to receive(:generate_cache_id).and_return('1369894322-345-1234-2255')
623
+ end
624
+
625
+ it "should cache the files based on the version" do
626
+ @uploader.cache!(File.open(file_path('bork.txt')))
627
+
628
+ expect(File.read(public_path(@uploader.to_s))).not_to eq(File.read(public_path(@uploader.thumb.to_s)))
629
+ expect(File.read(public_path(@uploader.thumb.to_s))).to eq(File.read(public_path(@uploader.small_thumb.to_s)))
630
+ end
631
+ end
632
+ end
633
+ end