gov_uk_date_fields 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gov_uk_date_fields/acts_as_gov_uk_date.rb +12 -3
- data/lib/gov_uk_date_fields/version.rb +1 -1
- data/test/dummy/app/models/default_error_clash_employee.rb +8 -0
- data/test/dummy/app/models/employee.rb +1 -0
- data/test/dummy/app/models/omit_error_clash_employee.rb +8 -0
- data/test/dummy/app/models/override_error_clash_employee.rb +23 -0
- data/test/dummy/log/test.log +5137 -0
- data/test/dummy/test/models/default_error_clash_employee_test.rb +33 -0
- data/test/dummy/test/models/omit_error_clash_employee_test.rb +34 -0
- data/test/dummy/test/models/overrride_error_clash_employee_test.rb +33 -0
- metadata +14 -2
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
3
|
+
require File.dirname(__FILE__) + '/../../../../lib/gov_uk_date_fields/gov_uk_date_fields'
|
4
|
+
|
5
|
+
|
6
|
+
class DefaultErrorClashEmployeeTest < ActiveSupport::TestCase
|
7
|
+
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@employee = DefaultErrorClashEmployee.new(name: 'John', dob: nil, joined: nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_presence_error_messages_generated
|
14
|
+
@employee.valid?
|
15
|
+
assert_equal ["can't be blank"], @employee.errors[:dob]
|
16
|
+
assert_equal ["can't be blank"], @employee.errors[:joined]
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_invalid_day_adds_invalid_date_message_to_cant_be_blank_message
|
20
|
+
@employee.dob_dd = '32'
|
21
|
+
assert_false @employee.valid?
|
22
|
+
assert_equal ['Invalid date', "can't be blank"], @employee.errors[:dob]
|
23
|
+
assert_equal ["can't be blank"], @employee.errors[:joined]
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_valid_dates_generate_no_errors_at_all
|
27
|
+
@employee.dob_dd = '15'
|
28
|
+
@employee.dob_mm = '8'
|
29
|
+
@employee.dob_yyyy = '2016'
|
30
|
+
assert_empty @employee.errors[:dob]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
3
|
+
require File.dirname(__FILE__) + '/../../../../lib/gov_uk_date_fields/gov_uk_date_fields'
|
4
|
+
|
5
|
+
|
6
|
+
class OmitErrorClashEmployeeTest < ActiveSupport::TestCase
|
7
|
+
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@employee = OmitErrorClashEmployee.new(name: 'John', dob: nil, joined: nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_presence_error_messages_generated
|
14
|
+
@employee.valid?
|
15
|
+
assert_equal ["can't be blank"], @employee.errors[:dob]
|
16
|
+
assert_equal ["can't be blank"], @employee.errors[:joined]
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_invalid_day_does_not_add_invalid_date_message_to_cant_be_blank_message
|
20
|
+
@employee.dob_dd = '32'
|
21
|
+
@employee.joined_mm = '77'
|
22
|
+
assert_false @employee.valid?
|
23
|
+
assert_equal ["can't be blank"], @employee.errors[:dob]
|
24
|
+
assert_equal ["can't be blank"], @employee.errors[:joined]
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_valid_dates_generate_no_errors_at_all
|
28
|
+
@employee.dob_dd = '15'
|
29
|
+
@employee.dob_mm = '8'
|
30
|
+
@employee.dob_yyyy = '2016'
|
31
|
+
assert_empty @employee.errors[:dob]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
3
|
+
require File.dirname(__FILE__) + '/../../../../lib/gov_uk_date_fields/gov_uk_date_fields'
|
4
|
+
|
5
|
+
|
6
|
+
class OverrideErrorClashEmployeeTest < ActiveSupport::TestCase
|
7
|
+
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@employee = OverrideErrorClashEmployee.new(name: 'John', dob: nil, joined: nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_presence_error_messages_generated
|
14
|
+
@employee.valid?
|
15
|
+
assert_equal ["Can't be blank"], @employee.errors[:dob]
|
16
|
+
assert_equal ["Can't be blank"], @employee.errors[:joined]
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_invalid_day_overrides_cant_be_blank_message
|
20
|
+
@employee.dob_mm = '77'
|
21
|
+
assert_false @employee.valid?
|
22
|
+
assert_equal ["Invalid date"], @employee.errors[:dob]
|
23
|
+
assert_equal ["Can't be blank"], @employee.errors[:joined]
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_valid_dates_generate_no_errors_at_all
|
27
|
+
@employee.dob_dd = '15'
|
28
|
+
@employee.dob_mm = '8'
|
29
|
+
@employee.dob_yyyy = '2016'
|
30
|
+
assert_empty @employee.errors[:dob]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gov_uk_date_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Richards
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-08-
|
12
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -97,8 +97,11 @@ files:
|
|
97
97
|
- test/dummy/app/controllers/employees_controller.rb
|
98
98
|
- test/dummy/app/helpers/application_helper.rb
|
99
99
|
- test/dummy/app/helpers/employees_helper.rb
|
100
|
+
- test/dummy/app/models/default_error_clash_employee.rb
|
100
101
|
- test/dummy/app/models/director.rb
|
101
102
|
- test/dummy/app/models/employee.rb
|
103
|
+
- test/dummy/app/models/omit_error_clash_employee.rb
|
104
|
+
- test/dummy/app/models/override_error_clash_employee.rb
|
102
105
|
- test/dummy/app/views/employees/_form.html.erb
|
103
106
|
- test/dummy/app/views/employees/edit.html.erb
|
104
107
|
- test/dummy/app/views/employees/index.html.erb
|
@@ -138,9 +141,12 @@ files:
|
|
138
141
|
- test/dummy/public/favicon.ico
|
139
142
|
- test/dummy/test/controllers/employees_controller_test.rb
|
140
143
|
- test/dummy/test/fixtures/employees.yml
|
144
|
+
- test/dummy/test/models/default_error_clash_employee_test.rb
|
141
145
|
- test/dummy/test/models/director_test.rb
|
142
146
|
- test/dummy/test/models/employee_test.rb
|
143
147
|
- test/dummy/test/models/form_date_test.rb
|
148
|
+
- test/dummy/test/models/omit_error_clash_employee_test.rb
|
149
|
+
- test/dummy/test/models/overrride_error_clash_employee_test.rb
|
144
150
|
- test/dummy/tmp/cache/assets/sprockets/v3.0/2u/2ufDB6YFi50dQLigiWTZjdW_0yWDhh7vBJXZ9gzCW18.cache
|
145
151
|
- test/dummy/tmp/cache/assets/sprockets/v3.0/2ufDB6YFi50dQLigiWTZjdW_0yWDhh7vBJXZ9gzCW18.cache
|
146
152
|
- test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache
|
@@ -240,8 +246,11 @@ test_files:
|
|
240
246
|
- test/dummy/app/controllers/employees_controller.rb
|
241
247
|
- test/dummy/app/helpers/application_helper.rb
|
242
248
|
- test/dummy/app/helpers/employees_helper.rb
|
249
|
+
- test/dummy/app/models/default_error_clash_employee.rb
|
243
250
|
- test/dummy/app/models/director.rb
|
244
251
|
- test/dummy/app/models/employee.rb
|
252
|
+
- test/dummy/app/models/omit_error_clash_employee.rb
|
253
|
+
- test/dummy/app/models/override_error_clash_employee.rb
|
245
254
|
- test/dummy/app/views/employees/_form.html.erb
|
246
255
|
- test/dummy/app/views/employees/edit.html.erb
|
247
256
|
- test/dummy/app/views/employees/index.html.erb
|
@@ -283,9 +292,12 @@ test_files:
|
|
283
292
|
- test/dummy/README.rdoc
|
284
293
|
- test/dummy/test/controllers/employees_controller_test.rb
|
285
294
|
- test/dummy/test/fixtures/employees.yml
|
295
|
+
- test/dummy/test/models/default_error_clash_employee_test.rb
|
286
296
|
- test/dummy/test/models/director_test.rb
|
287
297
|
- test/dummy/test/models/employee_test.rb
|
288
298
|
- test/dummy/test/models/form_date_test.rb
|
299
|
+
- test/dummy/test/models/omit_error_clash_employee_test.rb
|
300
|
+
- test/dummy/test/models/overrride_error_clash_employee_test.rb
|
289
301
|
- test/dummy/tmp/cache/assets/sprockets/v3.0/2u/2ufDB6YFi50dQLigiWTZjdW_0yWDhh7vBJXZ9gzCW18.cache
|
290
302
|
- test/dummy/tmp/cache/assets/sprockets/v3.0/2ufDB6YFi50dQLigiWTZjdW_0yWDhh7vBJXZ9gzCW18.cache
|
291
303
|
- test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache
|