uploadcare-rails 0.6.1 → 1.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +1 -1
- data/Rakefile +13 -8
- data/app/assets/javascripts/uploadcare-0.17.0.js +8248 -0
- data/app/assets/javascripts/uploadcare-0.17.0.min.js +17 -0
- data/app/assets/javascripts/uploadcare.js +1 -1
- data/config/initializers/uploadcare.rb +27 -0
- data/config/uploadcare_defaults.yml +12 -0
- data/lib/generators/templates/uploadcare_config_template.yml +56 -0
- data/lib/generators/uploadcare_config_generator.rb +9 -0
- data/lib/tasks/uploadcare_rails_tasks.rake +4 -0
- data/lib/uploadcare-rails.rb +6 -2
- data/lib/uploadcare/rails/action_view_include_tags.rb +36 -0
- data/lib/uploadcare/rails/action_view_uploader_tags.rb +75 -0
- data/lib/uploadcare/rails/active_record_has_file.rb +46 -0
- data/lib/uploadcare/rails/active_record_has_group.rb +43 -0
- data/lib/uploadcare/rails/engine.rb +17 -11
- data/lib/uploadcare/rails/file.rb +17 -20
- data/lib/uploadcare/rails/group.rb +27 -0
- data/lib/uploadcare/rails/settings.rb +63 -50
- data/lib/uploadcare/rails/version.rb +1 -1
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/javascripts/post_with_collections.js +2 -0
- data/spec/dummy/app/assets/javascripts/posts.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/post_with_collections.css +4 -0
- data/spec/dummy/app/assets/stylesheets/posts.css +4 -0
- data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/post_with_collections_controller.rb +58 -0
- data/spec/dummy/app/controllers/posts_controller.rb +58 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/post_with_collections_helper.rb +2 -0
- data/spec/dummy/app/helpers/posts_helper.rb +2 -0
- data/spec/dummy/app/models/post.rb +3 -0
- data/spec/dummy/app/models/post_with_collection.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +16 -0
- data/spec/dummy/app/views/post_with_collections/_form.html.erb +25 -0
- data/spec/dummy/app/views/post_with_collections/edit.html.erb +6 -0
- data/spec/dummy/app/views/post_with_collections/index.html.erb +29 -0
- data/spec/dummy/app/views/post_with_collections/new.html.erb +5 -0
- data/spec/dummy/app/views/post_with_collections/show.html.erb +14 -0
- data/spec/dummy/app/views/posts/_form.html.erb +25 -0
- data/spec/dummy/app/views/posts/edit.html.erb +6 -0
- data/spec/dummy/app/views/posts/index.html.erb +37 -0
- data/spec/dummy/app/views/posts/new.html.erb +5 -0
- data/spec/dummy/app/views/posts/show.html.erb +15 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +61 -0
- data/spec/dummy/config/uploadcare.yml +56 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20131119080328_create_posts.rb +10 -0
- data/spec/dummy/db/migrate/20131220083857_create_post_with_collections.rb +10 -0
- data/spec/dummy/db/schema.rb +30 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +9900 -0
- data/spec/dummy/log/test.log +1976 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/65C/2B0/uc.file.123213.store +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1004cb216c6a15b26aa9c52095902ee6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1930f1dc4fdf14493b9e0803644ae54a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1e8f75a6b5b33970fb8e397347caa0a1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/24204f742af588c8166d3160b500d20f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/416150dc3ac35079c94273cc46e90aa6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5384ad85f52d3272dbc64d46ef3876a4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/883a8569a0105010b3a20e0b3dbdf927 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/95f1667ad97500a482296c32c98e0fa0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c5ee0ee454770d592be595422c5f89b8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c85016e7bbd4f3adbb7635d01f85d39b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d066c004d1fd26ae76a61303a7a18145 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e41598315cab1b953e63b62bc36ee2f6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/restart.txt +0 -0
- data/spec/helpers/form_helpers_has_file_spec.rb +30 -0
- data/spec/helpers/form_helpers_has_group_spec.rb +30 -0
- data/spec/helpers/form_helpers_spec.rb +33 -0
- data/spec/helpers/include_tags_spec.rb +42 -0
- data/spec/helpers/uploader_tags_spec.rb +15 -0
- data/spec/models/file.rb +25 -0
- data/spec/models/group.rb +36 -0
- data/spec/models/has_file_spec.rb +31 -0
- data/spec/models/has_group_spec.rb +31 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/uploadcare_rails_settings_spec.rb +50 -0
- metadata +290 -51
- data/README.md +0 -104
- data/app/assets/javascripts/uploadcare-0.8.js +0 -22865
- data/lib/uploadcare/rails/action_view.rb +0 -49
- data/lib/uploadcare/rails/active_record.rb +0 -61
- data/lib/uploadcare/rails/simple_form.rb +0 -9
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/404.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
54
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@valueI"asdasdsad:ET:@created_atf1384864182.072901:@expires_in0
|
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
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Uploadcare::Rails::ActionView::FormBuilder, type: :helper do
|
4
|
+
before(:each) do
|
5
|
+
@post = Post.new
|
6
|
+
@form = ActionView::Helpers::FormBuilder.new(:post, @post, helper, {}, nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should include uploader tag for name" do
|
10
|
+
# not that post has uc file
|
11
|
+
tag = @form.uploadcare_field :file
|
12
|
+
tag.should be_kind_of(String)
|
13
|
+
tag.should have_selector("input", :type => "hidden", "data-multiple" => "false")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should override uploadcare- attribute" do
|
17
|
+
tag = @form.uploadcare_field :file, :uploadcare => {:multiple => true}
|
18
|
+
tag.should have_selector("input", :type => "hidden", "data-multiple" => "false")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should override data- attribute" do
|
22
|
+
tag = @form.uploadcare_field :file, :data => {:multiple => true}
|
23
|
+
tag.should have_selector("input", :type => "hidden", "data-multiple" => "false")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should override data- and uploadcare- attributes" do
|
27
|
+
tag = @form.uploadcare_field :file, :data => {:multiple => true}, :uploadcare => {:multiple => true}
|
28
|
+
tag.should have_selector("input", :type => "hidden", "data-multiple" => "false")
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Uploadcare::Rails::ActionView::FormBuilder, type: :helper do
|
4
|
+
before(:each) do
|
5
|
+
@post = PostWithCollection.new
|
6
|
+
@form = ActionView::Helpers::FormBuilder.new(:post, @post, helper, {}, nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should include uploader tag for name" do
|
10
|
+
# not that post has uc file
|
11
|
+
tag = @form.uploadcare_field :file
|
12
|
+
tag.should be_kind_of(String)
|
13
|
+
tag.should have_selector("input", :type => "hidden", "data-multiple" => "true")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should override uploadcare- attribute" do
|
17
|
+
tag = @form.uploadcare_field :file, :uploadcare => {:multiple => false}
|
18
|
+
tag.should have_selector("input", :type => "hidden", "data-multiple" => "true")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should override data- attribute" do
|
22
|
+
tag = @form.uploadcare_field :file, :data => {:multiple => false}
|
23
|
+
tag.should have_selector("input", :type => "hidden", "data-multiple" => "true")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should override data- and uploadcare- attributes" do
|
27
|
+
tag = @form.uploadcare_field :file, :data => {:multiple => false}, :uploadcare => {:multiple => false}
|
28
|
+
tag.should have_selector("input", :type => "hidden", "data-multiple" => "true")
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Uploadcare::Rails::ActionView::FormBuilder, type: :helper do
|
4
|
+
before(:each) do
|
5
|
+
@post = Post.new
|
6
|
+
@form = ActionView::Helpers::FormBuilder.new(:post, @post, helper, {}, nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should include uploader tag for name" do
|
10
|
+
tag = @form.uploadcare_field :file
|
11
|
+
tag.should be_kind_of(String)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have role attr" do
|
15
|
+
tag = @form.uploadcare_field :file, :uploadcare => {:multiple => true}
|
16
|
+
tag.should have_selector("input", :role => "uploadcare-uploader")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have custom data-attributes" do
|
20
|
+
tag = @form.uploadcare_field :file, :data => {:custom => true}
|
21
|
+
tag.should have_selector("input", "data-custom" => "true")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have uploadcare namespace translated into data- attributes" do
|
25
|
+
tag = @form.uploadcare_field :file, :uploadcare => {:custom => true}
|
26
|
+
tag.should have_selector("input", "data-custom" => "true")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should override data namespace with uploadcare namespace" do
|
30
|
+
tag = @form.uploadcare_field :file, :uploadcare => {:custom => true}, :data => {:custom => false}
|
31
|
+
tag.should have_selector(:input, "data-custom" => "true")
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Uploadcare::Rails do
|
4
|
+
it "should include widget from cdn" do
|
5
|
+
tag = helper.include_uploadcare_widget_from_cdn
|
6
|
+
tag.should be_kind_of(String)
|
7
|
+
tag.should == ("<script src=\"https://ucarecdn.com/widget/#{UPLOADCARE_SETTINGS.widget_version}/uploadcare/uploadcare-#{UPLOADCARE_SETTINGS.widget_version}.min.js\"></script>")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should specify widget version" do
|
11
|
+
version = "0.13.3"
|
12
|
+
|
13
|
+
tag = helper.include_uploadcare_widget_from_cdn({version: version})
|
14
|
+
tag.should == ("<script src=\"https://ucarecdn.com/widget/#{version}/uploadcare/uploadcare-#{version}.min.js\"></script>")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should load not minified version" do
|
18
|
+
version = "0.13.3"
|
19
|
+
min = false
|
20
|
+
|
21
|
+
tag = helper.include_uploadcare_widget_from_cdn({version: version, min: min})
|
22
|
+
tag.should == ("<script src=\"https://ucarecdn.com/widget/#{version}/uploadcare/uploadcare-#{version}.js\"></script>")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return js settings" do
|
26
|
+
settings = helper.uploadcare_settings
|
27
|
+
settings.should be_kind_of(String)
|
28
|
+
settings.should_not be_empty
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should include all uplaodcare settings" do
|
32
|
+
settings = helper.uploadcare_settings
|
33
|
+
settings.should have_selector("script", :content => "UPLOADCARE_PUBLIC_KEY")
|
34
|
+
settings.should have_selector("script", :content => "UPLOADCARE_LOCALE")
|
35
|
+
settings.should have_selector("script", :content => "UPLOADCARE_PREVIEW_STEP")
|
36
|
+
settings.should have_selector("script", :content => "UPLOADCARE_CLEARABLE")
|
37
|
+
settings.should have_selector("script", :content => "UPLOADCARE_TABS")
|
38
|
+
settings.should have_selector("script", :content => "UPLOADCARE_AUTOSTORE")
|
39
|
+
settings.should have_selector("script", :content => "UPLOADCARE_MANUAL_START")
|
40
|
+
settings.should have_selector("script", :content => "UPLOADCARE_PATH_VALUE")
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Uploadcare::Rails::ActionView::UploaderTags do
|
4
|
+
it "should include uploader tag for name" do
|
5
|
+
tag = helper.uploadcare_uploader_tag :file
|
6
|
+
tag.should be_kind_of(String)
|
7
|
+
tag.should have_selector("input", :type =>"hidden", :role =>"uploadcare-uploader", "data-path-value" => "true")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should include uploader field for object" do
|
11
|
+
tag = helper.uploadcare_uploader_field :post, :file
|
12
|
+
tag.should be_kind_of(String)
|
13
|
+
tag.should have_selector("input", :type =>"hidden", :role =>"uploadcare-uploader", "data-path-value" => "true")
|
14
|
+
end
|
15
|
+
end
|
data/spec/models/file.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Uploadcare::Rails::File do
|
4
|
+
before(:each) do
|
5
|
+
@post = Post.new title: "Post title", file: " http://www.ucarecdn.com/19cde26d-e41b-4cf5-923e-f58729c0522a/"
|
6
|
+
@file = @post.file
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be Uploadcare::Rails::File" do
|
10
|
+
@file.should be_kind_of(Uploadcare::Rails::File)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be not loaded by default" do
|
14
|
+
@file.loaded?.should == false
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should load itself" do
|
18
|
+
@file.load
|
19
|
+
@file.loaded?.should == true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "file should respond to :cdn_url and :to_s methods" do
|
23
|
+
@file.to_s.should == @file.cdn_url
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Uploadcare::Rails::Group do
|
4
|
+
before(:each) do
|
5
|
+
@post = PostWithCollection.new title: "Post title", file: "8e1f6ccb-0c4a-471e-934e-ac6ba030d33c~2"
|
6
|
+
@group = @post.file
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be Uploadcare::Rails::File" do
|
10
|
+
@group.should be_kind_of(Uploadcare::Rails::Group)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be not loaded by default" do
|
14
|
+
@group.loaded?.should == false
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should load itself" do
|
18
|
+
@group.load
|
19
|
+
@group.loaded?.should == true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "file should respond to :uuid and :to_s methods" do
|
23
|
+
@group.to_s.should == @group.uuid
|
24
|
+
end
|
25
|
+
|
26
|
+
it "group should have files" do
|
27
|
+
@group.load
|
28
|
+
@group.files.should be_kind_of(Array)
|
29
|
+
@group.files.sample.should be_kind_of(Uploadcare::Rails::File)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "loaded group files should be loaded too" do
|
33
|
+
@group.load
|
34
|
+
@group.files.sample.loaded?.should == true
|
35
|
+
end
|
36
|
+
end
|