uploader 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. data/Rakefile +22 -20
  2. data/VERSION +1 -1
  3. data/app/controllers/uploader/uploads_controller.rb +21 -4
  4. data/lib/uploader/config.rb +2 -0
  5. data/test/rails_test/Gemfile +17 -7
  6. data/test/rails_test/Gemfile.lock +86 -45
  7. data/test/rails_test/spec/controllers/default_controller_spec.rb +45 -0
  8. data/test/rails_test/spec/controllers/uploads_controller_spec.rb +221 -0
  9. data/test/rails_test/{test → spec}/factories.rb +1 -1
  10. data/test/rails_test/{test → spec}/fixtures/files/5k.png +0 -0
  11. data/test/rails_test/test/fixtures/files/IT'sUPPERCASE!AND WeIRD.JPG b/data/test/rails_test/spec/fixtures/files/IT'sUPPERCASE!AND → WeIRD.JPG +0 -0
  12. data/test/rails_test/{:rails_test/public/system/locals/000/000/001/original → spec/fixtures}/rails.png +0 -0
  13. data/test/rails_test/{:rails_test/public/system/locals/000/000/005/original → spec/fixtures}/test.doc +0 -0
  14. data/test/rails_test/{:rails_test/public/system/locals/000/000/007/original → spec/fixtures}/test.pdf +0 -0
  15. data/test/rails_test/{:rails_test/public/system/locals/000/000/044/original → spec/fixtures}/test.txt +0 -0
  16. data/test/rails_test/{:rails_test/public/system/locals/000/000/032/original → spec/fixtures}/test.xls +0 -0
  17. data/test/rails_test/spec/models/upload_spec.rb +149 -0
  18. data/test/rails_test/spec/models/user_spec.rb +20 -0
  19. data/test/rails_test/spec/spec_helper.rb +41 -0
  20. data/uploader.gemspec +14 -234
  21. metadata +17 -236
  22. data/test/rails_test/:rails_test/public/system/locals/000/000/001/icon/rails.png +0 -0
  23. data/test/rails_test/:rails_test/public/system/locals/000/000/001/large/rails.png +0 -0
  24. data/test/rails_test/:rails_test/public/system/locals/000/000/001/medium/rails.png +0 -0
  25. data/test/rails_test/:rails_test/public/system/locals/000/000/001/small/rails.png +0 -0
  26. data/test/rails_test/:rails_test/public/system/locals/000/000/001/thumb/rails.png +0 -0
  27. data/test/rails_test/:rails_test/public/system/locals/000/000/002/icon/rails.png +0 -0
  28. data/test/rails_test/:rails_test/public/system/locals/000/000/002/large/rails.png +0 -0
  29. data/test/rails_test/:rails_test/public/system/locals/000/000/002/medium/rails.png +0 -0
  30. data/test/rails_test/:rails_test/public/system/locals/000/000/002/original/rails.png +0 -0
  31. data/test/rails_test/:rails_test/public/system/locals/000/000/002/small/rails.png +0 -0
  32. data/test/rails_test/:rails_test/public/system/locals/000/000/002/thumb/rails.png +0 -0
  33. data/test/rails_test/:rails_test/public/system/locals/000/000/003/icon/rails.png +0 -0
  34. data/test/rails_test/:rails_test/public/system/locals/000/000/003/large/rails.png +0 -0
  35. data/test/rails_test/:rails_test/public/system/locals/000/000/003/medium/rails.png +0 -0
  36. data/test/rails_test/:rails_test/public/system/locals/000/000/003/original/rails.png +0 -0
  37. data/test/rails_test/:rails_test/public/system/locals/000/000/003/small/rails.png +0 -0
  38. data/test/rails_test/:rails_test/public/system/locals/000/000/003/thumb/rails.png +0 -0
  39. data/test/rails_test/:rails_test/public/system/locals/000/000/004/icon/rails.png +0 -0
  40. data/test/rails_test/:rails_test/public/system/locals/000/000/004/large/rails.png +0 -0
  41. data/test/rails_test/:rails_test/public/system/locals/000/000/004/medium/rails.png +0 -0
  42. data/test/rails_test/:rails_test/public/system/locals/000/000/004/original/rails.png +0 -0
  43. data/test/rails_test/:rails_test/public/system/locals/000/000/004/small/rails.png +0 -0
  44. data/test/rails_test/:rails_test/public/system/locals/000/000/004/thumb/rails.png +0 -0
  45. data/test/rails_test/:rails_test/public/system/locals/000/000/006/icon/rails.png +0 -0
  46. data/test/rails_test/:rails_test/public/system/locals/000/000/006/large/rails.png +0 -0
  47. data/test/rails_test/:rails_test/public/system/locals/000/000/006/medium/rails.png +0 -0
  48. data/test/rails_test/:rails_test/public/system/locals/000/000/006/original/rails.png +0 -0
  49. data/test/rails_test/:rails_test/public/system/locals/000/000/006/small/rails.png +0 -0
  50. data/test/rails_test/:rails_test/public/system/locals/000/000/006/thumb/rails.png +0 -0
  51. data/test/rails_test/:rails_test/public/system/locals/000/000/008/icon/rails.png +0 -0
  52. data/test/rails_test/:rails_test/public/system/locals/000/000/008/large/rails.png +0 -0
  53. data/test/rails_test/:rails_test/public/system/locals/000/000/008/medium/rails.png +0 -0
  54. data/test/rails_test/:rails_test/public/system/locals/000/000/008/original/rails.png +0 -0
  55. data/test/rails_test/:rails_test/public/system/locals/000/000/008/small/rails.png +0 -0
  56. data/test/rails_test/:rails_test/public/system/locals/000/000/008/thumb/rails.png +0 -0
  57. data/test/rails_test/:rails_test/public/system/locals/000/000/009/icon/rails.png +0 -0
  58. data/test/rails_test/:rails_test/public/system/locals/000/000/009/large/rails.png +0 -0
  59. data/test/rails_test/:rails_test/public/system/locals/000/000/009/medium/rails.png +0 -0
  60. data/test/rails_test/:rails_test/public/system/locals/000/000/009/original/rails.png +0 -0
  61. data/test/rails_test/:rails_test/public/system/locals/000/000/009/small/rails.png +0 -0
  62. data/test/rails_test/:rails_test/public/system/locals/000/000/009/thumb/rails.png +0 -0
  63. data/test/rails_test/:rails_test/public/system/locals/000/000/010/original/test.doc +0 -0
  64. data/test/rails_test/:rails_test/public/system/locals/000/000/011/icon/rails.png +0 -0
  65. data/test/rails_test/:rails_test/public/system/locals/000/000/011/large/rails.png +0 -0
  66. data/test/rails_test/:rails_test/public/system/locals/000/000/011/medium/rails.png +0 -0
  67. data/test/rails_test/:rails_test/public/system/locals/000/000/011/original/rails.png +0 -0
  68. data/test/rails_test/:rails_test/public/system/locals/000/000/011/small/rails.png +0 -0
  69. data/test/rails_test/:rails_test/public/system/locals/000/000/011/thumb/rails.png +0 -0
  70. data/test/rails_test/:rails_test/public/system/locals/000/000/012/icon/rails.png +0 -0
  71. data/test/rails_test/:rails_test/public/system/locals/000/000/012/large/rails.png +0 -0
  72. data/test/rails_test/:rails_test/public/system/locals/000/000/012/medium/rails.png +0 -0
  73. data/test/rails_test/:rails_test/public/system/locals/000/000/012/original/rails.png +0 -0
  74. data/test/rails_test/:rails_test/public/system/locals/000/000/012/small/rails.png +0 -0
  75. data/test/rails_test/:rails_test/public/system/locals/000/000/012/thumb/rails.png +0 -0
  76. data/test/rails_test/:rails_test/public/system/locals/000/000/013/icon/rails.png +0 -0
  77. data/test/rails_test/:rails_test/public/system/locals/000/000/013/large/rails.png +0 -0
  78. data/test/rails_test/:rails_test/public/system/locals/000/000/013/medium/rails.png +0 -0
  79. data/test/rails_test/:rails_test/public/system/locals/000/000/013/original/rails.png +0 -0
  80. data/test/rails_test/:rails_test/public/system/locals/000/000/013/small/rails.png +0 -0
  81. data/test/rails_test/:rails_test/public/system/locals/000/000/013/thumb/rails.png +0 -0
  82. data/test/rails_test/:rails_test/public/system/locals/000/000/014/icon/rails.png +0 -0
  83. data/test/rails_test/:rails_test/public/system/locals/000/000/014/large/rails.png +0 -0
  84. data/test/rails_test/:rails_test/public/system/locals/000/000/014/medium/rails.png +0 -0
  85. data/test/rails_test/:rails_test/public/system/locals/000/000/014/original/rails.png +0 -0
  86. data/test/rails_test/:rails_test/public/system/locals/000/000/014/small/rails.png +0 -0
  87. data/test/rails_test/:rails_test/public/system/locals/000/000/014/thumb/rails.png +0 -0
  88. data/test/rails_test/:rails_test/public/system/locals/000/000/015/icon/rails.png +0 -0
  89. data/test/rails_test/:rails_test/public/system/locals/000/000/015/large/rails.png +0 -0
  90. data/test/rails_test/:rails_test/public/system/locals/000/000/015/medium/rails.png +0 -0
  91. data/test/rails_test/:rails_test/public/system/locals/000/000/015/original/rails.png +0 -0
  92. data/test/rails_test/:rails_test/public/system/locals/000/000/015/small/rails.png +0 -0
  93. data/test/rails_test/:rails_test/public/system/locals/000/000/015/thumb/rails.png +0 -0
  94. data/test/rails_test/:rails_test/public/system/locals/000/000/016/icon/rails.png +0 -0
  95. data/test/rails_test/:rails_test/public/system/locals/000/000/016/large/rails.png +0 -0
  96. data/test/rails_test/:rails_test/public/system/locals/000/000/016/medium/rails.png +0 -0
  97. data/test/rails_test/:rails_test/public/system/locals/000/000/016/original/rails.png +0 -0
  98. data/test/rails_test/:rails_test/public/system/locals/000/000/016/small/rails.png +0 -0
  99. data/test/rails_test/:rails_test/public/system/locals/000/000/016/thumb/rails.png +0 -0
  100. data/test/rails_test/:rails_test/public/system/locals/000/000/017/icon/rails.png +0 -0
  101. data/test/rails_test/:rails_test/public/system/locals/000/000/017/large/rails.png +0 -0
  102. data/test/rails_test/:rails_test/public/system/locals/000/000/017/medium/rails.png +0 -0
  103. data/test/rails_test/:rails_test/public/system/locals/000/000/017/original/rails.png +0 -0
  104. data/test/rails_test/:rails_test/public/system/locals/000/000/017/small/rails.png +0 -0
  105. data/test/rails_test/:rails_test/public/system/locals/000/000/017/thumb/rails.png +0 -0
  106. data/test/rails_test/:rails_test/public/system/locals/000/000/018/icon/rails.png +0 -0
  107. data/test/rails_test/:rails_test/public/system/locals/000/000/018/large/rails.png +0 -0
  108. data/test/rails_test/:rails_test/public/system/locals/000/000/018/medium/rails.png +0 -0
  109. data/test/rails_test/:rails_test/public/system/locals/000/000/018/original/rails.png +0 -0
  110. data/test/rails_test/:rails_test/public/system/locals/000/000/018/small/rails.png +0 -0
  111. data/test/rails_test/:rails_test/public/system/locals/000/000/018/thumb/rails.png +0 -0
  112. data/test/rails_test/:rails_test/public/system/locals/000/000/019/icon/rails.png +0 -0
  113. data/test/rails_test/:rails_test/public/system/locals/000/000/019/large/rails.png +0 -0
  114. data/test/rails_test/:rails_test/public/system/locals/000/000/019/medium/rails.png +0 -0
  115. data/test/rails_test/:rails_test/public/system/locals/000/000/019/original/rails.png +0 -0
  116. data/test/rails_test/:rails_test/public/system/locals/000/000/019/small/rails.png +0 -0
  117. data/test/rails_test/:rails_test/public/system/locals/000/000/019/thumb/rails.png +0 -0
  118. data/test/rails_test/:rails_test/public/system/locals/000/000/020/icon/rails.png +0 -0
  119. data/test/rails_test/:rails_test/public/system/locals/000/000/020/large/rails.png +0 -0
  120. data/test/rails_test/:rails_test/public/system/locals/000/000/020/medium/rails.png +0 -0
  121. data/test/rails_test/:rails_test/public/system/locals/000/000/020/original/rails.png +0 -0
  122. data/test/rails_test/:rails_test/public/system/locals/000/000/020/small/rails.png +0 -0
  123. data/test/rails_test/:rails_test/public/system/locals/000/000/020/thumb/rails.png +0 -0
  124. data/test/rails_test/:rails_test/public/system/locals/000/000/024/icon/rails.png +0 -0
  125. data/test/rails_test/:rails_test/public/system/locals/000/000/024/large/rails.png +0 -0
  126. data/test/rails_test/:rails_test/public/system/locals/000/000/024/medium/rails.png +0 -0
  127. data/test/rails_test/:rails_test/public/system/locals/000/000/024/original/rails.png +0 -0
  128. data/test/rails_test/:rails_test/public/system/locals/000/000/024/small/rails.png +0 -0
  129. data/test/rails_test/:rails_test/public/system/locals/000/000/024/thumb/rails.png +0 -0
  130. data/test/rails_test/:rails_test/public/system/locals/000/000/025/icon/rails.png +0 -0
  131. data/test/rails_test/:rails_test/public/system/locals/000/000/025/large/rails.png +0 -0
  132. data/test/rails_test/:rails_test/public/system/locals/000/000/025/medium/rails.png +0 -0
  133. data/test/rails_test/:rails_test/public/system/locals/000/000/025/original/rails.png +0 -0
  134. data/test/rails_test/:rails_test/public/system/locals/000/000/025/small/rails.png +0 -0
  135. data/test/rails_test/:rails_test/public/system/locals/000/000/025/thumb/rails.png +0 -0
  136. data/test/rails_test/:rails_test/public/system/locals/000/000/026/icon/rails.png +0 -0
  137. data/test/rails_test/:rails_test/public/system/locals/000/000/026/large/rails.png +0 -0
  138. data/test/rails_test/:rails_test/public/system/locals/000/000/026/medium/rails.png +0 -0
  139. data/test/rails_test/:rails_test/public/system/locals/000/000/026/original/rails.png +0 -0
  140. data/test/rails_test/:rails_test/public/system/locals/000/000/026/small/rails.png +0 -0
  141. data/test/rails_test/:rails_test/public/system/locals/000/000/026/thumb/rails.png +0 -0
  142. data/test/rails_test/:rails_test/public/system/locals/000/000/027/icon/rails.png +0 -0
  143. data/test/rails_test/:rails_test/public/system/locals/000/000/027/large/rails.png +0 -0
  144. data/test/rails_test/:rails_test/public/system/locals/000/000/027/medium/rails.png +0 -0
  145. data/test/rails_test/:rails_test/public/system/locals/000/000/027/original/rails.png +0 -0
  146. data/test/rails_test/:rails_test/public/system/locals/000/000/027/small/rails.png +0 -0
  147. data/test/rails_test/:rails_test/public/system/locals/000/000/027/thumb/rails.png +0 -0
  148. data/test/rails_test/:rails_test/public/system/locals/000/000/028/original/test.doc +0 -0
  149. data/test/rails_test/:rails_test/public/system/locals/000/000/029/original/test.doc +0 -0
  150. data/test/rails_test/:rails_test/public/system/locals/000/000/030/original/test.doc +0 -0
  151. data/test/rails_test/:rails_test/public/system/locals/000/000/031/original/test.doc +0 -0
  152. data/test/rails_test/:rails_test/public/system/locals/000/000/033/original/test.xls +0 -0
  153. data/test/rails_test/:rails_test/public/system/locals/000/000/034/original/test.xls +0 -0
  154. data/test/rails_test/:rails_test/public/system/locals/000/000/035/original/test.xls +0 -0
  155. data/test/rails_test/:rails_test/public/system/locals/000/000/036/icon/rails.png +0 -0
  156. data/test/rails_test/:rails_test/public/system/locals/000/000/036/large/rails.png +0 -0
  157. data/test/rails_test/:rails_test/public/system/locals/000/000/036/medium/rails.png +0 -0
  158. data/test/rails_test/:rails_test/public/system/locals/000/000/036/original/rails.png +0 -0
  159. data/test/rails_test/:rails_test/public/system/locals/000/000/036/small/rails.png +0 -0
  160. data/test/rails_test/:rails_test/public/system/locals/000/000/036/thumb/rails.png +0 -0
  161. data/test/rails_test/:rails_test/public/system/locals/000/000/037/icon/rails.png +0 -0
  162. data/test/rails_test/:rails_test/public/system/locals/000/000/037/large/rails.png +0 -0
  163. data/test/rails_test/:rails_test/public/system/locals/000/000/037/medium/rails.png +0 -0
  164. data/test/rails_test/:rails_test/public/system/locals/000/000/037/original/rails.png +0 -0
  165. data/test/rails_test/:rails_test/public/system/locals/000/000/037/small/rails.png +0 -0
  166. data/test/rails_test/:rails_test/public/system/locals/000/000/037/thumb/rails.png +0 -0
  167. data/test/rails_test/:rails_test/public/system/locals/000/000/038/icon/rails.png +0 -0
  168. data/test/rails_test/:rails_test/public/system/locals/000/000/038/large/rails.png +0 -0
  169. data/test/rails_test/:rails_test/public/system/locals/000/000/038/medium/rails.png +0 -0
  170. data/test/rails_test/:rails_test/public/system/locals/000/000/038/original/rails.png +0 -0
  171. data/test/rails_test/:rails_test/public/system/locals/000/000/038/small/rails.png +0 -0
  172. data/test/rails_test/:rails_test/public/system/locals/000/000/038/thumb/rails.png +0 -0
  173. data/test/rails_test/:rails_test/public/system/locals/000/000/039/icon/rails.png +0 -0
  174. data/test/rails_test/:rails_test/public/system/locals/000/000/039/large/rails.png +0 -0
  175. data/test/rails_test/:rails_test/public/system/locals/000/000/039/medium/rails.png +0 -0
  176. data/test/rails_test/:rails_test/public/system/locals/000/000/039/original/rails.png +0 -0
  177. data/test/rails_test/:rails_test/public/system/locals/000/000/039/small/rails.png +0 -0
  178. data/test/rails_test/:rails_test/public/system/locals/000/000/039/thumb/rails.png +0 -0
  179. data/test/rails_test/:rails_test/public/system/locals/000/000/040/original/test.pdf +0 -0
  180. data/test/rails_test/:rails_test/public/system/locals/000/000/041/original/test.pdf +0 -0
  181. data/test/rails_test/:rails_test/public/system/locals/000/000/042/original/test.pdf +0 -0
  182. data/test/rails_test/:rails_test/public/system/locals/000/000/043/original/test.pdf +0 -0
  183. data/test/rails_test/:rails_test/public/system/locals/000/000/045/original/test.txt +0 -1
  184. data/test/rails_test/:rails_test/public/system/locals/000/000/046/original/test.txt +0 -1
  185. data/test/rails_test/:rails_test/public/system/locals/000/000/047/original/test.txt +0 -1
  186. data/test/rails_test/:rails_test/public/system/locals/000/000/048/original/rails.png +0 -0
  187. data/test/rails_test/:rails_test/public/system/locals/000/000/049/original/rails.png +0 -0
  188. data/test/rails_test/:rails_test/public/system/locals/000/000/050/icon/rails.png +0 -0
  189. data/test/rails_test/:rails_test/public/system/locals/000/000/050/large/rails.png +0 -0
  190. data/test/rails_test/:rails_test/public/system/locals/000/000/050/medium/rails.png +0 -0
  191. data/test/rails_test/:rails_test/public/system/locals/000/000/050/original/rails.png +0 -0
  192. data/test/rails_test/:rails_test/public/system/locals/000/000/050/small/rails.png +0 -0
  193. data/test/rails_test/:rails_test/public/system/locals/000/000/050/thumb/rails.png +0 -0
  194. data/test/rails_test/:rails_test/public/system/locals/000/000/051/icon/rails.png +0 -0
  195. data/test/rails_test/:rails_test/public/system/locals/000/000/051/large/rails.png +0 -0
  196. data/test/rails_test/:rails_test/public/system/locals/000/000/051/medium/rails.png +0 -0
  197. data/test/rails_test/:rails_test/public/system/locals/000/000/051/original/rails.png +0 -0
  198. data/test/rails_test/:rails_test/public/system/locals/000/000/051/small/rails.png +0 -0
  199. data/test/rails_test/:rails_test/public/system/locals/000/000/051/thumb/rails.png +0 -0
  200. data/test/rails_test/:rails_test/public/system/locals/000/000/052/icon/rails.png +0 -0
  201. data/test/rails_test/:rails_test/public/system/locals/000/000/052/large/rails.png +0 -0
  202. data/test/rails_test/:rails_test/public/system/locals/000/000/052/medium/rails.png +0 -0
  203. data/test/rails_test/:rails_test/public/system/locals/000/000/052/original/rails.png +0 -0
  204. data/test/rails_test/:rails_test/public/system/locals/000/000/052/small/rails.png +0 -0
  205. data/test/rails_test/:rails_test/public/system/locals/000/000/052/thumb/rails.png +0 -0
  206. data/test/rails_test/:rails_test/public/system/locals/000/000/053/icon/rails.png +0 -0
  207. data/test/rails_test/:rails_test/public/system/locals/000/000/053/large/rails.png +0 -0
  208. data/test/rails_test/:rails_test/public/system/locals/000/000/053/medium/rails.png +0 -0
  209. data/test/rails_test/:rails_test/public/system/locals/000/000/053/original/rails.png +0 -0
  210. data/test/rails_test/:rails_test/public/system/locals/000/000/053/small/rails.png +0 -0
  211. data/test/rails_test/:rails_test/public/system/locals/000/000/053/thumb/rails.png +0 -0
  212. data/test/rails_test/:rails_test/public/system/locals/000/000/054/icon/rails.png +0 -0
  213. data/test/rails_test/:rails_test/public/system/locals/000/000/054/large/rails.png +0 -0
  214. data/test/rails_test/:rails_test/public/system/locals/000/000/054/medium/rails.png +0 -0
  215. data/test/rails_test/:rails_test/public/system/locals/000/000/054/original/rails.png +0 -0
  216. data/test/rails_test/:rails_test/public/system/locals/000/000/054/small/rails.png +0 -0
  217. data/test/rails_test/:rails_test/public/system/locals/000/000/054/thumb/rails.png +0 -0
  218. data/test/rails_test/:rails_test/public/system/locals/000/000/055/icon/rails.png +0 -0
  219. data/test/rails_test/:rails_test/public/system/locals/000/000/055/large/rails.png +0 -0
  220. data/test/rails_test/:rails_test/public/system/locals/000/000/055/medium/rails.png +0 -0
  221. data/test/rails_test/:rails_test/public/system/locals/000/000/055/original/rails.png +0 -0
  222. data/test/rails_test/:rails_test/public/system/locals/000/000/055/small/rails.png +0 -0
  223. data/test/rails_test/:rails_test/public/system/locals/000/000/055/thumb/rails.png +0 -0
  224. data/test/rails_test/:rails_test/public/system/locals/000/000/056/icon/rails.png +0 -0
  225. data/test/rails_test/:rails_test/public/system/locals/000/000/056/large/rails.png +0 -0
  226. data/test/rails_test/:rails_test/public/system/locals/000/000/056/medium/rails.png +0 -0
  227. data/test/rails_test/:rails_test/public/system/locals/000/000/056/original/rails.png +0 -0
  228. data/test/rails_test/:rails_test/public/system/locals/000/000/056/small/rails.png +0 -0
  229. data/test/rails_test/:rails_test/public/system/locals/000/000/056/thumb/rails.png +0 -0
  230. data/test/rails_test/test/fixtures/rails.png +0 -0
  231. data/test/rails_test/test/fixtures/test.doc +0 -0
  232. data/test/rails_test/test/fixtures/test.pdf +0 -0
  233. data/test/rails_test/test/fixtures/test.txt +0 -1
  234. data/test/rails_test/test/fixtures/test.xls +0 -0
  235. data/test/rails_test/test/functional/.keep +0 -0
  236. data/test/rails_test/test/functional/default_controller_test.rb +0 -49
  237. data/test/rails_test/test/functional/uploads_controller_test.rb +0 -191
  238. data/test/rails_test/test/integration/.keep +0 -0
  239. data/test/rails_test/test/performance/browsing_test.rb +0 -9
  240. data/test/rails_test/test/shoulda_macros/paperclip.rb +0 -68
  241. data/test/rails_test/test/test_helper.rb +0 -31
  242. data/test/rails_test/test/unit/.keep +0 -0
  243. data/test/rails_test/test/unit/upload_test.rb +0 -157
  244. data/test/rails_test/test/unit/user_test.rb +0 -26
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
- require 'rake/rdoctask'
4
3
 
5
4
  desc 'Default: run unit tests.'
6
5
  task :default => :test
@@ -13,12 +12,19 @@ Rake::TestTask.new(:test) do |t|
13
12
  t.verbose = true
14
13
  end
15
14
 
15
+ require 'rake/rdoctask'
16
16
  desc 'Generate documentation for the uploader plugin.'
17
17
  Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ if File.exist?('VERSION.yml')
19
+ config = YAML.load(File.read('VERSION.yml'))
20
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
21
+ else
22
+ version = ""
23
+ end
18
24
  rdoc.rdoc_dir = 'rdoc'
19
25
  rdoc.title = 'Uploader'
20
26
  rdoc.options << '--line-numbers' << '--inline-source'
21
- rdoc.rdoc_files.include('README.rdoc')
27
+ rdoc.rdoc_files.include('README*')
22
28
  rdoc.rdoc_files.include('lib/**/*.rb')
23
29
  end
24
30
 
@@ -30,24 +36,20 @@ end
30
36
 
31
37
  begin
32
38
  require 'jeweler'
33
- Jeweler::Tasks.new do |gemspec|
34
- gemspec.name = "uploader"
35
- gemspec.summary = "Uploadify, SWFUpload + Paperclip wrapped in an engine with love."
36
- gemspec.email = "justinball@gmail.com"
37
- gemspec.homepage = "http://github.com/jbasdf/uploader"
38
- gemspec.description = "Uploader gem that makes it simple add multiple file uploads to your Rails project using SWFUpload, Uploadify and Paperclip"
39
- gemspec.authors = ["Justin Ball", "Joel Duffin", "David South"]
40
- gemspec.files.include %w( test/rails_test/db/schema.rb )
41
- gemspec.rubyforge_project = 'uploader'
42
- gemspec.add_dependency "mime-types"
43
- gemspec.add_dependency "rack"
44
- gemspec.add_dependency "paperclip"
45
- gemspec.add_dependency "aws-s3"
46
- end
47
- Jeweler::GemcutterTasks.new
48
- Jeweler::RubyforgeTasks.new do |rubyforge|
49
- rubyforge.doc_task = "rdoc"
39
+ Jeweler::Tasks.new do |gem|
40
+ gem.name = "uploader"
41
+ gem.summary = "Uploadify, SWFUpload + Paperclip wrapped in an engine with love."
42
+ gem.email = "justinball@gmail.com"
43
+ gem.homepage = "http://github.com/jbasdf/uploader"
44
+ gem.description = "Uploader gem that makes it simple add multiple file uploads to your Rails project using SWFUpload, Uploadify and Paperclip"
45
+ gem.authors = ["Justin Ball", "Joel Duffin", "David South"]
46
+ gem.add_dependency "mime-types"
47
+ gem.add_dependency "rack"
48
+ gem.add_dependency "paperclip"
49
+ gem.add_dependency "aws-s3"
50
+ gem.files.exclude 'test/**'
50
51
  end
