file_validators 2.0.1 → 2.0.2
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/lib/file_validators/validators/file_content_type_validator.rb +1 -1
- data/lib/file_validators/validators/file_size_validator.rb +1 -1
- data/lib/file_validators/version.rb +1 -1
- data/spec/integration/file_content_type_validation_integration_spec.rb +5 -0
- data/spec/integration/file_size_validator_integration_spec.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff6c87fab7ee11b1ce0fb5770332f0f1b22c5b96
|
4
|
+
data.tar.gz: c5b54b8b7b01b685b0f9ee3097c3f8cecbe8ddc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87bf7a8b288777610e8365b486ba806715ee155cc2c5b808aadea4b4f95e1bb18398d394b10af215ffde63fe0babbbc9ea70d265005a727cb31d7b01966ad69a
|
7
|
+
data.tar.gz: d05f373a6c43907891cbdc0358e3f0389027b2b10b41d788a83db65cb6edca23b3bdf3910bd82c8ebb45b350c368b94884033a0f98f5d65093bf00ff7b0d034d
|
@@ -12,7 +12,7 @@ module ActiveModel
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def validate_each(record, attribute, value)
|
15
|
-
value = JSON.parse(value) if value.is_a?(String)
|
15
|
+
value = JSON.parse(value) if value.is_a?(String) && value.present?
|
16
16
|
unless value.blank?
|
17
17
|
mode = option_value(record, :mode)
|
18
18
|
content_type = get_content_type(value, mode)
|
@@ -13,7 +13,7 @@ module ActiveModel
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def validate_each(record, attribute, value)
|
16
|
-
value = JSON.parse(value) if value.is_a?(String)
|
16
|
+
value = JSON.parse(value) if value.is_a?(String) && value.present?
|
17
17
|
unless value.blank?
|
18
18
|
options.slice(*CHECKS.keys).each do |option, option_value|
|
19
19
|
value = OpenStruct.new(value) if value.is_a?(Hash)
|
@@ -347,6 +347,11 @@ describe 'File Content Type integration with ActiveModel' do
|
|
347
347
|
before { subject.avatar = "{}" }
|
348
348
|
it { is_expected.to be_valid }
|
349
349
|
end
|
350
|
+
|
351
|
+
context 'empty string' do
|
352
|
+
before { subject.avatar = "" }
|
353
|
+
it { is_expected.to be_valid }
|
354
|
+
end
|
350
355
|
end
|
351
356
|
|
352
357
|
context 'image data as hash' do
|
@@ -231,6 +231,11 @@ describe 'File Size Validator integration with ActiveModel' do
|
|
231
231
|
before { subject.avatar = "{}" }
|
232
232
|
it { is_expected.to be_valid }
|
233
233
|
end
|
234
|
+
|
235
|
+
context 'empty json string' do
|
236
|
+
before { subject.avatar = "" }
|
237
|
+
it { is_expected.to be_valid }
|
238
|
+
end
|
234
239
|
end
|
235
240
|
|
236
241
|
context 'image data as hash' do
|
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.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmad Musaffa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08
|
11
|
+
date: 2015-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.4.5
|
177
|
+
rubygems_version: 2.4.5.1
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: ActiveModel file validators
|