file_validators 2.2.0.beta1 → 2.3.0

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
  SHA1:
3
- metadata.gz: 75fbf34dcce7be5b3770f09d4068c00f50f2cd9d
4
- data.tar.gz: e81f181e641308492a13b1ef3ed5034724d2a7f6
3
+ metadata.gz: 0353fd8c53123663ec484c7172c2df4d572f95dd
4
+ data.tar.gz: b1eb811cfea7257288ff5e588621f78aeff39896
5
5
  SHA512:
6
- metadata.gz: abb281ff04de1964a07f19d2ee5fa5ccc51f63827b0ae7bb2628c3ddc36379d16ad48e9aa037d5e16ed18a6ab5d0690b0cc866a263c48ce9a754006c53204d9f
7
- data.tar.gz: 01417d071f54021f5c8ad73b6a9eb5d35c7b49b29c450037dd2b3b40cbaa13fb9250bf9cfc66931385caab5e2bd934b51987329a736a87645ce6cfa7063bee6c
6
+ metadata.gz: 002f91a5243bf85650572ecb80a5283a25aafd6cdda3d4e9fe19bba988f597f3db228e583dc113bb54fb1c7973bc0caa9fc409592f10ff1c75c075438959fcf7
7
+ data.tar.gz: a1860e71ee7054624f2cf368802e1af2ee302886ecfca99c0ff43b948c6cf3af3d9264e62b1c877220fb465c18a5df6e11b507d42dbe03c29612e0e2f8513dd7
@@ -5,6 +5,7 @@ rvm:
5
5
  - 2.2.3
6
6
  - ruby-head
7
7
  - jruby-9.0.4.0
8
+ - jruby-9.1.7.0
8
9
 
9
10
  gemfile:
10
11
  - gemfiles/activemodel_5.0.gemfile
@@ -14,5 +15,11 @@ gemfile:
14
15
  - gemfiles/activemodel_3.2.gemfile
15
16
 
16
17
  matrix:
18
+ exclude:
19
+ - rvm: 2.0
20
+ gemfile: gemfiles/activemodel_5.0.gemfile
21
+ - rvm: jruby-9.0.4.0
22
+ gemfile: gemfiles/activemodel_5.0.gemfile
23
+
17
24
  allow_failures:
18
- - rvm: ruby-head
25
+ - rvm: ruby-head
data/Appraisals CHANGED
@@ -1,17 +1,21 @@
1
1
  appraise 'activemodel-3.2' do
2
2
  gem 'activemodel', '3.2.22.5'
3
+ gem 'rack', '1.6.5'
3
4
  end
4
5
 
5
6
  appraise 'activemodel-4.0' do
6
7
  gem 'activemodel', '4.0.13'
8
+ gem 'rack', '1.6.5'
7
9
  end
8
10
 
9
11
  appraise 'activemodel-4.1' do
10
12
  gem 'activemodel', '4.1.6'
13
+ gem 'rack', '1.6.5'
11
14
  end
12
15
 
13
16
  appraise 'activemodel-4.2' do
14
17
  gem 'activemodel', '4.2.7.1'
18
+ gem 'rack', '1.6.5'
15
19
  end
16
20
 
17
21
  appraise 'activemodel-5.0' do
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_development_dependency 'cocaine', '~> 0.5.4'
24
24
  s.add_development_dependency 'rake'
25
- s.add_development_dependency 'rspec', '~> 3.1.0'
25
+ s.add_development_dependency 'rspec', '~> 3.5.0'
26
26
  s.add_development_dependency 'coveralls'
27
27
  s.add_development_dependency 'rack-test'
28
28
  end
@@ -4,5 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
6
  gem "activemodel", "3.2.22.5"
7
+ gem "rack", "1.6.5"
7
8
 
8
9
  gemspec :path => "../"
@@ -4,5 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
6
  gem "activemodel", "4.0.13"
7
+ gem "rack", "1.6.5"
7
8
 
8
9
  gemspec :path => "../"
@@ -4,5 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
6
  gem "activemodel", "4.1.6"
7
+ gem "rack", "1.6.5"
7
8
 
8
9
  gemspec :path => "../"
@@ -4,5 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
6
  gem "activemodel", "4.2.7.1"
7
+ gem "rack", "1.6.5"
7
8
 
8
9
  gemspec :path => "../"
@@ -17,7 +17,7 @@ module ActiveModel
17
17
  unless values.empty?
18
18
  options.slice(*CHECKS.keys).each do |option, option_value|
19
19
  option_value = option_value.call(record) if option_value.is_a?(Proc)
20
- if values.any? { |v| not valid_size?(v.size, option, option_value) }
20
+ if values.any? { |v| not valid_size?(value_byte_size(v), option, option_value) }
21
21
  record.errors.add(attribute,
22
22
  "file_size_is_#{option}".to_sym,
23
23
  filtered_options(values).merge!(detect_error_options(option_value)))
@@ -57,7 +57,16 @@ module ActiveModel
57
57
  end
58
58
  end
59
59
 
60
+ def value_byte_size(value)
61
+ if value.respond_to?(:byte_size)
62
+ value.byte_size
63
+ else
64
+ value.size
65
+ end
66
+ end
67
+
60
68
  def valid_size?(size, option, option_value)
69
+ return false if size.nil?
61
70
  if option_value.is_a?(Range)
62
71
  option_value.send(CHECKS[option], size)
63
72
  else
@@ -1,3 +1,3 @@
1
1
  module FileValidators
2
- VERSION = '2.2.0.beta1'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -168,6 +168,12 @@ describe ActiveModel::Validations::FileSizeValidator do
168
168
  end
169
169
  end
170
170
 
171
+ context 'exceptional file size' do
172
+ before { build_validator less_than: 3.kilobytes }
173
+
174
+ it { is_expected.to allow_file_size(0, @validator) } # zero-byte file
175
+ it { is_expected.not_to allow_file_size(nil, @validator) }
176
+ end
171
177
 
172
178
  context 'using the helper' do
173
179
  before { Dummy.validates_file_size :avatar, in: (5.kilobytes..10.kilobytes) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.beta1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmad Musaffa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-08 00:00:00.000000000 Z
11
+ date: 2018-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 3.1.0
75
+ version: 3.5.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 3.1.0
82
+ version: 3.5.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: coveralls
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -169,9 +169,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  requirements:
172
- - - ">"
172
+ - - ">="
173
173
  - !ruby/object:Gem::Version
174
- version: 1.3.1
174
+ version: '0'
175
175
  requirements: []
176
176
  rubyforge_project:
177
177
  rubygems_version: 2.5.1