uploader 0.2.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -0
- data/README.rdoc +7 -2
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/app/controllers/uploader/uploads_controller.rb +2 -2
- data/app/helpers/uploader_helper.rb +51 -3
- data/app/views/uploads/_uploadify.html.erb +16 -0
- data/lib/active_record/acts/uploader_upload.rb +7 -6
- data/lib/daemons/amazonaws.rb +1 -1
- data/lib/uploader/middleware/flash_session_cookie_middleware.rb +4 -3
- data/lib/uploader/tasks.rb +1 -1
- data/locales/ar.yml +12 -12
- data/locales/bg.yml +13 -13
- data/locales/ca.yml +13 -13
- data/locales/cs.yml +13 -13
- data/locales/da.yml +8 -8
- data/locales/de.yml +12 -12
- data/locales/el.yml +16 -16
- data/locales/en.yml +2 -2
- data/locales/es.yml +12 -12
- data/locales/et.yml +14 -14
- data/locales/fa.yml +15 -15
- data/locales/fi.yml +14 -14
- data/locales/fr.yml +12 -12
- data/locales/gl.yml +15 -15
- data/locales/hi.yml +15 -15
- data/locales/hr.yml +13 -13
- data/locales/hu.yml +13 -13
- data/locales/id.yml +8 -8
- data/locales/it.yml +16 -16
- data/locales/iw.yml +12 -12
- data/locales/ja.yml +16 -16
- data/locales/ko.yml +13 -13
- data/locales/lt.yml +10 -10
- data/locales/lv.yml +11 -11
- data/locales/mt.yml +13 -13
- data/locales/nl.yml +8 -8
- data/locales/no.yml +8 -8
- data/locales/pl.yml +13 -13
- data/locales/pt-PT.yml +13 -13
- data/locales/ro.yml +13 -13
- data/locales/ru.yml +13 -13
- data/locales/sk.yml +14 -14
- data/locales/sl.yml +13 -13
- data/locales/sq.yml +13 -13
- data/locales/sr.yml +14 -14
- data/locales/sv.yml +6 -6
- data/locales/th.yml +18 -18
- data/locales/tl.yml +11 -11
- data/locales/tr.yml +15 -15
- data/locales/uk.yml +14 -14
- data/locales/vi.yml +12 -12
- data/locales/zh-CN.yml +11 -11
- data/locales/zh-TW.yml +11 -11
- data/locales/zh.yml +11 -11
- data/public/images/{SWFUploadButton.png → swfupload/SWFUploadButton.png} +0 -0
- data/public/images/{cancelbutton.gif → swfupload/cancelbutton.gif} +0 -0
- data/public/images/uploadify/cancel.png +0 -0
- data/public/javascripts/jquery/jquery.uploadify.min.js +26 -0
- data/public/javascripts/swf/swfobject.js +4 -0
- data/public/stylesheets/uploadify.css +53 -0
- data/public/swf/expressInstall.swf +0 -0
- data/public/swf/uploadify.swf +0 -0
- data/rails/init.rb +9 -1
- data/test/rails_root/app/controllers/application_controller.rb +4 -0
- data/test/rails_root/app/controllers/default_controller.rb +5 -0
- data/test/rails_root/app/models/upload.rb +26 -0
- data/test/rails_root/app/models/user.rb +11 -1
- data/test/rails_root/app/views/default/index.html.erb +6 -0
- data/test/rails_root/app/views/default/uploadify.html.erb +17 -0
- data/test/rails_root/config/environment.rb +1 -1
- data/test/rails_root/config/environments/test.rb +2 -8
- data/test/rails_root/config/routes.rb +1 -1
- data/test/rails_root/lib/daemons/amazonaws.rb +1 -1
- data/test/rails_root/public/images/cancelbutton.gif +0 -0
- data/test/rails_root/public/images/swfupload/SWFUploadButton.png +0 -0
- data/test/rails_root/public/images/swfupload/cancelbutton.gif +0 -0
- data/test/rails_root/public/images/uploadify/cancel.png +0 -0
- data/test/rails_root/public/javascripts/jquery/jquery-ui.js +763 -273
- data/test/rails_root/public/javascripts/jquery/jquery.js +150 -15
- data/test/rails_root/public/javascripts/jquery/jquery.uploadify.min.js +26 -0
- data/test/rails_root/public/javascripts/swf/swfobject.js +4 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.cookies.js +2 -2
- data/test/rails_root/public/javascripts/swfupload/swfupload.js +325 -136
- data/test/rails_root/public/javascripts/swfupload/swfupload.proxy.js +96 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.queue.js +83 -61
- data/test/rails_root/public/javascripts/swfupload/swfupload.speed.js +346 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.swfobject.js +4 -3
- data/test/rails_root/public/stylesheets/uploadify.css +53 -0
- data/test/rails_root/public/swf/expressInstall.swf +0 -0
- data/test/rails_root/public/swf/swfupload.swf +0 -0
- data/test/rails_root/public/swf/swfupload_fp9.swf +0 -0
- data/test/rails_root/public/swf/uploadify.swf +0 -0
- data/test/rails_root/test/factories.rb +1 -1
- data/test/rails_root/test/functional/default_controller_test.rb +20 -1
- data/test/rails_root/test/functional/uploads_controller_test.rb +21 -21
- data/test/rails_root/test/test_helper.rb +0 -1
- data/test/rails_root/test/unit/upload_test.rb +131 -32
- data/uploader.gemspec +28 -8
- metadata +31 -10
- data/locales/pt.yml +0 -17
@@ -38,11 +38,12 @@
|
|
38
38
|
*/
|
39
39
|
|
40
40
|
|
41
|
-
/*
|
42
|
-
Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
|
41
|
+
/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
|
42
|
+
Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
|
43
43
|
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
|
44
44
|
*/
|
45
|
-
var swfobject=function(){var
|
45
|
+
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
|
46
|
+
|
46
47
|
|
47
48
|
|
48
49
|
var SWFUpload;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/*
|
2
|
+
Uploadify v2.1.0
|
3
|
+
Release Date: August 24, 2009
|
4
|
+
|
5
|
+
Copyright (c) 2009 Ronnie Garcia, Travis Nickels
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
9
|
+
in the Software without restriction, including without limitation the rights
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
12
|
+
furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
15
|
+
all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
THE SOFTWARE.
|
24
|
+
*/
|
25
|
+
.uploadifyQueueItem {
|
26
|
+
font: 11px Verdana, Geneva, sans-serif;
|
27
|
+
border: 2px solid #E5E5E5;
|
28
|
+
background-color: #F5F5F5;
|
29
|
+
margin-top: 5px;
|
30
|
+
padding: 10px;
|
31
|
+
width: 350px;
|
32
|
+
}
|
33
|
+
.uploadifyError {
|
34
|
+
border: 2px solid #FBCBBC !important;
|
35
|
+
background-color: #FDE5DD !important;
|
36
|
+
}
|
37
|
+
.uploadifyQueueItem .cancel {
|
38
|
+
float: right;
|
39
|
+
}
|
40
|
+
.uploadifyProgress {
|
41
|
+
background-color: #FFFFFF;
|
42
|
+
border-top: 1px solid #808080;
|
43
|
+
border-left: 1px solid #808080;
|
44
|
+
border-right: 1px solid #C5C5C5;
|
45
|
+
border-bottom: 1px solid #C5C5C5;
|
46
|
+
margin-top: 10px;
|
47
|
+
width: 100%;
|
48
|
+
}
|
49
|
+
.uploadifyProgressBar {
|
50
|
+
background-color: #0099FF;
|
51
|
+
width: 1px;
|
52
|
+
height: 3px;
|
53
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -10,5 +10,5 @@ Factory.define :upload do |f|
|
|
10
10
|
f.creator {|a| a.association(:user)}
|
11
11
|
f.uploadable {|a| a.association(:user)}
|
12
12
|
f.caption { Factory.next(:name) }
|
13
|
-
f.local ActionController::TestUploadedFile.new(File.join(RAILS_ROOT, 'public/images/rails.png'), 'image/
|
13
|
+
f.local ActionController::TestUploadedFile.new(File.join(RAILS_ROOT, 'public/images/rails.png'), 'image/png')
|
14
14
|
end
|
@@ -13,7 +13,7 @@ class DefaultControllerTest < ActionController::TestCase
|
|
13
13
|
@user = Factory(:user)
|
14
14
|
get :index, :user_id => @user.to_param
|
15
15
|
end
|
16
|
-
|
16
|
+
should respond_with :success
|
17
17
|
should "have a_container_with_a_long_name in the body" do
|
18
18
|
assert @response.body.include?('a_container_with_a_long_name')
|
19
19
|
end
|
@@ -25,6 +25,25 @@ class DefaultControllerTest < ActionController::TestCase
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
context 'on GET to uploadify' do
|
29
|
+
# The default view calls the upload_form helper. This isn't a great test but
|
30
|
+
# it will make sure it doesn't blow up
|
31
|
+
setup do
|
32
|
+
@user = Factory(:user)
|
33
|
+
get :uploadify, :user_id => @user.to_param
|
34
|
+
end
|
35
|
+
should respond_with :success
|
36
|
+
should "have a_container_with_a_long_name in the body" do
|
37
|
+
assert @response.body.include?('a_container_with_a_long_name')
|
38
|
+
end
|
39
|
+
should "have '1310720' in the body" do
|
40
|
+
assert @response.body.include?('1310720')
|
41
|
+
end
|
42
|
+
should "have '*.jpg' in the body" do
|
43
|
+
assert @response.body.include?('*.jpg')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
28
47
|
end
|
29
48
|
|
30
49
|
end
|
@@ -15,8 +15,8 @@ class UploadsControllerTest < ActionController::TestCase
|
|
15
15
|
setup do
|
16
16
|
post :create, { :upload => { :local => VALID_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
17
17
|
end
|
18
|
-
|
19
|
-
|
18
|
+
should redirect_to("/create_success") { '/create_success' }
|
19
|
+
should set_the_flash.to(I18n.t('uploader.successful_upload'))
|
20
20
|
should "create a valid upload" do
|
21
21
|
assert_difference "@user.uploads.count", 1 do
|
22
22
|
post :create, { :upload => { :local => VALID_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
@@ -28,8 +28,8 @@ class UploadsControllerTest < ActionController::TestCase
|
|
28
28
|
setup do
|
29
29
|
post :create, { :upload => { :local => VALID_TEXT_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
30
30
|
end
|
31
|
-
|
32
|
-
|
31
|
+
should redirect_to("/create_success") { '/create_success' }
|
32
|
+
should set_the_flash.to(I18n.t('uploader.successful_upload'))
|
33
33
|
should "create a valid upload" do
|
34
34
|
assert_difference "@user.uploads.count", 1 do
|
35
35
|
post :create, { :upload => { :local => VALID_TEXT_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
@@ -41,8 +41,8 @@ class UploadsControllerTest < ActionController::TestCase
|
|
41
41
|
setup do
|
42
42
|
post :create, { :upload => { :local => VALID_PDF_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
43
43
|
end
|
44
|
-
|
45
|
-
|
44
|
+
should redirect_to("/create_success") { '/create_success' }
|
45
|
+
should set_the_flash.to(I18n.t('uploader.successful_upload'))
|
46
46
|
should "create a valid upload" do
|
47
47
|
assert_difference "@user.uploads.count", 1 do
|
48
48
|
post :create, { :upload => { :local => VALID_PDF_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
@@ -54,8 +54,8 @@ class UploadsControllerTest < ActionController::TestCase
|
|
54
54
|
setup do
|
55
55
|
post :create, { :upload => { :local => VALID_WORD_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
56
56
|
end
|
57
|
-
|
58
|
-
|
57
|
+
should redirect_to("/create_success") { '/create_success' }
|
58
|
+
should set_the_flash.to(I18n.t('uploader.successful_upload'))
|
59
59
|
should "create a valid upload" do
|
60
60
|
assert_difference "@user.uploads.count", 1 do
|
61
61
|
post :create, { :upload => { :local => VALID_WORD_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
@@ -67,8 +67,8 @@ class UploadsControllerTest < ActionController::TestCase
|
|
67
67
|
setup do
|
68
68
|
post :create, { :upload => { :local => VALID_EXCEL_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
69
69
|
end
|
70
|
-
|
71
|
-
|
70
|
+
should redirect_to("/create_success") { '/create_success' }
|
71
|
+
should set_the_flash.to(I18n.t('uploader.successful_upload'))
|
72
72
|
should "create a valid upload" do
|
73
73
|
assert_difference "@user.uploads.count", 1 do
|
74
74
|
post :create, { :upload => { :local => VALID_EXCEL_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
@@ -80,8 +80,8 @@ class UploadsControllerTest < ActionController::TestCase
|
|
80
80
|
setup do
|
81
81
|
post :create, { :upload => { :local => nil }, :parent_type => 'User', :parent_id => @user.to_param }
|
82
82
|
end
|
83
|
-
|
84
|
-
|
83
|
+
should redirect_to("/create_failure") { '/create_failure' }
|
84
|
+
should set_the_flash.to(/An error occured while uploading the file/)
|
85
85
|
should "not create file" do
|
86
86
|
assert_difference "@user.uploads.count", 1 do
|
87
87
|
post :create, { :upload => { :local => VALID_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
@@ -90,14 +90,14 @@ class UploadsControllerTest < ActionController::TestCase
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
|
-
context 'on POST to :
|
93
|
+
context 'on POST to :multiupload' do
|
94
94
|
setup do
|
95
|
-
post :
|
95
|
+
post :multiupload, { :Filedata => VALID_FILE, :parent_type => 'User', :parent_id => @user.to_param }
|
96
96
|
end
|
97
|
-
|
97
|
+
should respond_with :success
|
98
98
|
should "add an upload" do
|
99
99
|
assert_difference "Upload.count", 1 do
|
100
|
-
post :
|
100
|
+
post :multiupload, { :Filedata => VALID_FILE, :parent_type => 'User', :parent_id => @user.to_param }
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
@@ -107,7 +107,7 @@ class UploadsControllerTest < ActionController::TestCase
|
|
107
107
|
@controller.stubs(:has_permission_to_upload).returns(false)
|
108
108
|
post :create, { :upload => { :local => VALID_FILE }, :parent_type => 'User', :parent_id => @user.to_param }
|
109
109
|
end
|
110
|
-
|
110
|
+
should redirect_to("/permission_denied") { '/permission_denied' }
|
111
111
|
end
|
112
112
|
|
113
113
|
context 'on DELETE to :destroy' do
|
@@ -119,8 +119,8 @@ class UploadsControllerTest < ActionController::TestCase
|
|
119
119
|
setup do
|
120
120
|
delete :destroy, { :id => @upload.to_param }
|
121
121
|
end
|
122
|
-
|
123
|
-
|
122
|
+
should redirect_to("/destroy_success") { '/destroy_success' }
|
123
|
+
should set_the_flash.to(I18n.t('uploader.file_deleted'))
|
124
124
|
end
|
125
125
|
context "data changes" do
|
126
126
|
should "delete the upload" do
|
@@ -139,8 +139,8 @@ class UploadsControllerTest < ActionController::TestCase
|
|
139
139
|
setup do
|
140
140
|
delete :destroy, { :id => @upload.to_param }
|
141
141
|
end
|
142
|
-
|
143
|
-
|
142
|
+
should redirect_to("/destroy_success") { '/destroy_success' }
|
143
|
+
should set_the_flash.to(I18n.t('uploader.file_delete_permission_denied'))
|
144
144
|
end
|
145
145
|
context "data changes" do
|
146
146
|
should "not delete the upload" do
|
@@ -1,45 +1,144 @@
|
|
1
|
-
require 'test_helper'
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
3
|
class UploadTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
-
context
|
5
|
+
context "upload" do
|
6
|
+
context 'upload instance' do
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
should belong_to :uploadable
|
9
|
+
should belong_to :creator
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
should_have_attached_file :local
|
12
|
+
should_have_attached_file :remote
|
13
|
+
should_not allow_mass_assignment_of :creator_id
|
14
|
+
should_not allow_mass_assignment_of :uploadable_id
|
15
|
+
should_not allow_mass_assignment_of :uploadable_type
|
16
|
+
should_validate_attachment_size :local, :less_than => 10.megabytes
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
should 'use id_partitioning' do
|
19
|
+
upload = Upload.new
|
20
|
+
upload.stubs(:id).returns(12345)
|
21
|
+
upload.local = VALID_FILE
|
22
|
+
assert_equal "#{RAILS_ROOT}/public/system/locals/000/012/345/original/rails.png", upload.local.path
|
23
|
+
assert_equal '/system/locals/000/012/345/original/rails.png', upload.local.url(:original, false)
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'transliterate the filename' do
|
27
|
+
upload = Upload.new
|
28
|
+
file = fixture_file %Q{IT'sUPPERCASE!AND WeIRD.JPG}
|
29
|
+
upload.local = file
|
30
|
+
assert_equal 'itsuppercase-and-weird.jpg', upload.local.original_filename
|
31
|
+
file.close
|
32
|
+
end
|
33
|
+
|
21
34
|
end
|
22
35
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
36
|
+
context "Named scopes" do
|
37
|
+
context "'newest' named scope" do
|
38
|
+
setup do
|
39
|
+
Upload.delete_all
|
40
|
+
@first = Factory(:upload, :created_at => 1.day.ago)
|
41
|
+
@second = Factory(:upload, :created_at => 1.week.ago)
|
42
|
+
end
|
43
|
+
should "sort by created_at" do
|
44
|
+
assert_equal @first, Upload.newest[0]
|
45
|
+
assert_equal @second, Upload.newest[1]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
context "'recent' named scope" do
|
49
|
+
setup do
|
50
|
+
Upload.delete_all
|
51
|
+
@recent = Factory(:upload)
|
52
|
+
@not_recent = Factory(:upload, :created_at => 10.weeks.ago)
|
53
|
+
end
|
54
|
+
should "get recent" do
|
55
|
+
assert Upload.recent.include?(@recent), "since didn't include recent upload"
|
56
|
+
end
|
57
|
+
should "not get recent" do
|
58
|
+
assert !Upload.recent.include?(@not_recent), "since did include recent upload"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
context "'by_filename' named scope" do
|
62
|
+
setup do
|
63
|
+
Upload.delete_all
|
64
|
+
@first = Factory(:upload, :local_file_name => 'a')
|
65
|
+
@second = Factory(:upload, :local_file_name => 'b')
|
66
|
+
end
|
67
|
+
should "sort by name" do
|
68
|
+
assert_equal @first, Upload.by_filename[0]
|
69
|
+
assert_equal @second, Upload.by_filename[1]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
context "'public' named scope" do
|
73
|
+
setup do
|
74
|
+
Upload.delete_all
|
75
|
+
@first = Factory(:upload, :is_public => true)
|
76
|
+
@second = Factory(:upload, :is_public => false)
|
77
|
+
end
|
78
|
+
should "find public files" do
|
79
|
+
assert Upload.public.include?(@first)
|
80
|
+
assert !Upload.public.include?(@second)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
context "'pending_s3_migrations' named scope" do
|
84
|
+
setup do
|
85
|
+
Upload.delete_all
|
86
|
+
@first = Factory(:upload)
|
87
|
+
@second = Factory(:upload, :remote_file_name => 'test.png')
|
88
|
+
end
|
89
|
+
should "find pending_s3_migrations entries" do
|
90
|
+
assert Upload.pending_s3_migrations.include?(@first)
|
91
|
+
assert !Upload.pending_s3_migrations.include?(@second)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
context "'images' named scope" do
|
95
|
+
setup do
|
96
|
+
Upload.delete_all
|
97
|
+
@first = Factory(:upload) # default is png
|
98
|
+
@second = Factory(:upload, :local => ActionController::TestUploadedFile.new(File.join(RAILS_ROOT, 'test/test.doc'), 'application/msword'))
|
99
|
+
end
|
100
|
+
should "find images" do
|
101
|
+
assert Upload.images.include?(@first)
|
102
|
+
assert !Upload.images.include?(@second)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
context "'documents' named scope" do
|
106
|
+
setup do
|
107
|
+
Upload.delete_all
|
108
|
+
@first = Factory(:upload, :local => ActionController::TestUploadedFile.new(File.join(RAILS_ROOT, 'test/test.doc'), 'application/msword'))
|
109
|
+
@second = Factory(:upload)
|
110
|
+
end
|
111
|
+
should "find documents" do
|
112
|
+
assert Upload.documents.include?(@first)
|
113
|
+
assert !Upload.documents.include?(@second)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
context "'files' named scope" do
|
117
|
+
setup do
|
118
|
+
Upload.delete_all
|
119
|
+
@first = Factory(:upload, :local => ActionController::TestUploadedFile.new(File.join(RAILS_ROOT, 'test/test.pdf'), 'application/pdf'))
|
120
|
+
@second = Factory(:upload)
|
121
|
+
end
|
122
|
+
should "find files (not images)" do
|
123
|
+
assert Upload.files.include?(@first)
|
124
|
+
assert !Upload.files.include?(@second)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
context "'created_by' named scope" do
|
128
|
+
setup do
|
129
|
+
Upload.delete_all
|
130
|
+
@creator_id = 28
|
131
|
+
@first = Factory(:upload, :creator_id => @creator_id)
|
132
|
+
@second = Factory(:upload)
|
133
|
+
end
|
134
|
+
should "find by creator" do
|
135
|
+
assert Upload.created_by(@creator_id).include?(@first)
|
136
|
+
assert !Upload.created_by(@creator_id).include?(@second)
|
137
|
+
end
|
138
|
+
end
|
29
139
|
end
|
30
|
-
|
31
|
-
end
|
32
140
|
|
33
|
-
|
34
|
-
should_have_named_scope :newest_first
|
35
|
-
should_have_named_scope :alphabetic
|
36
|
-
should_have_named_scope :recent
|
37
|
-
should_have_named_scope :public
|
38
|
-
should_have_named_scope :images
|
39
|
-
should_have_named_scope :documents
|
40
|
-
should_have_named_scope :files
|
41
|
-
should_have_named_scope :since
|
42
|
-
should_have_named_scope :pending_s3_migration
|
141
|
+
end
|
43
142
|
|
44
143
|
private
|
45
144
|
def fixture_file(name)
|
data/uploader.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{uploader}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Justin Ball", "David South"]
|
12
|
-
s.date = %q{2010-08-
|
13
|
-
s.description = %q{Uploader gem that makes it simple add multiple file uploads to your Rails project using SWFUpload and Paperclip}
|
11
|
+
s.authors = ["Justin Ball", "Joel Duffin", "David South"]
|
12
|
+
s.date = %q{2010-08-30}
|
13
|
+
s.description = %q{Uploader gem that makes it simple add multiple file uploads to your Rails project using SWFUpload, Uploadify and Paperclip}
|
14
14
|
s.email = %q{justinball@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc",
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".gitignore",
|
21
|
+
"Gemfile",
|
21
22
|
"MIT-LICENSE",
|
22
23
|
"README.rdoc",
|
23
24
|
"Rakefile",
|
@@ -27,6 +28,7 @@ Gem::Specification.new do |s|
|
|
27
28
|
"app/helpers/uploader_helper.rb",
|
28
29
|
"app/views/uploads/_swf_javascript.html.erb",
|
29
30
|
"app/views/uploads/_swf_upload.html.erb",
|
31
|
+
"app/views/uploads/_uploadify.html.erb",
|
30
32
|
"config/uploader_routes.rb",
|
31
33
|
"db/migrate/20090517040220_create_uploads.rb",
|
32
34
|
"lib/active_record/acts/uploader_upload.rb",
|
@@ -66,7 +68,6 @@ Gem::Specification.new do |s|
|
|
66
68
|
"locales/no.yml",
|
67
69
|
"locales/pl.yml",
|
68
70
|
"locales/pt-PT.yml",
|
69
|
-
"locales/pt.yml",
|
70
71
|
"locales/ro.yml",
|
71
72
|
"locales/ru.yml",
|
72
73
|
"locales/sk.yml",
|
@@ -82,8 +83,6 @@ Gem::Specification.new do |s|
|
|
82
83
|
"locales/zh-CN.yml",
|
83
84
|
"locales/zh-TW.yml",
|
84
85
|
"locales/zh.yml",
|
85
|
-
"public/images/SWFUploadButton.png",
|
86
|
-
"public/images/cancelbutton.gif",
|
87
86
|
"public/images/file_icons/excel.gif",
|
88
87
|
"public/images/file_icons/file.gif",
|
89
88
|
"public/images/file_icons/file.png",
|
@@ -132,6 +131,11 @@ Gem::Specification.new do |s|
|
|
132
131
|
"public/images/file_icons/text.gif",
|
133
132
|
"public/images/file_icons/text.png",
|
134
133
|
"public/images/file_icons/word.gif",
|
134
|
+
"public/images/swfupload/SWFUploadButton.png",
|
135
|
+
"public/images/swfupload/cancelbutton.gif",
|
136
|
+
"public/images/uploadify/cancel.png",
|
137
|
+
"public/javascripts/jquery/jquery.uploadify.min.js",
|
138
|
+
"public/javascripts/swf/swfobject.js",
|
135
139
|
"public/javascripts/swfupload/fileprogress.js",
|
136
140
|
"public/javascripts/swfupload/handlers.js",
|
137
141
|
"public/javascripts/swfupload/swfupload.cookies.js",
|
@@ -141,8 +145,11 @@ Gem::Specification.new do |s|
|
|
141
145
|
"public/javascripts/swfupload/swfupload.speed.js",
|
142
146
|
"public/javascripts/swfupload/swfupload.swfobject.js",
|
143
147
|
"public/stylesheets/swfupload.css",
|
148
|
+
"public/stylesheets/uploadify.css",
|
149
|
+
"public/swf/expressInstall.swf",
|
144
150
|
"public/swf/swfupload.swf",
|
145
151
|
"public/swf/swfupload_fp9.swf",
|
152
|
+
"public/swf/uploadify.swf",
|
146
153
|
"rails/init.rb",
|
147
154
|
"tasks/rails.rake",
|
148
155
|
"test/rails_root/.gitignore",
|
@@ -156,6 +163,7 @@ Gem::Specification.new do |s|
|
|
156
163
|
"test/rails_root/app/models/upload.rb",
|
157
164
|
"test/rails_root/app/models/user.rb",
|
158
165
|
"test/rails_root/app/views/default/index.html.erb",
|
166
|
+
"test/rails_root/app/views/default/uploadify.html.erb",
|
159
167
|
"test/rails_root/app/views/layouts/application.html.erb",
|
160
168
|
"test/rails_root/config/amazon_s3.yml",
|
161
169
|
"test/rails_root/config/boot.rb",
|
@@ -188,6 +196,7 @@ Gem::Specification.new do |s|
|
|
188
196
|
"test/rails_root/public/dispatch.rb",
|
189
197
|
"test/rails_root/public/favicon.ico",
|
190
198
|
"test/rails_root/public/images/SWFUploadButton.png",
|
199
|
+
"test/rails_root/public/images/cancelbutton.gif",
|
191
200
|
"test/rails_root/public/images/file_icons/excel.gif",
|
192
201
|
"test/rails_root/public/images/file_icons/file.gif",
|
193
202
|
"test/rails_root/public/images/file_icons/file.png",
|
@@ -237,6 +246,9 @@ Gem::Specification.new do |s|
|
|
237
246
|
"test/rails_root/public/images/file_icons/text.png",
|
238
247
|
"test/rails_root/public/images/file_icons/word.gif",
|
239
248
|
"test/rails_root/public/images/rails.png",
|
249
|
+
"test/rails_root/public/images/swfupload/SWFUploadButton.png",
|
250
|
+
"test/rails_root/public/images/swfupload/cancelbutton.gif",
|
251
|
+
"test/rails_root/public/images/uploadify/cancel.png",
|
240
252
|
"test/rails_root/public/javascripts/application.js",
|
241
253
|
"test/rails_root/public/javascripts/builder.js",
|
242
254
|
"test/rails_root/public/javascripts/controls.js",
|
@@ -249,21 +261,29 @@ Gem::Specification.new do |s|
|
|
249
261
|
"test/rails_root/public/javascripts/jquery/jquery.jgrowl.js",
|
250
262
|
"test/rails_root/public/javascripts/jquery/jquery.js",
|
251
263
|
"test/rails_root/public/javascripts/jquery/jquery.tips.js",
|
264
|
+
"test/rails_root/public/javascripts/jquery/jquery.uploadify.min.js",
|
252
265
|
"test/rails_root/public/javascripts/jquery/jrails.js",
|
253
266
|
"test/rails_root/public/javascripts/prototype.js",
|
254
267
|
"test/rails_root/public/javascripts/scriptaculous.js",
|
255
268
|
"test/rails_root/public/javascripts/slider.js",
|
256
269
|
"test/rails_root/public/javascripts/sound.js",
|
270
|
+
"test/rails_root/public/javascripts/swf/swfobject.js",
|
257
271
|
"test/rails_root/public/javascripts/swfupload/fileprogress.js",
|
258
272
|
"test/rails_root/public/javascripts/swfupload/handlers.js",
|
259
273
|
"test/rails_root/public/javascripts/swfupload/swfupload.cookies.js",
|
260
274
|
"test/rails_root/public/javascripts/swfupload/swfupload.js",
|
275
|
+
"test/rails_root/public/javascripts/swfupload/swfupload.proxy.js",
|
261
276
|
"test/rails_root/public/javascripts/swfupload/swfupload.queue.js",
|
277
|
+
"test/rails_root/public/javascripts/swfupload/swfupload.speed.js",
|
262
278
|
"test/rails_root/public/javascripts/swfupload/swfupload.swfobject.js",
|
263
279
|
"test/rails_root/public/robots.txt",
|
264
280
|
"test/rails_root/public/stylesheets/.keep",
|
265
281
|
"test/rails_root/public/stylesheets/swfupload.css",
|
282
|
+
"test/rails_root/public/stylesheets/uploadify.css",
|
283
|
+
"test/rails_root/public/swf/expressInstall.swf",
|
266
284
|
"test/rails_root/public/swf/swfupload.swf",
|
285
|
+
"test/rails_root/public/swf/swfupload_fp9.swf",
|
286
|
+
"test/rails_root/public/swf/uploadify.swf",
|
267
287
|
"test/rails_root/script/about",
|
268
288
|
"test/rails_root/script/breakpointer",
|
269
289
|
"test/rails_root/script/console",
|
@@ -305,7 +325,7 @@ Gem::Specification.new do |s|
|
|
305
325
|
s.require_paths = ["lib"]
|
306
326
|
s.rubyforge_project = %q{uploader}
|
307
327
|
s.rubygems_version = %q{1.3.7}
|
308
|
-
s.summary = %q{SWFUpload + Paperclip wrapped in an engine with love.}
|
328
|
+
s.summary = %q{Uploadify, SWFUpload + Paperclip wrapped in an engine with love.}
|
309
329
|
s.test_files = [
|
310
330
|
"test/rails_root/app/controllers/application_controller.rb",
|
311
331
|
"test/rails_root/app/controllers/default_controller.rb",
|