52
+ Jeweler::RubygemsDotOrgTasks.new
51
53
  rescue LoadError
52
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
54
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
53
55
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.0
1
+ 3.1.1
@@ -39,8 +39,13 @@ class Uploader::UploadsController < ApplicationController
39
39
  redirect_to get_redirect(:create_failure)
40
40
  end
41
41
  format.js { render :text => message }
42
- format.json { render :json => { :success => false, :message => message } }
43
- # render :json => message, :status => :unprocessable_entity
42
+ format.json do
43
+ if Uploader.configuration.use_http_status_failures
44
+ render :json => message, :status => :unprocessable_entity
45
+ else
46
+ render :json => { :success => false, :message => message }
47
+ end
48
+ end
44
49
  end
45
50
  end
46
51
 
@@ -59,7 +64,13 @@ class Uploader::UploadsController < ApplicationController
59
64
  message = t('uploader.standard_file_upload_error', :error => ex)
60
65
  respond_to do |format|
61
66
  format.js { render :text => message }
62
- format.json { render :json => { :success => false, :message => message } }
67
+ format.json do
68
+ if Uploader.configuration.use_http_status_failures
69
+ render :json => message, :status => :unprocessable_entity
70
+ else
71
+ render :json => { :success => false, :message => message }
72
+ end
73
+ end
63
74
  end
