rails-uploader 0.5.7 → 0.5.8
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 +6 -4
- data/lib/uploader/helpers/field_tag.rb +7 -1
- data/lib/uploader/version.rb +1 -1
- data/spec/fileuploads_spec.rb +15 -13
- data/spec/mongoid_spec.rb +3 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/uploader_spec.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd3d3610d3f91d0664616a93f69f14e5d1493f7b7671722104b9b12ca75d9441
|
|
4
|
+
data.tar.gz: d84492649655991cd0f03e823fb910ce21cf4623bb8c6571b62195fbc0b6c028
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0756498c5abb96d3b48f1fdb0f06c0e6b096d2b582953eaca8a7c5d7eb8acce0ac350716552f8b3067b4b963c192ee36455d87f7b7f5d0481ba8f877e593476f'
|
|
7
|
+
data.tar.gz: 387826cfcbae71415a4d139c77759ce79cf438867bd9870bc74168eaab31bc72445465b31c542f2051c14d8d5868f3fa36da995278faccd1dd43e33837e07968
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://app.travis-ci.com/superp/rails-uploader)
|
|
2
2
|
|
|
3
3
|
# HTML5 File uploader for rails
|
|
4
4
|
|
|
@@ -21,7 +21,7 @@ mount Uploader::Engine => '/uploader'
|
|
|
21
21
|
Migration for ActiveRecord:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
bundle exec rails g uploader:install
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
@@ -286,6 +286,8 @@ That's it!
|
|
|
286
286
|
|
|
287
287
|
## Testing
|
|
288
288
|
|
|
289
|
-
|
|
289
|
+
```
|
|
290
|
+
rspec ./spec/
|
|
291
|
+
```
|
|
290
292
|
|
|
291
|
-
Copyright (c)
|
|
293
|
+
Copyright (c) 2022 Fodojo LLC, released under the MIT license
|
|
@@ -76,7 +76,7 @@ module Uploader
|
|
|
76
76
|
@input_html ||= { multiple: multiple?, class: 'uploader' }.merge(input_html_options)
|
|
77
77
|
@input_html[:data] ||= {}
|
|
78
78
|
@input_html[:data][:url] ||= attachments_path(singular: !multiple?)
|
|
79
|
-
@input_html[:accept] ||=
|
|
79
|
+
@input_html[:accept] ||= extension_whitelist
|
|
80
80
|
@input_html
|
|
81
81
|
end
|
|
82
82
|
|
|
@@ -84,6 +84,12 @@ module Uploader
|
|
|
84
84
|
@options.reject { |key, _value| RESERVED_OPTIONS_KEYS.include?(key.to_s) }
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
def extension_whitelist
|
|
88
|
+
@extension_whitelist ||= extract_extension_whitelist
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
87
93
|
def extract_extension_whitelist
|
|
88
94
|
return unless klass.respond_to?(:uploaders)
|
|
89
95
|
return unless klass.uploaders[:data].try(:const_defined?, :EXTENSION_WHITELIST)
|
data/lib/uploader/version.rb
CHANGED
data/spec/fileuploads_spec.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Uploader::Fileuploads do
|
|
@@ -5,41 +7,41 @@ describe Uploader::Fileuploads do
|
|
|
5
7
|
@picture = FactoryGirl.create(:picture, assetable_type: 'Article')
|
|
6
8
|
end
|
|
7
9
|
|
|
8
|
-
it
|
|
10
|
+
it 'should be a Module' do
|
|
9
11
|
Uploader::Fileuploads.should be_a(Module)
|
|
10
12
|
end
|
|
11
13
|
|
|
12
|
-
context
|
|
14
|
+
context 'instance methods' do
|
|
13
15
|
before(:each) do
|
|
14
16
|
@article = FactoryGirl.build(:article)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
|
-
it
|
|
18
|
-
@article.fileupload_klass(
|
|
19
|
+
it 'should return asset class' do
|
|
20
|
+
@article.fileupload_klass('picture').should == Picture
|
|
19
21
|
end
|
|
20
22
|
|
|
21
|
-
it
|
|
23
|
+
it 'should find asset by guid' do
|
|
22
24
|
@picture.update_column(:guid, @article.fileupload_guid)
|
|
23
25
|
|
|
24
26
|
asset = @article.fileupload_asset('picture')
|
|
25
27
|
asset.should == @picture
|
|
26
28
|
end
|
|
27
29
|
|
|
28
|
-
it
|
|
30
|
+
it 'should generate guid' do
|
|
29
31
|
@article.fileupload_guid.should_not be_blank
|
|
30
32
|
end
|
|
31
33
|
|
|
32
|
-
it
|
|
33
|
-
@article.fileupload_guid =
|
|
34
|
-
@article.fileupload_changed?.should
|
|
35
|
-
@article.fileupload_guid.should ==
|
|
34
|
+
it 'should change guid' do
|
|
35
|
+
@article.fileupload_guid = 'other guid'
|
|
36
|
+
@article.fileupload_changed?.should be_truthy
|
|
37
|
+
@article.fileupload_guid.should == 'other guid'
|
|
36
38
|
end
|
|
37
39
|
|
|
38
|
-
it
|
|
39
|
-
@article.fileupload_multiple?(
|
|
40
|
+
it 'should not multiplay upload' do
|
|
41
|
+
@article.fileupload_multiple?('picture').should be_falsey
|
|
40
42
|
end
|
|
41
43
|
|
|
42
|
-
it
|
|
44
|
+
it 'should find uploaded asset or build new record' do
|
|
43
45
|
picture = @article.fileupload_asset(:picture)
|
|
44
46
|
picture.should_not be_nil
|
|
45
47
|
picture.should be_new_record
|
data/spec/mongoid_spec.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
require 'mongoid'
|
|
3
5
|
|
|
@@ -33,7 +35,7 @@ describe Uploader::Asset do
|
|
|
33
35
|
asset.should == @picture
|
|
34
36
|
end
|
|
35
37
|
|
|
36
|
-
it
|
|
38
|
+
it 'should update asset target_id by guid' do
|
|
37
39
|
@article.save
|
|
38
40
|
|
|
39
41
|
@picture.reload
|
data/spec/spec_helper.rb
CHANGED
data/spec/uploader_spec.rb
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Uploader do
|
|
4
|
-
it
|
|
6
|
+
it 'should be a Module' do
|
|
5
7
|
Uploader.should be_a(Module)
|
|
6
8
|
end
|
|
7
9
|
|
|
8
|
-
it
|
|
10
|
+
it 'should generate random string' do
|
|
9
11
|
value = Uploader.guid
|
|
10
12
|
value.should_not be_blank
|
|
11
13
|
value.size.should == 22
|
|
12
14
|
end
|
|
13
15
|
|
|
14
|
-
it
|
|
16
|
+
it 'should find all precompile assets' do
|
|
15
17
|
Uploader.assets.should_not be_nil
|
|
16
18
|
Uploader.assets.should include('uploader/jquery.fileupload.js')
|
|
17
19
|
end
|
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.5.
|
|
4
|
+
version: 0.5.8
|
|
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: 2022-
|
|
12
|
+
date: 2022-08-29 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: carrierwave
|