file_validators 2.0.1 → 2.0.2

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: 862ed2a30f76ed277f22f80773319c3627f991dd
4
- data.tar.gz: c434e6754743f0f6cd819992a0d4475bc5fc8176
3
+ metadata.gz: ff6c87fab7ee11b1ce0fb5770332f0f1b22c5b96
4
+ data.tar.gz: c5b54b8b7b01b685b0f9ee3097c3f8cecbe8ddc0
5
5
  SHA512:
6
- metadata.gz: 33426eed1c228b06716a841826221a4f6cb87ed508cc1c58c745ff432c5a18915d8230e5d227146d6a4642488baf3f9e5d4c326b947de7bbb5e6cf8b5d221efc
7
- data.tar.gz: b0b2f36ce62fc8dd9f93fff6ac65a5a6440499893c3ac09e8a8f053914f89d9180e6a9999c570d49382265688f15ffe7bce10d92809bd012e78573119760afa5
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)
@@ -1,3 +1,3 @@
1
1
  module FileValidators
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
@@ -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.1
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-03 00:00:00.000000000 Z
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