64
75
  end
65
76
 
@@ -79,7 +90,13 @@ class Uploader::UploadsController < ApplicationController
79
90
  redirect_to get_redirect(:destroy_success)
80
91
  end
81
92
  format.js { render :text => message }
82
- format.json { render :json => { :success => success, :message => message } }
93
+ format.json do
94
+ if Uploader.configuration.use_http_status_failures
95
+ render :json => message, :status => :unprocessable_entity
96
+ else
97
+ render :json => { :success => success, :message => message }
98
+ end
99
+ end
83
100
  end
84
101
  end
85
102
 
@@ -42,6 +42,7 @@ module Uploader
42
42
  attr_accessor :keep_local_file
43
43
  attr_accessor :disable_halt_nonimage_processing
44
44
  attr_accessor :temp_dir
45
+ attr_accessor :use_http_status_failures # This only applies to json requests
45
46
 
46
47
  def initialize
47
48
  @enable_s3 = false
@@ -49,6 +50,7 @@ module Uploader
49
50
  @keep_local_file = true
50
51
  @disable_halt_nonimage_processing = false
51
52
  @temp_dir = Dir::tmpdir
53
+ @use_http_status_failures = false
52
54
  @has_attached_file_options = {
53
55
  :url => "/system/:attachment/:id_partition/:style/:basename.:extension",
54
56
  :path => ":rails_root/public:url",
@@ -1,8 +1,8 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rails", "3.0.0"
4
- gem "capybara", ">= 0.3.9"
3
+ gem "rails", "3.0.10"
5
4
  gem 'mysql'
5
+ gem 'authlogic', "3.0.2"
6
6
 
7
7
  gem "mime-types"
8
8
  gem "rack"
@@ -13,9 +13,19 @@ if RUBY_VERSION < '1.9'
13
13
  gem "ruby-debug"
14
14
  end
15
15
 
16
+ group :test, :development do
17
+ gem "rspec-rails", ">=2.4.0"
18
+ gem "cucumber-rails"
19
+ end
20
+
16
21
  group :test do
17
- gem 'shoulda'
18
- gem 'factory_girl'
19
- gem 'mocha'
20
- gem 'redgreen'
21
- end
22
+ gem "capybara", ">= 0.3.9"
23
+ gem "shoulda"
24
+ gem "factory_girl"
25
+ gem "cucumber"
26
+ gem "rcov"
27
+ gem "rspec", ">=2.4.0"
28
+ gem "database_cleaner"
29
+ gem "spork"
30
+ gem "launchy"
31
+ end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- uploader (3.0.2)
4
+ uploader (3.1.0)
5
5
  aws-s3
6
6
  mime-types
7
7
  paperclip
@@ -11,34 +11,37 @@ GEM
11
11
  remote: http://rubygems.org/
12
12
  specs:
13
13
  abstract (1.0.0)
14
- actionmailer (3.0.0)
15
- actionpack (= 3.0.0)
16
- mail (~> 2.2.5)
17
- actionpack (3.0.0)
18
- activemodel (= 3.0.0)
19
- activesupport (= 3.0.0)
14
+ actionmailer (3.0.10)
15
+ actionpack (= 3.0.10)
16
+ mail (~> 2.2.19)
17
+ actionpack (3.0.10)
18
+ activemodel (= 3.0.10)
19
+ activesupport (= 3.0.10)
20
20
  builder (~> 2.1.2)
21
21
  erubis (~> 2.6.6)
22
- i18n (~> 0.4.1)
22
+ i18n (~> 0.5.0)
23
23
  rack (~> 1.2.1)
24
- rack-mount (~> 0.6.12)
25
- rack-test (~> 0.5.4)
24
+ rack-mount (~> 0.6.14)
25
+ rack-test (~> 0.5.7)
26
26
  tzinfo (~> 0.3.23)
27
- activemodel (3.0.0)
28
- activesupport (= 3.0.0)
27
+ activemodel (3.0.10)
28
+ activesupport (= 3.0.10)
29
29
  builder (~> 2.1.2)
30
- i18n (~> 0.4.1)
31
- activerecord (3.0.0)
32
- activemodel (= 3.0.0)
33
- activesupport (= 3.0.0)
34
- arel (~> 1.0.0)
30
+ i18n (~> 0.5.0)
31
+ activerecord (3.0.10)
32
+ activemodel (= 3.0.10)
33
+ activesupport (= 3.0.10)
34
+ arel (~> 2.0.10)
35
35
  tzinfo (~> 0.3.23)
36
- activeresource (3.0.0)
37
- activemodel (= 3.0.0)
38
- activesupport (= 3.0.0)
39
- activesupport (3.0.0)
40
- arel (1.0.1)
41
- activesupport (~> 3.0.0)
36
+ activeresource (3.0.10)
37
+ activemodel (= 3.0.10)
38
+ activesupport (= 3.0.10)
39
+ activesupport (3.0.10)
40
+ addressable (2.2.6)
41
+ arel (2.0.10)
42
+ authlogic (3.0.2)
43
+ activerecord (~> 3.0.7)
44
+ activerecord (~> 3.0.7)
42
45
  aws-s3 (0.6.2)
43
46
  builder
44
47
  mime-types
@@ -55,12 +58,29 @@ GEM
55
58
  ffi (~> 1.0.6)
56
59
  cocaine (0.2.0)
57
60
  columnize (0.3.4)
61
+ cucumber (1.0.6)
62
+ builder (>= 2.1.2)
63
+ diff-lcs (>= 1.1.2)
64
+ gherkin (~> 2.4.18)
65
+ json (>= 1.4.6)
66
+ term-ansicolor (>= 1.0.6)
67
+ cucumber-rails (1.0.5)
68
+ capybara (>= 1.1.1)
69
+ cucumber (~> 1.0.6)
70
+ nokogiri (>= 1.5.0)
71
+ database_cleaner (0.6.7)
72
+ diff-lcs (1.1.3)
58
73
  erubis (2.6.6)
59
74
  abstract (>= 1.0.0)
60
75
  factory_girl (2.1.0)
61
76
  ffi (1.0.9)
62
- i18n (0.4.2)
77
+ gherkin (2.4.21)
78
+ json (>= 1.4.6)
79
+ i18n (0.5.0)
80
+ json (1.6.0)
63
81
  json_pure (1.6.0)
82
+ launchy (2.0.5)
83
+ addressable (~> 2.2.6)
64
84
  linecache (0.46)
65
85
  rbx-require-relative (> 0.0.4)
66
86
  mail (2.2.19)
@@ -68,10 +88,7 @@ GEM
68
88
  i18n (>= 0.4.0)
69
89
  mime-types (~> 1.16)
70
90
  treetop (~> 1.4.8)
71
- metaclass (0.0.1)
72
91
  mime-types (1.16)
73
- mocha (0.10.0)
74
- metaclass (~> 0.0.1)
75
92
  mysql (2.8.1)
76
93
  nokogiri (1.5.0)
77
94
  paperclip (2.4.1)
@@ -80,27 +97,42 @@ GEM
80
97
  cocaine (>= 0.0.2)
81
98
  mime-types
82
99
  polyglot (0.3.2)
83
- rack (1.2.3)
100
+ rack (1.2.4)
84
101
  rack-mount (0.6.14)
85
102
  rack (>= 1.0.0)
86
103
  rack-test (0.5.7)
87
104
  rack (>= 1.0)
88
- rails (3.0.0)
89
- actionmailer (= 3.0.0)
90
- actionpack (= 3.0.0)
91
- activerecord (= 3.0.0)
92
- activeresource (= 3.0.0)
93
- activesupport (= 3.0.0)
94
- bundler (~> 1.0.0)
95
- railties (= 3.0.0)
96
- railties (3.0.0)
97
- actionpack (= 3.0.0)
98
- activesupport (= 3.0.0)
99
- rake (>= 0.8.4)
100
- thor (~> 0.14.0)
105
+ rails (3.0.10)
106
+ actionmailer (= 3.0.10)
107
+ actionpack (= 3.0.10)
108
+ activerecord (= 3.0.10)
109
+ activeresource (= 3.0.10)
110
+ activesupport (= 3.0.10)
111
+ bundler (~> 1.0)
112
+ railties (= 3.0.10)
113
+ railties (3.0.10)
114
+ actionpack (= 3.0.10)
115
+ activesupport (= 3.0.10)
116
+ rake (>= 0.8.7)
117
+ rdoc (~> 3.4)
118
+ thor (~> 0.14.4)
101
119
  rake (0.9.2)
102
120
  rbx-require-relative (0.0.5)
103
- redgreen (1.2.2)
121
+ rcov (0.9.10)
122
+ rdoc (3.9.4)
123
+ rspec (2.6.0)
124
+ rspec-core (~> 2.6.0)
125
+ rspec-expectations (~> 2.6.0)
126
+ rspec-mocks (~> 2.6.0)
127
+ rspec-core (2.6.4)
128
+ rspec-expectations (2.6.0)
129
+ diff-lcs (~> 1.1.2)
130
+ rspec-mocks (2.6.0)
131
+ rspec-rails (2.6.1)
132
+ actionpack (~> 3.0)
133
+ activesupport (~> 3.0)
134
+ railties (~> 3.0)
135
+ rspec (~> 2.6.0)
104
136
  ruby-debug (0.10.4)
105
137
  columnize (>= 0.1)
106
138
  ruby-debug-base (~> 0.10.4.0)
@@ -113,6 +145,8 @@ GEM
113
145
  json_pure
114
146
  rubyzip
115
147
  shoulda (2.11.3)
148
+ spork (0.8.5)
149
+ term-ansicolor (1.0.6)
116
150
  thor (0.14.6)
117
151
  treetop (1.4.10)
118
152
  polyglot
@@ -126,15 +160,22 @@ PLATFORMS
126
160
  ruby
127
161
 
128
162
  DEPENDENCIES
163
+ authlogic (= 3.0.2)
129
164
  capybara (>= 0.3.9)
165
+ cucumber
166
+ cucumber-rails
167
+ database_cleaner
130
168
  factory_girl
169
+ launchy
131
170
  mime-types
132
- mocha
133
171
  mysql
134
172
  paperclip
135
173
  rack
136
- rails (= 3.0.0)
137
- redgreen
174
+ rails (= 3.0.10)
175
+ rcov
176
+ rspec (>= 2.4.0)
177
+ rspec-rails (>= 2.4.0)
138
178
  ruby-debug
139
179
  shoulda
180
+ spork
140
181
  uploader!
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe DefaultController do
4
+
5
+ render_views
6
+
7
+ describe 'on GET to index' do
8
+ # The default view calls the upload_form helper. This isn't a great test but
9
+ # it will make sure it doesn't blow up
10
+ before do
11
+ @user = Factory(:user)
12
+ get :index, :user_id => @user.to_param
13
+ end
14
+ it { should respond_with :success }
15
+ it "should have a_container_with_a_long_name in the body" do
16
+ @response.body.should include('a_container_with_a_long_name')
17
+ end
18
+ it "should have '1 MB' in the body" do
19
+ @response.body.should include('1 MB')
20
+ end
21
+ it "should have '*.jpg' in the body" do
22
+ @response.body.should include('*.jpg')
23
+ end
24
+ end
25
+
26
+ describe 'on GET to uploadify' do
27
+ # The default view calls the upload_form helper. This isn't a great test but
28
+ # it will make sure it doesn't blow up
29
+ before do
30
+ @user = Factory(:user)
31
+ get :uploadify, :user_id => @user.to_param
32
+ end
33
+ it { should respond_with :success }
34
+ it "should have a_container_with_a_long_name in the body" do
35
+ @response.body.should include('a_container_with_a_long_name')
36
+ end
37
+ it "should have '1310720' in the body" do
38
+ @response.body.should include('1310720')
39
+ end
40
+ it "should have '*.jpg' in the body" do
41
+ @response.body.should include('*.jpg')
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,221 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe UploadsController do
4
+
5
+ before do
6
+ @user = Factory(:user)
7
+ @controller.stub!(:current_user).and_return(@user)
8
+ end
9
+
10
+ describe 'on POST to :create' do
11
+ describe "good file" do
12
+ describe "response" do
13
+ before do
14
+ post :create, { :upload => { :local => VALID_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
15
+ end
16
+ it { should redirect_to("/create_success") }
17
+ it { should set_the_flash.to(I18n.t('uploader.successful_upload')) }
18
+ end
19
+ it "should create a valid upload" do
20
+ expect {
21
+ post :create, { :upload => { :local => VALID_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
22
+ assigns(:upload).errors.should be_empty
23
+ }.to change(@user.uploads, :count).by(1)
24
+ end
25
+ end
26
+ describe "good text file" do
27
+ describe "response" do
28
+ before do
29
+ post :create, { :upload => { :local => VALID_TEXT_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
30
+ end
31
+ it { should redirect_to("/create_success") }
32
+ it { should set_the_flash.to(I18n.t('uploader.successful_upload')) }
33
+ end
34
+ it "should create a valid upload" do
35
+ expect {
36
+ post :create, { :upload => { :local => VALID_TEXT_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
37
+ assigns(:upload).errors.should be_empty
38
+ }.to change(@user.uploads, :count).by(1)
39
+ end
40
+ end
41
+ describe "good pdf file" do
42
+ describe "response" do
43
+ before do
44
+ post :create, { :upload => { :local => VALID_PDF_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
45
+ end
46
+ it { should redirect_to("/create_success") }
47
+ it { should set_the_flash.to(I18n.t('uploader.successful_upload')) }
48
+ end
49
+ it "should create a valid upload" do
50
+ expect {
51
+ post :create, { :upload => { :local => VALID_PDF_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
52
+ assigns(:upload).errors.should be_empty
53
+ }.to change(@user.uploads, :count).by(1)
54
+ end
55
+ end
56
+ describe "good doc file" do
57
+ describe "response" do
58
+ before do
59
+ post :create, { :upload => { :local => VALID_WORD_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
60
+ end
61
+ it { should redirect_to("/create_success") }
62
+ it { should set_the_flash.to(I18n.t('uploader.successful_upload')) }
63
+ end
64
+ it "should create a valid upload" do
65
+ expect {
66
+ post :create, { :upload => { :local => VALID_WORD_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
67
+ assigns(:upload).errors.should be_empty
68
+ }.to change(@user.uploads, :count).by(1)
69
+ end
70
+ end
71
+ describe "good excel file" do
72
+ describe "response" do
73
+ before do
74
+ post :create, { :upload => { :local => VALID_EXCEL_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
75
+ end
76
+ it { should redirect_to("/create_success") }
77
+ it { should set_the_flash.to(I18n.t('uploader.successful_upload')) }
78
+ end
79
+ it "should create a valid upload" do
80
+ expect {
81
+ post :create, { :upload => { :local => VALID_EXCEL_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
82
+ assigns(:upload).errors.should be_empty
83
+ }.to change(@user.uploads, :count).by(1)
84
+ end
85
+ end
86
+ describe "bad file" do
87
+ describe "response" do
88
+ before do
89
+ post :create, { :upload => { :local => nil }, :parent_type => 'User', :parent_id => @user.to_param }
90
+ end
91
+ it { should redirect_to("/create_failure") }
92
+ it { should set_the_flash.to(/An error occured while uploading the file/) }
93
+ end
94
+ it "should not create file" do
95
+ expect {
96
+ post :create, { :upload => { :local => nil }, :parent_type => 'User', :parent_id => @user.to_param }
97
+ assigns(:upload).errors.should_not be_empty
98
+ }.to change(@user.uploads, :count).by(0)
99
+ end
100
+ end
101
+ describe "use_http_status_failures set to true" do
102
+ before do
103
+ @use_http_status_failures_default = Uploader.configuration.use_http_status_failures
104
+ Uploader.configuration.use_http_status_failures = true
105
+ end
106
+ after do
107
+ Uploader.configuration.use_http_status_failures = @use_http_status_failures_default
108
+ end
109
+ describe "response" do
110
+ before do
111
+ post :create, { :upload => { :local => nil }, :parent_type => 'User', :parent_id => @user.to_param, :format => 'json' }
112
+ end
113
+ it "should set the response to unprocessable_entity" do
114
+ response.status.should == 422
115
+ end
116
+ end
117
+ end
118
+ describe "raw file upload" do
119
+ before do
120
+ @name = 'rails.png'
121
+ @request.set_header "HTTP_X_FILE_NAME", @name
122
+ @request.set_header "HTTP_X_FILE_UPLOAD", "true"
123
+ @request.set_header "rack.input", StringIO.new('some random file')
124
+ end
125
+ it "should create a new upload" do
126
+ expect {
127
+ post :create
128
+ }.to change(Upload, :count).by(1)
129
+ end
130
+ it "should not have errors on the upload" do
131
+ post :create
132
+ assert assigns(:upload).errors.empty?
133
+ end
134
+ it "should set the name of the file" do
135
+ post :create
136
+ assert assigns(:upload).name == @name
137
+ assert assigns(:upload).local_file_name == @name
138
+ end
139
+ end
140
+ end
141
+ describe 'on POST to :multiupload' do
142
+ describe 'js' do
143
+ describe "response" do
144
+ before do
145
+ post :multiupload, { :Filedata => VALID_FILE, :parent_type => 'User', :parent_id => @user.to_param, :format => 'js' }
146
+ end
147
+ it { should respond_with :success }
148
+ end
149
+ it "should add an upload" do
150
+ expect {
151
+ post :multiupload, { :Filedata => VALID_FILE, :parent_type => 'User', :parent_id => @user.to_param, :format => 'js' }
152
+ }.to change(Upload, :count).by(1)
153
+ end
154
+ end
155
+ describe 'json' do
156
+ describe "response" do
157
+ before do
158
+ post :multiupload, { :Filedata => VALID_FILE, :parent_type => 'User', :parent_id => @user.to_param, :format => 'json' }
159
+ end
160
+ it { should respond_with :success }
161
+ end
162
+ it "should add an upload" do
163
+ expect {
164
+ post :multiupload, { :Filedata => VALID_FILE, :parent_type => 'User', :parent_id => @user.to_param, :format => 'json' }
165
+ }.to change(Upload, :count).by(1)
166
+ end
167
+ end
168
+ end
169
+
170
+ describe 'permission denied' do
171
+ before do
172
+ @controller.stub!(:has_permission_to_upload).and_return(false)
173
+ post :create, { :upload => { :local => VALID_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
174
+ end
175
+ it {should redirect_to("/permission_denied") }
176
+ end
177
+
178
+ describe 'on DELETE to :destroy' do
179
+ before do
180
+ @upload = Factory(:upload)
181
+ end
182
+ describe "has permission" do
183
+ describe "controller" do
184
+ before do
185
+ delete :destroy, { :id => @upload.to_param }
186
+ end
187
+ it {should redirect_to("/destroy_success")}
188
+ it { should set_the_flash.to((I18n.t('uploader.file_deleted'))) }
189
+ end
190
+ describe "data changes" do
191
+ it "should delete the upload" do
192
+ expect {
193
+ delete :destroy, { :id => @upload.to_param }
194
+ }.to change(Upload, :count).by(-1)
195
+ end
196
+ end
197
+ end
198
+ describe "permission denied" do
199
+ before do
200
+ @upload.stub!(:can_edit?).and_return(false)
201
+ Upload.stub!(:find).and_return(@upload) # db version won't have can_edit? stubbed since it is a new object so we have to return @upload instead.
202
+ end
203
+ describe "controller" do
204
+ before do
205
+ delete :destroy, { :id => @upload.to_param }
206
+ end
207
+ it {should redirect_to("/destroy_success")}
208
+ it { should set_the_flash.to((I18n.t('uploader.file_delete_permission_denied'))) }
209
+ end
210
+ describe "data changes" do
211
+ it "should not delete the upload" do
212
+ expect {
213
+ delete :destroy, { :id => @upload.to_param }
214
+ }.to change(Upload, :count).by(0)
215
+ end
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end