another_uploader 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +21 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/app/assets/images/another_uploader/doc.gif +0 -0
- data/app/assets/images/another_uploader/mp3.gif +0 -0
- data/app/assets/images/another_uploader/none.gif +0 -0
- data/app/assets/images/another_uploader/pdf.gif +0 -0
- data/app/assets/images/another_uploader/spreadsheet.gif +0 -0
- data/app/assets/images/another_uploader/text.gif +0 -0
- data/app/assets/javascripts/another_uploader/index.js +5 -0
- data/app/assets/javascripts/uploads.js +2 -0
- data/app/assets/stylesheets/another_uploader/index.css +5 -0
- data/app/assets/stylesheets/uploads.css +4 -0
- data/app/controllers/uploads_controller.rb +7 -0
- data/app/helpers/uploads_helper.rb +2 -0
- data/app/models/upload.rb +145 -0
- data/app/views/uploads/destroy.html.erb +2 -0
- data/app/views/uploads/uploadify.html.erb +2 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20121115043827_create_uploads.rb +31 -0
- data/lib/another_uploader.rb +14 -0
- data/lib/another_uploader/configuration.rb +36 -0
- data/lib/another_uploader/engine.rb +4 -0
- data/lib/another_uploader/icons.rb +23 -0
- data/lib/another_uploader/image_processing.rb +29 -0
- data/lib/another_uploader/mime_type_getters.rb +17 -0
- data/lib/another_uploader/mime_type_groups.rb +17 -0
- data/lib/another_uploader/transliteration.rb +22 -0
- data/lib/another_uploader/version.rb +3 -0
- data/lib/tasks/another_uploader_tasks.rake +4 -0
- data/test/another_uploader_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +17 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +6 -0
- data/test/dummy/app/controllers/main_controller.rb +4 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/user.rb +6 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/main/index.html.erb +2 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/another_uploader.rb +10 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +61 -0
- data/test/dummy/config/s3.yml +10 -0
- data/test/dummy/config/s3.yml.example +21 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20121115045546_create_users.easy_rails_authentication_engine.rb +12 -0
- data/test/dummy/db/migrate/20121115045547_create_password_recoveries.easy_rails_authentication_engine.rb +13 -0
- data/test/dummy/db/migrate/20121115045630_create_uploads.another_uploader_engine.rb +32 -0
- data/test/dummy/db/schema.rb +63 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +53979 -0
- data/test/dummy/log/test.log +139363 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/functional/main_controller_test.rb +9 -0
- data/test/dummy/tmp/cache/assets/C1D/CB0/sprockets%2F1368a6c195444308f76a970b1127660b +0 -0
- data/test/dummy/tmp/cache/assets/C56/660/sprockets%2F9606c93013df9ec75112d323643686a9 +0 -0
- data/test/dummy/tmp/cache/assets/C64/2A0/sprockets%2F779fa4794d76f3083f442743352e247c +0 -0
- data/test/dummy/tmp/cache/assets/C80/910/sprockets%2F1da2794871f7097ea5246354ae85300b +0 -0
- data/test/dummy/tmp/cache/assets/C82/240/sprockets%2F625dc2916f00654e5351b054afc95678 +0 -0
- data/test/dummy/tmp/cache/assets/C9F/DD0/sprockets%2F1801bd89c75539c636659918883e8dea +0 -0
- data/test/dummy/tmp/cache/assets/CA9/ED0/sprockets%2F845117661057731bd942dc61ddda24f3 +0 -0
- data/test/dummy/tmp/cache/assets/CB1/030/sprockets%2F330d8361296be2294bcf4e8282473ab7 +0 -0
- data/test/dummy/tmp/cache/assets/CBD/D80/sprockets%2F65641a234ede6ff88b006594b1869b29 +0 -0
- data/test/dummy/tmp/cache/assets/CC1/4E0/sprockets%2F53d9bd83335f4bb9561087645769c5da +0 -0
- data/test/dummy/tmp/cache/assets/CD6/C50/sprockets%2Fd30f21629ea47cf66530fa0e347272b4 +0 -0
- data/test/dummy/tmp/cache/assets/CD7/B40/sprockets%2F21b71f8ea0f566175a551816b6f530cb +0 -0
- data/test/dummy/tmp/cache/assets/CD7/EE0/sprockets%2Fd677061accd85058216607c208b7a2bf +0 -0
- data/test/dummy/tmp/cache/assets/CD8/000/sprockets%2F12d162f45ae0036e177e4a67b926a92d +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CD9/990/sprockets%2Fba64ae414cc39805ce695e2c40162807 +0 -0
- data/test/dummy/tmp/cache/assets/CDA/700/sprockets%2F2437e594d81db9b2b87b24411630dba8 +0 -0
- data/test/dummy/tmp/cache/assets/CE1/340/sprockets%2F0573a62b0251cc18c80949a9c9fe34d7 +0 -0
- data/test/dummy/tmp/cache/assets/CE1/C30/sprockets%2F6a2c53cf042c621806c77ada86288c77 +0 -0
- data/test/dummy/tmp/cache/assets/CE6/1A0/sprockets%2F41ce96883326a6a9313b408cdf80df74 +0 -0
- data/test/dummy/tmp/cache/assets/CE7/F50/sprockets%2F5118ca4d54388e2cc84e90c95f36048a +0 -0
- data/test/dummy/tmp/cache/assets/CED/B00/sprockets%2Fbde328b963290de060b7677fd155695e +0 -0
- data/test/dummy/tmp/cache/assets/CF2/4B0/sprockets%2Fb95901745337c00037e00a7f0cacaa3c +0 -0
- data/test/dummy/tmp/cache/assets/CF9/960/sprockets%2F69590f47d597a9ec070b6c0bc28e9876 +0 -0
- data/test/dummy/tmp/cache/assets/CFE/EE0/sprockets%2F1100a030f19d781dc98eb066ab6075ec +0 -0
- data/test/dummy/tmp/cache/assets/D00/D30/sprockets%2F08dc27f9a9ed399356a91d4069889c5d +0 -0
- data/test/dummy/tmp/cache/assets/D0A/760/sprockets%2F28d26ec78714eaf45198b0abab175117 +0 -0
- data/test/dummy/tmp/cache/assets/D0E/E90/sprockets%2Fa982198515b54c1f58f8aae30830f0ea +0 -0
- data/test/dummy/tmp/cache/assets/D12/7E0/sprockets%2F35c1a2211d6547b7c7ffa5ed813d7938 +0 -0
- data/test/dummy/tmp/cache/assets/D18/610/sprockets%2F66cc7f1b171e5729d4279bac1676de53 +0 -0
- data/test/dummy/tmp/cache/assets/D1A/AC0/sprockets%2F045847ba35c0701c01fa0b0ecf73d11a +0 -0
- data/test/dummy/tmp/cache/assets/D1B/810/sprockets%2F76112c598c956c07c4f4e91f6ee3ba80 +0 -0
- data/test/dummy/tmp/cache/assets/D1E/580/sprockets%2F5f965913df7a03e307dfd9326f9b06b7 +0 -0
- data/test/dummy/tmp/cache/assets/D21/CE0/sprockets%2F85c75ccf1618c6e9214374fa80ff6a78 +0 -0
- data/test/dummy/tmp/cache/assets/D23/8A0/sprockets%2F6175cb8fa517f52908739e3b478ef4bd +0 -0
- data/test/dummy/tmp/cache/assets/D24/DF0/sprockets%2F205e10fc11b2c5ed047b48e7d13ca262 +0 -0
- data/test/dummy/tmp/cache/assets/D25/860/sprockets%2Ff8260dc5f64465554e619b1e8d8e5fb7 +0 -0
- data/test/dummy/tmp/cache/assets/D27/BB0/sprockets%2F1ce3f0373575afde958376fec61658e8 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D35/000/sprockets%2F26017814dcf3891ad5be86ec7005a0ae +0 -0
- data/test/dummy/tmp/cache/assets/D38/250/sprockets%2F80644f3f31455068a51deebec0aa7a86 +0 -0
- data/test/dummy/tmp/cache/assets/D41/DF0/sprockets%2F86004b9b60de26aa7d87a1ff8b828f21 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D4F/1A0/sprockets%2F7901d59d8f722a5ebfff972429bb2d45 +0 -0
- data/test/dummy/tmp/cache/assets/D4F/4A0/sprockets%2F4fcb3c5126d2489feb99578dfa0c8507 +0 -0
- data/test/dummy/tmp/cache/assets/D52/E40/sprockets%2F04b1950fad18f3bcf64d30120da8b40b +0 -0
- data/test/dummy/tmp/cache/assets/D52/FD0/sprockets%2F19d7b68fb60b78d7519fc64d3c9a05f6 +0 -0
- data/test/dummy/tmp/cache/assets/D59/F30/sprockets%2F9dff7df99c759433823d4030cea998ac +0 -0
- data/test/dummy/tmp/cache/assets/D5A/850/sprockets%2F4015515d4be88de02aa43ff1b0abb594 +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D5C/030/sprockets%2F85440ce896b9da860fd37bb1e58f978e +0 -0
- data/test/dummy/tmp/cache/assets/D65/DA0/sprockets%2Fd0515dae6856f8da160c5d3050aa8b8e +0 -0
- data/test/dummy/tmp/cache/assets/D68/CD0/sprockets%2F9d829309524cfa22a0bdddf62c817d2a +0 -0
- data/test/dummy/tmp/cache/assets/D6B/A10/sprockets%2Fe2054cdbee145cdb51eb971863f54c80 +0 -0
- data/test/dummy/tmp/cache/assets/D6C/4B0/sprockets%2F543f257da84ce9914a414c3ffc1ad5a5 +0 -0
- data/test/dummy/tmp/cache/assets/D6C/AC0/sprockets%2Ffc095dd6183c1fcdf793351aa0b9057c +0 -0
- data/test/dummy/tmp/cache/assets/D71/520/sprockets%2Fc8e0327abdc946f27d2a91311ddd868e +0 -0
- data/test/dummy/tmp/cache/assets/D72/B90/sprockets%2Fc267891912fff9a3fa22ae346ba4f82b +0 -0
- data/test/dummy/tmp/cache/assets/D7C/E70/sprockets%2F9cae95be6892da1bf96c244c0d58069c +0 -0
- data/test/dummy/tmp/cache/assets/D7D/750/sprockets%2F8755c9ddd1217ce9ab854a429c4f7e3d +0 -0
- data/test/dummy/tmp/cache/assets/D91/D00/sprockets%2Fc1e1b10c6a5879ae7a2a875b0dbd357a +0 -0
- data/test/dummy/tmp/cache/assets/D95/0C0/sprockets%2Ffce9642718191a3112260ccbc8cafefc +0 -0
- data/test/dummy/tmp/cache/assets/D9A/DE0/sprockets%2Fcd78fb20bde75dba85a0c62b4838542c +0 -0
- data/test/dummy/tmp/cache/assets/DBB/440/sprockets%2Fe68195d6a29fe5fd90ded7559fccb429 +0 -0
- data/test/dummy/tmp/cache/assets/DBB/A30/sprockets%2Fe70dc841dca9ceee2e413a1661ed0b03 +0 -0
- data/test/dummy/tmp/cache/assets/DBF/3A0/sprockets%2F3c82ed0abb7057c1e728ac0f2ca41df9 +0 -0
- data/test/dummy/tmp/cache/assets/DC0/490/sprockets%2F5e0aebe091b8cea050c89d4ea19e080b +0 -0
- data/test/dummy/tmp/cache/assets/DC9/380/sprockets%2F2aaba93d71e5b9e178b0ce2df59eb603 +0 -0
- data/test/dummy/tmp/cache/assets/DCC/450/sprockets%2Fb3392d6eaf0e4cc318e19b6beb59b33f +0 -0
- data/test/dummy/tmp/cache/assets/DD0/2F0/sprockets%2F2cb2d409afda49a014f5bfef65f75c67 +0 -0
- data/test/dummy/tmp/cache/assets/DD9/030/sprockets%2F22d64f8febf6fc918b3a9ff6ad40441f +0 -0
- data/test/dummy/tmp/cache/assets/DDA/760/sprockets%2F31d55e4ecf03fbd5d71d5d7fd6d6d586 +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/DDC/630/sprockets%2Fd23e663fbbe6dfdb81e7a5d86d87b507 +0 -0
- data/test/dummy/tmp/cache/assets/DEA/760/sprockets%2Fcf1c5cfb9b1239a5b3dee52a3dd5001e +0 -0
- data/test/dummy/tmp/cache/assets/DED/500/sprockets%2F6b8b0740ec26f31fe0bcaa5ecd1e75a4 +0 -0
- data/test/dummy/tmp/cache/assets/DF1/B80/sprockets%2Fae7705cefbeb7308c73ba3a7a42c6a1f +0 -0
- data/test/dummy/tmp/cache/assets/DF6/DE0/sprockets%2Fd4eb25c8857c4c413cacaf6e7a0ccd26 +0 -0
- data/test/dummy/tmp/cache/assets/DF8/1A0/sprockets%2F0f9b45b1ca394c1aedc6febec735820f +0 -0
- data/test/dummy/tmp/cache/assets/DFE/980/sprockets%2F3493099ba61bb24ebec3f59cddf08ead +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E29/000/sprockets%2F6d13db8fbbd48dbce7392e43ac0ecb46 +0 -0
- data/test/dummy/tmp/cache/assets/E31/930/sprockets%2Ff68b89fd7200b23eccd9b1ba9afff3d3 +0 -0
- data/test/dummy/tmp/cache/assets/E79/780/sprockets%2Fd7e2d10be0ca0abfe06ecab1d3868dfd +0 -0
- data/test/fixtures/files/1000Hz-5sec.mp3 +0 -0
- data/test/fixtures/files/lorem-ipsum +7 -0
- data/test/fixtures/files/lorem-ipsum.jpg +0 -0
- data/test/fixtures/files/lorem-ipsum.ods +0 -0
- data/test/fixtures/files/lorem-ipsum.odt +0 -0
- data/test/fixtures/files/lorem-ipsum.pdf +0 -0
- data/test/fixtures/files/lorem-ipsum.txt +7 -0
- data/test/fixtures/users.yml +10 -0
- data/test/functional/uploads_controller_test.rb +14 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +52 -0
- data/test/unit/file_storage_test.rb +157 -0
- data/test/unit/helpers/uploads_helper_test.rb +4 -0
- data/test/unit/icon_and_thumb_test.rb +36 -0
- data/test/unit/mime_types_test.rb +74 -0
- data/test/unit/name_test.rb +51 -0
- data/test/unit/scope_test.rb +162 -0
- data/test/unit/upload_test.rb +7 -0
- data/test/upload_test_helper.rb +52 -0
- metadata +486 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean consequat eros id erat sagittis vitae molestie velit porta. Nunc dignissim tellus vel orci laoreet tempor. Mauris tristique interdum nisi, tempor convallis lacus bibendum ut. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Morbi a urna purus, in condimentum nisl. Quisque in mi et lacus facilisis sodales in at velit. Aliquam a urna neque. Nulla lacus tortor, ultrices eu pharetra a, consectetur id nunc. Nullam nisi ligula, facilisis vel tempor nec, tempus vel nisi. Pellentesque non pharetra nisl. Donec eu venenatis turpis. Quisque scelerisque tellus interdum eros eleifend non mattis purus viverra. Fusce malesuada metus nec augue mollis laoreet. Cras sit amet libero ante. Aliquam ornare, urna vestibulum tempus blandit, enim ante mollis libero, ac condimentum augue leo sit amet est.
|
2
|
+
|
3
|
+
Donec placerat, tellus non rhoncus hendrerit, orci erat porta neque, a pretium urna neque dapibus ligula. Sed posuere placerat bibendum. Aenean nec mi a nulla sollicitudin consectetur. Phasellus accumsan egestas magna porttitor elementum. Curabitur lobortis ligula non nisi fringilla sodales. Praesent ut leo quis arcu convallis tempor id at purus. Sed nec neque mauris. Integer sodales, urna ut volutpat commodo, erat nulla interdum magna, laoreet semper risus odio at nisi. In sit amet ipsum magna, in tincidunt nibh.
|
4
|
+
|
5
|
+
Maecenas nisi augue, viverra ac dignissim eu, consequat nec augue. Proin congue elit non nunc elementum quis faucibus turpis consequat. Donec sagittis interdum tortor, in aliquet mi faucibus non. Morbi ultrices placerat quam non sagittis. Donec accumsan commodo quam, at lacinia turpis varius ac. Proin ultrices, quam gravida commodo ultrices, tortor mi volutpat dolor, eu condimentum justo urna sed nisi. Duis sed nulla nec ligula accumsan auctor. Suspendisse tortor massa, aliquam vel commodo ac, accumsan et lacus. Nullam tempor justo eget leo auctor laoreet condimentum risus commodo. Nullam ultricies sem et risus condimentum fringilla. Ut pellentesque laoreet turpis.
|
6
|
+
|
7
|
+
Nulla convallis vulputate ultrices. Nullam dapibus fringilla metus, id lacinia metus interdum eget. Ut volutpat, arcu eu lacinia vulputate, libero enim tincidunt ante, ut fermentum lectus mauris in urna. Proin ut convallis dui. Aliquam condimentum, magna id tincidunt tempus, massa felis laoreet nibh, et pretium orci nulla a enim. Donec id mauris vel nibh vehicula euismod quis bibendum lacus. Mauris ac nulla a lacus sagittis accumsan non sed erat. Nam ultricies pharetra dolor, a adipiscing leo congue quis. Vivamus scelerisque auctor dui id volutpat. Sed placerat, dui eget fermentum pharetra, mi erat auctor mauris, ut vulputate lectus odio dignissim eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean consequat eros id erat sagittis vitae molestie velit porta. Nunc dignissim tellus vel orci laoreet tempor. Mauris tristique interdum nisi, tempor convallis lacus bibendum ut. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Morbi a urna purus, in condimentum nisl. Quisque in mi et lacus facilisis sodales in at velit. Aliquam a urna neque. Nulla lacus tortor, ultrices eu pharetra a, consectetur id nunc. Nullam nisi ligula, facilisis vel tempor nec, tempus vel nisi. Pellentesque non pharetra nisl. Donec eu venenatis turpis. Quisque scelerisque tellus interdum eros eleifend non mattis purus viverra. Fusce malesuada metus nec augue mollis laoreet. Cras sit amet libero ante. Aliquam ornare, urna vestibulum tempus blandit, enim ante mollis libero, ac condimentum augue leo sit amet est.
|
2
|
+
|
3
|
+
Donec placerat, tellus non rhoncus hendrerit, orci erat porta neque, a pretium urna neque dapibus ligula. Sed posuere placerat bibendum. Aenean nec mi a nulla sollicitudin consectetur. Phasellus accumsan egestas magna porttitor elementum. Curabitur lobortis ligula non nisi fringilla sodales. Praesent ut leo quis arcu convallis tempor id at purus. Sed nec neque mauris. Integer sodales, urna ut volutpat commodo, erat nulla interdum magna, laoreet semper risus odio at nisi. In sit amet ipsum magna, in tincidunt nibh.
|
4
|
+
|
5
|
+
Maecenas nisi augue, viverra ac dignissim eu, consequat nec augue. Proin congue elit non nunc elementum quis faucibus turpis consequat. Donec sagittis interdum tortor, in aliquet mi faucibus non. Morbi ultrices placerat quam non sagittis. Donec accumsan commodo quam, at lacinia turpis varius ac. Proin ultrices, quam gravida commodo ultrices, tortor mi volutpat dolor, eu condimentum justo urna sed nisi. Duis sed nulla nec ligula accumsan auctor. Suspendisse tortor massa, aliquam vel commodo ac, accumsan et lacus. Nullam tempor justo eget leo auctor laoreet condimentum risus commodo. Nullam ultricies sem et risus condimentum fringilla. Ut pellentesque laoreet turpis.
|
6
|
+
|
7
|
+
Nulla convallis vulputate ultrices. Nullam dapibus fringilla metus, id lacinia metus interdum eget. Ut volutpat, arcu eu lacinia vulputate, libero enim tincidunt ante, ut fermentum lectus mauris in urna. Proin ut convallis dui. Aliquam condimentum, magna id tincidunt tempus, massa felis laoreet nibh, et pretium orci nulla a enim. Donec id mauris vel nibh vehicula euismod quis bibendum lacus. Mauris ac nulla a lacus sagittis accumsan non sed erat. Nam ultricies pharetra dolor, a adipiscing leo congue quis. Vivamus scelerisque auctor dui id volutpat. Sed placerat, dui eget fermentum pharetra, mi erat auctor mauris, ut vulputate lectus odio dignissim eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
admin:
|
2
|
+
email: "the_boss@my_offic.es"
|
3
|
+
password_digest: "$2a$10$Ua36a1Mzjx3SmwvOSzak3OJepBiW7NShdw1G90TeC9TBXriGcjvPi"
|
4
|
+
# password: "1"
|
5
|
+
admin: true
|
6
|
+
|
7
|
+
plain:
|
8
|
+
email: "just_a_guy@my_offic.es"
|
9
|
+
password_digest: "$2a$10$Ua36a1Mzjx3SmwvOSzak3OJepBiW7NShdw1G90TeC9TBXriGcjvPi"
|
10
|
+
# password: "1"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UploadsControllerTest < ActionController::TestCase
|
4
|
+
test "should get uploadify" do
|
5
|
+
get :uploadify
|
6
|
+
assert_response :success
|
7
|
+
end
|
8
|
+
|
9
|
+
test "should get destroy" do
|
10
|
+
get :destroy
|
11
|
+
assert_response :success
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
def image_magick_must_be_installed
|
2
|
+
convert = `which convert`
|
3
|
+
if "" == convert
|
4
|
+
puts "imagemagick must be installed for the tests to run."
|
5
|
+
puts "Please execute `sudo apt-get install imagemagick` and then try again"
|
6
|
+
exit
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
image_magick_must_be_installed
|
11
|
+
|
12
|
+
# Configure Rails Environment
|
13
|
+
ENV["RAILS_ENV"] = "test"
|
14
|
+
|
15
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
16
|
+
require "rails/test_help"
|
17
|
+
|
18
|
+
Rails.backtrace_cleaner.remove_silencers!
|
19
|
+
|
20
|
+
# Load support files
|
21
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
22
|
+
|
23
|
+
# Load fixtures from the engine
|
24
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
25
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
26
|
+
end
|
27
|
+
|
28
|
+
Paperclip.options[:log] = false
|
29
|
+
|
30
|
+
class ActiveSupport::TestCase
|
31
|
+
fixtures :all
|
32
|
+
|
33
|
+
def self.aws_setup
|
34
|
+
paperclip_config = AnotherUploader.configuration.has_attached_file_options
|
35
|
+
@@bucket ||= paperclip_config[:bucket]
|
36
|
+
AWS.config(paperclip_config[:s3_credentials])
|
37
|
+
AWS::S3.new
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.bucket
|
41
|
+
@@aws ||= self.aws_setup
|
42
|
+
@@aws.buckets[@@bucket]
|
43
|
+
end
|
44
|
+
|
45
|
+
def assert_remote_file_exists path
|
46
|
+
assert self.class.bucket.objects[path].exists?, "Expected #{path} to be uploaded to bucket #{@@bucket}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def config
|
50
|
+
AnotherUploader.configuration
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'upload_test_helper'
|
2
|
+
|
3
|
+
class FileStorageTest < UploadTestHelper
|
4
|
+
setup do
|
5
|
+
@path_to_created_files = File.dirname(__FILE__)+"/../dummy/public/system"
|
6
|
+
given_s3_is_disabled
|
7
|
+
end
|
8
|
+
|
9
|
+
def each_style &block
|
10
|
+
config.has_attached_file_options[:styles].keys.each { |style|
|
11
|
+
yield style
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def attachment_path filename, style
|
16
|
+
"000/000/001/#{style}/#{filename}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def remote_path filename, style
|
20
|
+
"remotes/#{attachment_path filename, style}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def local_path filename, style
|
24
|
+
"#{@path_to_created_files}/locals/#{attachment_path filename, style}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def assert_each_style_was_saved_on_s3_for file
|
28
|
+
each_style { |style|
|
29
|
+
assert_remote_file_exists remote_path(file[:name], style)
|
30
|
+
}
|
31
|
+
assert_remote_file_exists remote_path(file[:name], :original)
|
32
|
+
end
|
33
|
+
|
34
|
+
def assert_only_original_was_saved_on_filesystem_for file
|
35
|
+
assert_file_saved_on_local_filesystem file[:name], :original
|
36
|
+
each_style { |style|
|
37
|
+
path = local_path file[:name], style
|
38
|
+
assert !File.file?(path), "Expected no file to exist at #{path}"
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def assert_file_saved_on_local_filesystem name, style
|
43
|
+
path = local_path name, style
|
44
|
+
assert File.file?(path), "Expected file to be uploaded to #{path}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def assert_each_style_was_saved_on_filesystem_for file
|
48
|
+
each_style { |style|
|
49
|
+
assert_file_saved_on_local_filesystem file[:name], style
|
50
|
+
}
|
51
|
+
assert_file_saved_on_local_filesystem file[:name], :original
|
52
|
+
end
|
53
|
+
|
54
|
+
def assert_the_file_only_exists_locally
|
55
|
+
assert @upload.exists_locally?, "The file should exist locally"
|
56
|
+
assert !@upload.exists_remotely?, "The file should not exist remotely"
|
57
|
+
end
|
58
|
+
|
59
|
+
def assert_the_file_only_exists_remotely
|
60
|
+
assert !@upload.exists_locally?, "The file should not exist locally"
|
61
|
+
assert @upload.exists_remotely?, "The file should exist remotely"
|
62
|
+
end
|
63
|
+
|
64
|
+
def assert_dimensions
|
65
|
+
assert_equal 503, @upload.width
|
66
|
+
assert_equal 350, @upload.height
|
67
|
+
assert_equal "503x350", @upload.size
|
68
|
+
end
|
69
|
+
|
70
|
+
def assert_file_attributes_match original
|
71
|
+
assert_equal original[:name], @upload.file_name, original.inspect
|
72
|
+
assert_equal original[:type], @upload.content_type, original.inspect
|
73
|
+
assert_equal original[:size], @upload.file_size, original.inspect
|
74
|
+
assert_equal original[:fingerprint], @upload.fingerprint, original.inspect
|
75
|
+
end
|
76
|
+
|
77
|
+
def when_i_upload_to_s3_a file
|
78
|
+
given_s3_is_immediate
|
79
|
+
when_i_upload_a file
|
80
|
+
end
|
81
|
+
|
82
|
+
test "can upload an image to local filesystem" do
|
83
|
+
when_i_upload_a IMAGE
|
84
|
+
assert @upload.save, @upload.errors.messages.inspect
|
85
|
+
assert_the_file_only_exists_locally
|
86
|
+
assert_each_style_was_saved_on_filesystem_for IMAGE
|
87
|
+
assert_file_attributes_match IMAGE
|
88
|
+
assert_dimensions
|
89
|
+
end
|
90
|
+
|
91
|
+
test "can upload an image directly to s3" do
|
92
|
+
when_i_upload_to_s3_a IMAGE
|
93
|
+
assert @upload.save, @upload.errors.messages.inspect
|
94
|
+
assert_the_file_only_exists_remotely
|
95
|
+
assert_each_style_was_saved_on_s3_for IMAGE
|
96
|
+
assert_file_attributes_match IMAGE
|
97
|
+
assert_dimensions
|
98
|
+
end
|
99
|
+
|
100
|
+
test "can move an image from local filesystem to s3" do
|
101
|
+
given_s3_is_deferred
|
102
|
+
when_i_upload_a IMAGE
|
103
|
+
@upload.save!
|
104
|
+
assert_the_file_only_exists_locally
|
105
|
+
@upload.send_to_remote
|
106
|
+
assert_the_file_only_exists_remotely
|
107
|
+
assert_each_style_was_saved_on_s3_for IMAGE
|
108
|
+
assert_file_attributes_match IMAGE
|
109
|
+
assert_dimensions
|
110
|
+
end
|
111
|
+
|
112
|
+
test "can upload non-image types to local filesystem" do
|
113
|
+
NON_IMAGE_FILES.each { |file|
|
114
|
+
when_i_upload_a file
|
115
|
+
assert @upload.save, @upload.errors.messages.inspect
|
116
|
+
assert_the_file_only_exists_locally
|
117
|
+
assert_file_attributes_match file
|
118
|
+
assert_only_original_was_saved_on_filesystem_for file
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
test "content type can be inferred when uploading" do
|
123
|
+
given_s3_is_disabled
|
124
|
+
ALL_FILES.each { |file|
|
125
|
+
@upload.file = fixture_file(file)
|
126
|
+
assert_file_attributes_match file
|
127
|
+
}
|
128
|
+
end
|
129
|
+
|
130
|
+
test "can_edit? compares creator to a user" do
|
131
|
+
@user = users(:plain)
|
132
|
+
@upload.creator = @user
|
133
|
+
when_i_upload_a PDF
|
134
|
+
assert @upload.can_edit?(@user)
|
135
|
+
assert !@upload.can_edit?(users(:admin))
|
136
|
+
end
|
137
|
+
|
138
|
+
test "can_edit? returns false when creator is nil" do
|
139
|
+
when_i_upload_a PDF
|
140
|
+
assert !@upload.can_edit?(users(:plain))
|
141
|
+
assert !@upload.can_edit?(users(:admin))
|
142
|
+
assert !@upload.can_edit?(@upload.creator)
|
143
|
+
assert !@upload.can_edit?('')
|
144
|
+
end
|
145
|
+
|
146
|
+
test "cannot send dirty file to remote" do
|
147
|
+
given_s3_is_deferred
|
148
|
+
when_i_upload_a DOC
|
149
|
+
assert_raise Paperclip::Error do
|
150
|
+
@upload.send_to_remote
|
151
|
+
end
|
152
|
+
@upload.save!
|
153
|
+
assert_the_file_only_exists_locally
|
154
|
+
@upload.send_to_remote
|
155
|
+
assert_the_file_only_exists_remotely
|
156
|
+
end
|
157
|
+
end
|