file_upload 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/file_upload/application.js +13 -0
- data/app/assets/javascripts/file_upload.js.erb +148 -0
- data/app/assets/stylesheets/file_upload/application.css +13 -0
- data/app/assets/stylesheets/file_upload.css +3 -0
- data/app/controllers/file_upload/application_controller.rb +4 -0
- data/app/controllers/file_upload/redis_files_controller.rb +54 -0
- data/app/helpers/file_upload/application_helper.rb +4 -0
- data/app/helpers/file_upload/tag_helper.rb +25 -0
- data/app/models/file_upload/builder_mixin.rb +13 -0
- data/app/models/file_upload/redis_file.rb +159 -0
- data/app/models/file_upload/redis_file_readable.rb +21 -0
- data/app/models/file_upload/temp_file.rb +17 -0
- data/app/views/file_upload/redis_files/index.html.erb +1 -0
- data/app/views/file_upload/redis_files/new.html.erb +9 -0
- data/app/views/file_upload/redis_files/show.html.erb +15 -0
- data/app/views/file_upload/tags/_multiple.html.erb +44 -0
- data/app/views/file_upload/tags/_single.html.erb +46 -0
- data/app/views/layouts/file_upload/application.html.erb +14 -0
- data/config/routes.rb +6 -0
- data/lib/file_upload/engine.rb +40 -0
- data/lib/file_upload/version.rb +3 -0
- data/lib/file_upload.rb +7 -0
- data/lib/tasks/file_upload_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/jquery-1.10.2.min.js +6 -0
- data/test/dummy/app/assets/javascripts/jquery-ui.js +15003 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/db_files_controller.rb +8 -0
- data/test/dummy/app/controllers/emails_controller.rb +43 -0
- data/test/dummy/app/controllers/users_controller.rb +42 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/db_file.rb +13 -0
- data/test/dummy/app/models/email.rb +10 -0
- data/test/dummy/app/models/user.rb +9 -0
- data/test/dummy/app/views/db_files/_db_file.html.erb +1 -0
- data/test/dummy/app/views/emails/_email.html.erb +3 -0
- data/test/dummy/app/views/emails/_form.html.erb +24 -0
- data/test/dummy/app/views/emails/edit.html.erb +3 -0
- data/test/dummy/app/views/emails/index.html.erb +5 -0
- data/test/dummy/app/views/emails/new.html.erb +3 -0
- data/test/dummy/app/views/emails/show.html.erb +14 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/users/_form.html.erb +20 -0
- data/test/dummy/app/views/users/_user.html.erb +1 -0
- data/test/dummy/app/views/users/edit.html.erb +3 -0
- data/test/dummy/app/views/users/index.html.erb +5 -0
- data/test/dummy/app/views/users/new.html.erb +3 -0
- data/test/dummy/app/views/users/show.html.erb +8 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +28 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +31 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +7 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130820025256_add_users.rb +21 -0
- data/test/dummy/db/schema.rb +34 -0
- data/test/dummy/log/development.log +15541 -0
- data/test/dummy/log/test.log +26004 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1027254ad9f9317017cee3f9f844a862 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/21e0ff88cf13ca60a86a9b629cdca847 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/24cf35cebd10e0755a5585f9e486aa35 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/27413a86db5db5977d5dd1d87c724907 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5c6d9c2c3107f94ad59710d3b31f75 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3131541e8089635bc8595e2da83d1d81 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/32f1d616324cf52e9876bb83b9b0841a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/33474263b3841cd98ef63cde45dc85b2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3fa0d13a4820d4aa56f86ed4af4b88fc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4e07f6f4475a0dca9066eec990db088a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5512d0b5788ce193fd26bfadccd21304 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5d5ab91fa7d1eee7502e703747d4e933 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6b7e97595c37161f619adfd2b7724ea2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/87fa3cc4e2e49762d146f3d1709b3fb0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8806d06f37e08b22f9546e50ab98d671 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8cdad172c92eaf76e1b71c84f58a192e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/91e53bdf30a2b8e78bf99ca794addf70 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/96e2b2964d1d31d997a1af35ad0afed2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ab5c07d7e81fb5d5cf7460715f22bef6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b94837629e2fb2ef40ea66348764a9a2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c360bf7b66d29ebdf71b5814574b5fed +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e046b0166566aeeb2da51f2bde543364 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ec2d15616d5d09eb1693b761c72948ce +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fc0327db3eb7c687c31f2acf94871f86 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1027254ad9f9317017cee3f9f844a862 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/21e0ff88cf13ca60a86a9b629cdca847 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/24cf35cebd10e0755a5585f9e486aa35 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/27413a86db5db5977d5dd1d87c724907 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/32f1d616324cf52e9876bb83b9b0841a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3fa0d13a4820d4aa56f86ed4af4b88fc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5d5ab91fa7d1eee7502e703747d4e933 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6b7e97595c37161f619adfd2b7724ea2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/87fa3cc4e2e49762d146f3d1709b3fb0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8806d06f37e08b22f9546e50ab98d671 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ab5c07d7e81fb5d5cf7460715f22bef6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b94837629e2fb2ef40ea66348764a9a2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c360bf7b66d29ebdf71b5814574b5fed +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e046b0166566aeeb2da51f2bde543364 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ec2d15616d5d09eb1693b761c72948ce +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fc0327db3eb7c687c31f2acf94871f86 +0 -0
- data/test/fixtures/avatar.jpeg +0 -0
- data/test/fixtures/test_upload.txt +1 -0
- data/test/integration/multiple_upload_test.rb +131 -0
- data/test/integration/single_upload_test.rb +157 -0
- data/test/test_helper.rb +60 -0
- data/test/unit/redis_file_readable_test.rb +30 -0
- data/test/unit/redis_file_test.rb +30 -0
- data/vendor/assets/javascripts/jquery.fileupload.js +1113 -0
- data/vendor/assets/javascripts/load-image.js +232 -0
- metadata +401 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RedisFileReadableTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
class TestFile
|
6
|
+
attr_accessor :name, :content_type, :size, :data
|
7
|
+
|
8
|
+
include FileUpload::RedisFileReadable
|
9
|
+
end
|
10
|
+
|
11
|
+
teardown do
|
12
|
+
FileUpload::Engine.config.redis.flushdb
|
13
|
+
end
|
14
|
+
|
15
|
+
test "can load data from a key" do
|
16
|
+
file = FileUpload::RedisFile.new({
|
17
|
+
:file_io => Rack::Test::UploadedFile.new(File.expand_path('../../fixtures/avatar.jpeg', __FILE__)),
|
18
|
+
})
|
19
|
+
assert file.save
|
20
|
+
|
21
|
+
tf = TestFile.new
|
22
|
+
tf.key = file.id
|
23
|
+
|
24
|
+
assert_equal("image/jpeg", tf.content_type)
|
25
|
+
assert_equal("avatar.jpeg", tf.name)
|
26
|
+
assert(tf.size)
|
27
|
+
assert(tf.data)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RedisFileTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
teardown do
|
6
|
+
FileUpload::Engine.config.redis.flushdb
|
7
|
+
end
|
8
|
+
|
9
|
+
test "can preserve attributes" do
|
10
|
+
|
11
|
+
tf = FileUpload::RedisFile.new({
|
12
|
+
:file_io => Rack::Test::UploadedFile.new(File.expand_path('../../fixtures/avatar.jpeg', __FILE__)),
|
13
|
+
})
|
14
|
+
assert_equal("image/jpeg", tf.type)
|
15
|
+
assert(tf.save, "should be able to save the file to redis")
|
16
|
+
|
17
|
+
tf2 = FileUpload::RedisFile.find(tf.id)
|
18
|
+
assert_equal(tf.key, tf2.key)
|
19
|
+
assert_equal("avatar.jpeg", tf2.name)
|
20
|
+
assert_equal("image/jpeg", tf2.type)
|
21
|
+
end
|
22
|
+
|
23
|
+
test "can detect file type" do
|
24
|
+
tf = FileUpload::RedisFile.new({
|
25
|
+
:file_io => Rack::Test::UploadedFile.new(File.expand_path('../../fixtures/test_upload.txt', __FILE__)),
|
26
|
+
})
|
27
|
+
assert_equal("text/plain", tf.type)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|