rails_validations 1.1.2 → 1.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc1dd77a7c0210226a3a1d51326400739d74839b
4
- data.tar.gz: a6d84e924ef157d550e5a1d560eebb69d6801902
3
+ metadata.gz: ddd6882125ca697433e2c84a1abe00d27915a047
4
+ data.tar.gz: c5989625d5445cc3c945dacca0508af06326bc34
5
5
  SHA512:
6
- metadata.gz: 354295b2cd7f84d48ac1cc619da220cf79ae65205f876118da20bb626fa69f8304d3808836ebc6dcbeb012c165417cceedddf3282bbe8234a7a373d6eaa38d02
7
- data.tar.gz: 05fd3b1468787d6252cc663b0fafe84ed6986142133cb523f755bc9d8aabba9661651e3efaacff55eff9cb0b7c5bdc055da629b811e34ba36162e42a03928cf6
6
+ metadata.gz: ec30b335a30fe9d5edcb557305aba2801d7311482ae6524beed630a6c4b0a26ee445211cf911b217663d316807c73fe537468a27b7dc54e14433106e1d763ffd
7
+ data.tar.gz: 28d39fdf01a7018dd1497b02188016bb350fb85655c1c773695b6d673f016f5f7098b749970a5c81e2b37ccd49ddf9685f31c82a5da0ff8c901f47dbe12fe6fa
@@ -97,26 +97,32 @@ Currently implemented countries:
97
97
  ChangeLog
98
98
  =========
99
99
 
100
- version 1.1.2, 20141201
101
- -----------------------
100
+ Version 1.1.3, 2014-12-03
101
+ -------------------------
102
+ - Make sure that the date validator doesn’t throw an exception if
103
+ `'invalid'.to_date` fails.
104
+
105
+
106
+ Version 1.1.2, 2014-12-01
107
+ -------------------------
102
108
  - Fix typo in Dutch translation.
103
109
  - Update some docs.
104
110
 
105
111
 
106
- version 1.1.1, 20141013
107
- -----------------------
112
+ Version 1.1.1, 2014-10-13
113
+ -------------------------
108
114
  - Fix i18n key for `phone`.
109
115
  - Allow passing a Proc to `date` without an argument.
110
116
 
111
117
 
112
- version 1.1, 20141003
113
- ---------------------
118
+ Version 1.1, 2014-10-03
119
+ -----------------------
114
120
  - Make the date validation work if the column it points to is `nil`.
115
121
  - Add documentation.
116
122
 
117
123
 
118
- version 1.0, 20140905
119
- ---------------------
124
+ Version 1.0, 2014-09-05
125
+ -----------------------
120
126
  - Initial release.
121
127
 
122
128
 
@@ -33,7 +33,11 @@ class DateValidator < ActiveModel::EachValidator
33
33
  value = if raw_value.is_a? Fixnum
34
34
  time.at(raw_value).to_date
35
35
  elsif raw_value.respond_to? :to_date
36
- raw_value.to_date
36
+ begin
37
+ raw_value.to_date
38
+ rescue ArgumentError
39
+ false
40
+ end
37
41
  else
38
42
  false
39
43
  end
@@ -9,6 +9,7 @@ require 'action_view'
9
9
  require 'active_model'
10
10
  require 'active_record'
11
11
  require 'active_support'
12
+ require 'active_support/all'
12
13
 
13
14
  #require 'rspec/rails'
14
15
 
@@ -1,5 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'active_support/core_ext/date/calculations'
3
2
 
4
3
  module ValidationsSpecHelper
5
4
  class Date < ValidationsSpecHelper::Record
@@ -62,4 +61,11 @@ describe ValidationsSpecHelper::Date do
62
61
  expect(model(Date.today.advance days: -1).valid?).to eq(true)
63
62
  end
64
63
  end
64
+
65
+
66
+ it "works with input that is not even remotely a date" do
67
+ with_validation 'date: true' do
68
+ expect(model('Yesterday, a fish nibbled my toe.')).to_not be_valid
69
+ end
70
+ end
65
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Tournoij
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-01 00:00:00.000000000 Z
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack