rails-uploader 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/uploader.rb +5 -0
- data/lib/uploader/asset.rb +11 -12
- data/lib/uploader/engine.rb +0 -1
- data/lib/uploader/fileupload_glue.rb +107 -0
- data/lib/uploader/fileuploads.rb +6 -49
- data/lib/uploader/helpers/field_tag.rb +2 -9
- data/lib/uploader/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +825 -0
- data/spec/dummy/public/uploads/picture/data/1/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/picture/data/3/thumb_rails.png +0 -0
- data/spec/factories/assets.rb +6 -6
- data/spec/fileuploads_spec.rb +14 -19
- data/spec/mongoid_spec.rb +11 -7
- data/spec/uploader_spec.rb +3 -3
- metadata +3 -3
Binary file
|
Binary file
|
data/spec/factories/assets.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
2
|
|
3
|
-
FactoryGirl.define do
|
4
|
-
factory :picture, :
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :picture, class: Picture do
|
5
5
|
data File.open('spec/factories/files/rails.png')
|
6
|
-
data_content_type
|
7
|
-
data_file_name
|
8
|
-
|
9
|
-
association :assetable, :
|
6
|
+
data_content_type 'image/png'
|
7
|
+
data_file_name 'rails.png'
|
8
|
+
|
9
|
+
association :assetable, factory: :article
|
10
10
|
end
|
11
11
|
end
|
data/spec/fileuploads_spec.rb
CHANGED
@@ -2,34 +2,29 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Uploader::Fileuploads do
|
4
4
|
before(:all) do
|
5
|
-
@picture = FactoryGirl.create(:picture)
|
5
|
+
@picture = FactoryGirl.create(:picture, assetable_type: 'Article')
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should be a Module" do
|
9
9
|
Uploader::Fileuploads.should be_a(Module)
|
10
10
|
end
|
11
11
|
|
12
|
-
it "should return asset class" do
|
13
|
-
Article.fileupload_klass("picture").should == Picture
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should find asset by guid" do
|
17
|
-
asset = Article.fileupload_find("picture", @picture.guid)
|
18
|
-
asset.should == @picture
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should update asset target_id by guid" do
|
22
|
-
Article.fileupload_update(1000, @picture.guid, :picture)
|
23
|
-
@picture.reload
|
24
|
-
@picture.assetable_id.should == 1000
|
25
|
-
@picture.guid.should be_nil
|
26
|
-
end
|
27
|
-
|
28
12
|
context "instance methods" do
|
29
13
|
before(:each) do
|
30
14
|
@article = FactoryGirl.build(:article)
|
31
15
|
end
|
32
16
|
|
17
|
+
it "should return asset class" do
|
18
|
+
@article.fileupload_klass("picture").should == Picture
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should find asset by guid" do
|
22
|
+
@picture.update_column(:guid, @article.fileupload_guid)
|
23
|
+
|
24
|
+
asset = @article.fileupload_asset('picture')
|
25
|
+
asset.should == @picture
|
26
|
+
end
|
27
|
+
|
33
28
|
it "should generate guid" do
|
34
29
|
@article.fileupload_guid.should_not be_blank
|
35
30
|
end
|
@@ -50,8 +45,8 @@ describe Uploader::Fileuploads do
|
|
50
45
|
picture.should be_new_record
|
51
46
|
end
|
52
47
|
|
53
|
-
it
|
54
|
-
@article.
|
48
|
+
it 'must get fileupload params' do
|
49
|
+
@article.fileupload_params(:picture).should_not be nil
|
55
50
|
end
|
56
51
|
end
|
57
52
|
end
|
data/spec/mongoid_spec.rb
CHANGED
@@ -7,33 +7,37 @@ class MongoidArticle
|
|
7
7
|
include Mongoid::Document
|
8
8
|
include Uploader::Fileuploads
|
9
9
|
|
10
|
-
has_one :mongoid_picture, :
|
10
|
+
has_one :mongoid_picture, as: :assetable
|
11
11
|
|
12
12
|
fileuploads :mongoid_picture
|
13
13
|
end
|
14
14
|
|
15
15
|
class MongoidPicture
|
16
16
|
include Mongoid::Document
|
17
|
-
include Uploader::Asset
|
17
|
+
include Uploader::Asset
|
18
|
+
|
19
|
+
field :guid, type: String
|
18
20
|
|
19
21
|
belongs_to :assetable, polymorphic: true
|
20
22
|
end
|
21
23
|
|
22
|
-
describe Uploader::Asset
|
24
|
+
describe Uploader::Asset do
|
23
25
|
before do
|
24
26
|
@guid = 'guid'
|
25
|
-
@
|
27
|
+
@article = MongoidArticle.new(fileupload_guid: @guid)
|
28
|
+
@picture = MongoidPicture.create!(guid: @guid, assetable_type: 'MongoidArticle')
|
26
29
|
end
|
27
30
|
|
28
31
|
it 'should find asset by guid' do
|
29
|
-
asset =
|
32
|
+
asset = @article.fileupload_asset(:mongoid_picture)
|
30
33
|
asset.should == @picture
|
31
34
|
end
|
32
35
|
|
33
36
|
it "should update asset target_id by guid" do
|
34
|
-
|
37
|
+
@article.save
|
38
|
+
|
35
39
|
@picture.reload
|
36
|
-
@picture.assetable_id.should ==
|
40
|
+
@picture.assetable_id.should == @article.id
|
37
41
|
@picture.guid.should be_nil
|
38
42
|
end
|
39
43
|
|
data/spec/uploader_spec.rb
CHANGED
@@ -4,13 +4,13 @@ describe Uploader do
|
|
4
4
|
it "should be a Module" do
|
5
5
|
Uploader.should be_a(Module)
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should generate random string" do
|
9
9
|
value = Uploader.guid
|
10
10
|
value.should_not be_blank
|
11
|
-
value.size.should ==
|
11
|
+
value.size.should == 22
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "should find all precompile assets" do
|
15
15
|
Uploader.assets.should_not be_nil
|
16
16
|
Uploader.assets.should include('uploader/jquery.fileupload.js')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Galeta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jquery-ui-rails
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/uploader/chunked_uploads.rb
|
98
98
|
- lib/uploader/engine.rb
|
99
99
|
- lib/uploader/file_part.rb
|
100
|
+
- lib/uploader/fileupload_glue.rb
|
100
101
|
- lib/uploader/fileuploads.rb
|
101
102
|
- lib/uploader/helpers/field_tag.rb
|
102
103
|
- lib/uploader/helpers/form_builder.rb
|
@@ -277,4 +278,3 @@ test_files:
|
|
277
278
|
- spec/requests/attachments_controller_spec.rb
|
278
279
|
- spec/spec_helper.rb
|
279
280
|
- spec/uploader_spec.rb
|
280
|
-
has_rdoc:
|