unidom-geo-china 0.5 → 0.5.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dd8fa89ff879d8ad98a63349c4dc3fd68d8d9c9
|
4
|
+
data.tar.gz: '095dfe1d5ab55022b30f65328a0bbe57d4366fc2'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85df3cfef412f717c2e631359c4f92b1712fcc3740d6ede909b9790e54359048f91aaf4c75459f15cbcce58148b35caaa56a25abfe86aad9ede49f0adadb2a77
|
7
|
+
data.tar.gz: 3d3d5ca53e56cf977d8d161f05d2bdd37acab38ec09d995efc80268c73ee6e77db887e687613d97dc145eb34f1f0b79d4e1df696fade0e575537cfd52a1253d3
|
@@ -31,9 +31,9 @@ class Unidom::Geo::China::Region < Unidom::Geo::China::ApplicationRecord
|
|
31
31
|
include Unidom::Geo::China::Concerns::AsInferiorRegion
|
32
32
|
include Unidom::Geo::China::Concerns::AsSuperiorRegion
|
33
33
|
|
34
|
-
validates :numeric_code, numericality: { integer_only: true }
|
34
|
+
validates :numeric_code, presence: true, numericality: { integer_only: true, greater_than_or_equal_to: 0 }, length: { minimum: columns_hash['numeric_code'].limit }
|
35
35
|
validates :alphabetic_code, allow_blank: true, length: { minimum: 2 }
|
36
|
-
validates :name, presence: true, length: {
|
36
|
+
validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
|
37
37
|
|
38
38
|
belongs_to :scheme, polymorphic: true
|
39
39
|
|
@@ -7,7 +7,8 @@ class Unidom::Geo::China::Town < Unidom::Geo::China::ApplicationRecord
|
|
7
7
|
|
8
8
|
include Unidom::Common::Concerns::ModelExtension
|
9
9
|
|
10
|
-
validates :
|
10
|
+
validates :numeric_code, length: { minimum: self.columns_hash['numeric_code'].limit }, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
11
|
+
validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
|
11
12
|
|
12
13
|
belongs_to :region, class_name: 'Unidom::Geo::China::Region'
|
13
14
|
|
@@ -16,8 +16,59 @@ describe Unidom::Geo::China::Region, type: :model do
|
|
16
16
|
name: 'Some Region'
|
17
17
|
}
|
18
18
|
|
19
|
+
name_max_length = described_class.columns_hash['name'].limit
|
20
|
+
|
19
21
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
20
22
|
|
23
|
+
it_behaves_like 'validates', model_attributes, :numeric_code,
|
24
|
+
{ } => 0,
|
25
|
+
{ numeric_code: nil } => 3,
|
26
|
+
{ numeric_code: '' } => 3,
|
27
|
+
{ numeric_code: '1' } => 1,
|
28
|
+
{ numeric_code: '11' } => 1,
|
29
|
+
{ numeric_code: '111' } => 1,
|
30
|
+
{ numeric_code: '1111' } => 1,
|
31
|
+
{ numeric_code: '11111' } => 1,
|
32
|
+
{ numeric_code: 11111 } => 1,
|
33
|
+
{ numeric_code: '-11111' } => 1,
|
34
|
+
{ numeric_code: -11111 } => 1,
|
35
|
+
{ numeric_code: '111111' } => 0,
|
36
|
+
{ numeric_code: 111111 } => 0,
|
37
|
+
{ numeric_code: '-111111' } => 2,
|
38
|
+
{ numeric_code: -111111 } => 2,
|
39
|
+
{ numeric_code: '1111111' } => 1,
|
40
|
+
{ numeric_code: 1111111 } => 1,
|
41
|
+
{ numeric_code: '11111A' } => 1
|
42
|
+
|
43
|
+
it_behaves_like 'validates', model_attributes, :alphabetic_code,
|
44
|
+
{ } => 0,
|
45
|
+
{ alphabetic_code: nil } => 0,
|
46
|
+
{ alphabetic_code: '' } => 0,
|
47
|
+
{ alphabetic_code: '1' } => 1,
|
48
|
+
{ alphabetic_code: '11' } => 0,
|
49
|
+
{ alphabetic_code: 'AA' } => 0,
|
50
|
+
{ alphabetic_code: '111' } => 0,
|
51
|
+
{ alphabetic_code: 'AAA' } => 0,
|
52
|
+
{ alphabetic_code: '1111' } => 1,
|
53
|
+
{ alphabetic_code: 'AAAA' } => 1
|
54
|
+
|
55
|
+
it_behaves_like 'validates', model_attributes, :name,
|
56
|
+
{ } => 0,
|
57
|
+
{ name: nil } => 2,
|
58
|
+
{ name: '' } => 2,
|
59
|
+
{ name: '1' } => 1,
|
60
|
+
{ name: 'A' } => 1,
|
61
|
+
{ name: '11' } => 0,
|
62
|
+
{ name: 'AA' } => 0,
|
63
|
+
{ name: '111' } => 0,
|
64
|
+
{ name: 'AAA' } => 0,
|
65
|
+
{ name: '1'*(name_max_length-1) } => 0,
|
66
|
+
{ name: 'A'*(name_max_length-1) } => 0,
|
67
|
+
{ name: '1'*name_max_length } => 0,
|
68
|
+
{ name: 'A'*name_max_length } => 0,
|
69
|
+
{ name: '1'*(name_max_length+1) } => 1,
|
70
|
+
{ name: 'A'*(name_max_length+1) } => 1
|
71
|
+
|
21
72
|
end
|
22
73
|
|
23
74
|
end
|
@@ -14,8 +14,45 @@ describe Unidom::Geo::China::Town, type: :model do
|
|
14
14
|
name: 'Some Town'
|
15
15
|
}
|
16
16
|
|
17
|
+
name_max_length = described_class.columns_hash['name'].limit
|
18
|
+
|
17
19
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
18
20
|
|
21
|
+
it_behaves_like 'validates', model_attributes, :numeric_code,
|
22
|
+
{ } => 0,
|
23
|
+
{ numeric_code: nil } => 3,
|
24
|
+
{ numeric_code: '' } => 3,
|
25
|
+
{ numeric_code: '1' } => 1,
|
26
|
+
{ numeric_code: '1'*8 } => 1,
|
27
|
+
{ numeric_code: 11_111_111 } => 1,
|
28
|
+
{ numeric_code: "-#{'1'*8}" } => 1,
|
29
|
+
{ numeric_code: -11_111_111 } => 1,
|
30
|
+
{ numeric_code: '1'*9 } => 0,
|
31
|
+
{ numeric_code: 111_111_111 } => 0,
|
32
|
+
{ numeric_code: "-#{'1'*9}" } => 2,
|
33
|
+
{ numeric_code: -111_111_111 } => 2,
|
34
|
+
{ numeric_code: '1'*10 } => 1,
|
35
|
+
{ numeric_code: 1_111_111_111 } => 1,
|
36
|
+
{ numeric_code: "#{'1'*8}A" } => 1,
|
37
|
+
{ numeric_code: '111111.11' } => 1,
|
38
|
+
{ numeric_code: 111111.11 } => 1
|
39
|
+
|
40
|
+
it_behaves_like 'validates', model_attributes, :name,
|
41
|
+
{ } => 0,
|
42
|
+
{ name: nil } => 2,
|
43
|
+
{ name: '' } => 2,
|
44
|
+
{ name: '1' } => 1,
|
45
|
+
{ name: '11' } => 0,
|
46
|
+
{ name: 'AA' } => 0,
|
47
|
+
{ name: '111' } => 0,
|
48
|
+
{ name: 'AAA' } => 0,
|
49
|
+
{ name: '1'*(name_max_length-1) } => 0,
|
50
|
+
{ name: 'A'*(name_max_length-1) } => 0,
|
51
|
+
{ name: '1'*name_max_length } => 0,
|
52
|
+
{ name: 'A'*name_max_length } => 0,
|
53
|
+
{ name: '1'*(name_max_length+1) } => 1,
|
54
|
+
{ name: 'A'*(name_max_length+1) } => 1
|
55
|
+
|
19
56
|
end
|
20
57
|
|
21
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-geo-china
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-geo
|