rails-uploader 0.5.5 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 288f1b049430d69fe720b17b8db0888f196987f632c366150cb25b9ebada7081
4
- data.tar.gz: 9dba7c65c0dab4ccebde808be6e867470c8c879133cf65461373c8f235311521
3
+ metadata.gz: bd3d3610d3f91d0664616a93f69f14e5d1493f7b7671722104b9b12ca75d9441
4
+ data.tar.gz: d84492649655991cd0f03e823fb910ce21cf4623bb8c6571b62195fbc0b6c028
5
5
  SHA512:
6
- metadata.gz: 25ae58b3c31a0c2d9144b0c201bc5357ed42abef4e5cf3dad8323c1a11cbff3ba519f467efc7bf79754a4d978f39264d350e897458956be373e9db454238236b
7
- data.tar.gz: 67e803051409302b8c64b81ed8a020dbd75373d19ab7432292a9b38d0e808b8f35d1a2e210a1c20225d8f32d206bf7dcdb7a8d5a2b5629d12cf3ac0f3c96af29
6
+ metadata.gz: '0756498c5abb96d3b48f1fdb0f06c0e6b096d2b582953eaca8a7c5d7eb8acce0ac350716552f8b3067b4b963c192ee36455d87f7b7f5d0481ba8f877e593476f'
7
+ data.tar.gz: 387826cfcbae71415a4d139c77759ce79cf438867bd9870bc74168eaab31bc72445465b31c542f2051c14d8d5868f3fa36da995278faccd1dd43e33837e07968
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/superp/rails-uploader.svg?branch=master)](https://travis-ci.org/superp/rails-uploader)
1
+ [![Build Status](https://app.travis-ci.com/superp/rails-uploader.svg?branch=master)](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
- $ bundle exec rails g uploader:install
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
- rspec ./spec/
289
+ ```
290
+ rspec ./spec/
291
+ ```
290
292
 
291
- Copyright (c) 2016 Fodojo LLC, released under the MIT license
293
+ Copyright (c) 2022 Fodojo LLC, released under the MIT license
@@ -51,7 +51,7 @@ module Uploader
51
51
  #
52
52
  def fileupload_create(params, _request = nil)
53
53
  self[Uploader.guid_column] = params[:guid]
54
- return false unless update_attributes(self.class.fileupload_assetable_options(params))
54
+ return false unless update(self.class.fileupload_assetable_options(params))
55
55
 
56
56
  if fileupload_destroy_other_on_singular?(params)
57
57
  self.class.fileupload_find_assets(params).where.not(id: id).destroy_all
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/concern'
4
- require_relative 'json_rendering'
5
4
 
6
5
  module Uploader
7
6
  module Authorization
8
7
  extend ActiveSupport::Concern
9
8
 
10
9
  included do
11
- include JsonRendering
10
+ include Uploader::JsonRendering
12
11
  include ActionController::Rescue
13
12
 
14
13
  rescue_from Uploader::AccessDenied, with: :dispatch_uploader_access_denied
@@ -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] ||= extract_extension_whitelist
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uploader
4
- VERSION = '0.5.5'
4
+ VERSION = '0.5.8'
5
5
  end
data/lib/uploader.rb CHANGED
@@ -13,6 +13,7 @@ module Uploader
13
13
  autoload :UploadRequest, 'uploader/upload_request'
14
14
  autoload :FilePart, 'uploader/file_part'
15
15
  autoload :FileuploadGlue, 'uploader/fileupload_glue'
16
+ autoload :JsonRendering, 'uploader/json_rendering'
16
17
 
17
18
  # Just Rails helpers
18
19
  module Helpers
@@ -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 "should be a Module" do
10
+ it 'should be a Module' do
9
11
  Uploader::Fileuploads.should be_a(Module)
10
12
  end
11
13
 
12
- context "instance methods" do
14
+ context 'instance methods' do
13
15
  before(:each) do
14
16
  @article = FactoryGirl.build(:article)
15
17
  end
16
18
 
17
- it "should return asset class" do
18
- @article.fileupload_klass("picture").should == Picture
19
+ it 'should return asset class' do
20
+ @article.fileupload_klass('picture').should == Picture
19
21
  end
20
22
 
21
- it "should find asset by guid" do
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 "should generate guid" do
30
+ it 'should generate guid' do
29
31
  @article.fileupload_guid.should_not be_blank
30
32
  end
31
33
 
32
- it "should change guid" do
33
- @article.fileupload_guid = "other guid"
34
- @article.fileupload_changed?.should be_true
35
- @article.fileupload_guid.should == "other guid"
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 "should not multiplay upload" do
39
- @article.fileupload_multiple?("picture").should be_false
40
+ it 'should not multiplay upload' do
41
+ @article.fileupload_multiple?('picture').should be_falsey
40
42
  end
41
43
 
42
- it "should find uploaded asset or build new record" do
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 "should update asset target_id by guid" do
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Configure Rails Envinronment
2
4
  ENV['RAILS_ENV'] = 'test'
3
5
 
@@ -1,17 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Uploader do
4
- it "should be a Module" do
6
+ it 'should be a Module' do
5
7
  Uploader.should be_a(Module)
6
8
  end
7
9
 
8
- it "should generate random string" do
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 "should find all precompile assets" do
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.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-01-21 00:00:00.000000000 Z
12
+ date: 2022-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: carrierwave