uploader 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +22 -20
- data/VERSION +1 -1
- data/app/controllers/uploader/uploads_controller.rb +21 -4
- data/lib/uploader/config.rb +2 -0
- data/test/rails_test/Gemfile +17 -7
- data/test/rails_test/Gemfile.lock +86 -45
- data/test/rails_test/spec/controllers/default_controller_spec.rb +45 -0
- data/test/rails_test/spec/controllers/uploads_controller_spec.rb +221 -0
- data/test/rails_test/{test → spec}/factories.rb +1 -1
- data/test/rails_test/{test → spec}/fixtures/files/5k.png +0 -0
- 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
- data/test/rails_test/{:rails_test/public/system/locals/000/000/001/original → spec/fixtures}/rails.png +0 -0
- data/test/rails_test/{:rails_test/public/system/locals/000/000/005/original → spec/fixtures}/test.doc +0 -0
- data/test/rails_test/{:rails_test/public/system/locals/000/000/007/original → spec/fixtures}/test.pdf +0 -0
- data/test/rails_test/{:rails_test/public/system/locals/000/000/044/original → spec/fixtures}/test.txt +0 -0
- data/test/rails_test/{:rails_test/public/system/locals/000/000/032/original → spec/fixtures}/test.xls +0 -0
- data/test/rails_test/spec/models/upload_spec.rb +149 -0
- data/test/rails_test/spec/models/user_spec.rb +20 -0
- data/test/rails_test/spec/spec_helper.rb +41 -0
- data/uploader.gemspec +14 -234
- metadata +17 -236
- data/test/rails_test/:rails_test/public/system/locals/000/000/001/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/001/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/001/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/001/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/001/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/002/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/002/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/002/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/002/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/002/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/002/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/003/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/003/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/003/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/003/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/003/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/003/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/004/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/004/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/004/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/004/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/004/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/004/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/006/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/006/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/006/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/006/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/006/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/006/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/008/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/008/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/008/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/008/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/008/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/008/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/009/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/009/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/009/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/009/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/009/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/009/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/010/original/test.doc +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/011/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/011/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/011/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/011/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/011/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/011/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/012/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/012/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/012/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/012/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/012/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/012/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/013/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/013/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/013/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/013/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/013/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/013/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/014/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/014/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/014/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/014/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/014/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/014/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/015/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/015/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/015/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/015/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/015/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/015/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/016/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/016/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/016/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/016/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/016/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/016/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/017/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/017/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/017/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/017/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/017/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/017/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/018/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/018/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/018/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/018/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/018/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/018/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/019/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/019/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/019/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/019/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/019/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/019/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/020/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/020/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/020/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/020/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/020/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/020/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/024/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/024/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/024/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/024/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/024/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/024/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/025/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/025/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/025/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/025/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/025/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/025/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/026/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/026/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/026/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/026/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/026/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/026/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/027/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/027/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/027/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/027/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/027/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/027/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/028/original/test.doc +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/029/original/test.doc +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/030/original/test.doc +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/031/original/test.doc +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/033/original/test.xls +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/034/original/test.xls +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/035/original/test.xls +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/036/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/036/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/036/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/036/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/036/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/036/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/037/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/037/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/037/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/037/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/037/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/037/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/038/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/038/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/038/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/038/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/038/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/038/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/039/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/039/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/039/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/039/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/039/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/039/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/040/original/test.pdf +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/041/original/test.pdf +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/042/original/test.pdf +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/043/original/test.pdf +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/045/original/test.txt +0 -1
- data/test/rails_test/:rails_test/public/system/locals/000/000/046/original/test.txt +0 -1
- data/test/rails_test/:rails_test/public/system/locals/000/000/047/original/test.txt +0 -1
- data/test/rails_test/:rails_test/public/system/locals/000/000/048/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/049/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/050/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/050/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/050/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/050/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/050/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/050/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/051/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/051/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/051/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/051/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/051/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/051/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/052/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/052/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/052/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/052/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/052/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/052/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/053/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/053/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/053/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/053/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/053/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/053/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/054/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/054/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/054/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/054/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/054/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/054/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/055/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/055/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/055/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/055/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/055/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/055/thumb/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/056/icon/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/056/large/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/056/medium/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/056/original/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/056/small/rails.png +0 -0
- data/test/rails_test/:rails_test/public/system/locals/000/000/056/thumb/rails.png +0 -0
- data/test/rails_test/test/fixtures/rails.png +0 -0
- data/test/rails_test/test/fixtures/test.doc +0 -0
- data/test/rails_test/test/fixtures/test.pdf +0 -0
- data/test/rails_test/test/fixtures/test.txt +0 -1
- data/test/rails_test/test/fixtures/test.xls +0 -0
- data/test/rails_test/test/functional/.keep +0 -0
- data/test/rails_test/test/functional/default_controller_test.rb +0 -49
- data/test/rails_test/test/functional/uploads_controller_test.rb +0 -191
- data/test/rails_test/test/integration/.keep +0 -0
- data/test/rails_test/test/performance/browsing_test.rb +0 -9
- data/test/rails_test/test/shoulda_macros/paperclip.rb +0 -68
- data/test/rails_test/test/test_helper.rb +0 -31
- data/test/rails_test/test/unit/.keep +0 -0
- data/test/rails_test/test/unit/upload_test.rb +0 -157
- 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
|
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 |
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
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.
|
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
|
43
|
-
|
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
|
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
|
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
|
|
data/lib/uploader/config.rb
CHANGED
@@ -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",
|
data/test/rails_test/Gemfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gem "rails", "3.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
|
18
|
-
gem
|
19
|
-
gem
|
20
|
-
gem
|
21
|
-
|
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
|
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.
|
15
|
-
actionpack (= 3.0.
|
16
|
-
mail (~> 2.2.
|
17
|
-
actionpack (3.0.
|
18
|
-
activemodel (= 3.0.
|
19
|
-
activesupport (= 3.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.
|
22
|
+
i18n (~> 0.5.0)
|
23
23
|
rack (~> 1.2.1)
|
24
|
-
rack-mount (~> 0.6.
|
25
|
-
rack-test (~> 0.5.
|
24
|
+
rack-mount (~> 0.6.14)
|
25
|
+
rack-test (~> 0.5.7)
|
26
26
|
tzinfo (~> 0.3.23)
|
27
|
-
activemodel (3.0.
|
28
|
-
activesupport (= 3.0.
|
27
|
+
activemodel (3.0.10)
|
28
|
+
activesupport (= 3.0.10)
|
29
29
|
builder (~> 2.1.2)
|
30
|
-
i18n (~> 0.
|
31
|
-
activerecord (3.0.
|
32
|
-
activemodel (= 3.0.
|
33
|
-
activesupport (= 3.0.
|
34
|
-
arel (~>
|
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.
|
37
|
-
activemodel (= 3.0.
|
38
|
-
activesupport (= 3.0.
|
39
|
-
activesupport (3.0.
|
40
|
-
|
41
|
-
|
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
|
-
|
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.
|
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.
|
89
|
-
actionmailer (= 3.0.
|
90
|
-
actionpack (= 3.0.
|
91
|
-
activerecord (= 3.0.
|
92
|
-
activeresource (= 3.0.
|
93
|
-
activesupport (= 3.0.
|
94
|
-
bundler (~> 1.0
|
95
|
-
railties (= 3.0.
|
96
|
-
railties (3.0.
|
97
|
-
actionpack (= 3.0.
|
98
|
-
activesupport (= 3.0.
|
99
|
-
rake (>= 0.8.
|
100
|
-
|
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
|
-
|
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.
|
137
|
-
|
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
|