unidom-contact 1.4 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/unidom/contact/contact_subscription.rb +1 -1
- data/app/models/unidom/contact/email_address.rb +3 -3
- data/lib/rspec/models/unidom/contact/contact_subscription_spec.rb +13 -0
- data/lib/rspec/models/unidom/contact/email_address_spec.rb +17 -0
- data/lib/unidom/contact/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90ab4bbccf8f42e982b867ce4137a4526bf900ae
|
4
|
+
data.tar.gz: 77b6f26b29d6cea5c19c48063a0d5779c6317957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96ca484032fa3edb02ad080355905b98bf9421eacfabbf7bea4f767d077a0533226eb8b8df2d45c6e72cfcccdbdcd2bbd672cfce877eb6489ca70fdbca0d9ea4
|
7
|
+
data.tar.gz: 5d65a43f43c35c19dac9b49abc4f6c82a7f7a572ec83493bc51ff4d51d0c5bf4f4acdc3e571aa15965bfa328cdc27273baff157eb71b13cb732dfddc49b8a785
|
@@ -7,7 +7,7 @@ class Unidom::Contact::ContactSubscription < Unidom::Contact::ApplicationRecord
|
|
7
7
|
|
8
8
|
include Unidom::Common::Concerns::ModelExtension
|
9
9
|
|
10
|
-
validates :name,
|
10
|
+
validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
|
11
11
|
|
12
12
|
belongs_to :contact, polymorphic: true
|
13
13
|
belongs_to :subscriber, polymorphic: true
|
@@ -18,10 +18,10 @@ class Unidom::Contact::EmailAddress < Unidom::Contact::ApplicationRecord
|
|
18
18
|
scope :domain_part_is, ->(domain_part) { where domain_part: domain_part }
|
19
19
|
|
20
20
|
before_validation do
|
21
|
-
self.full_address.strip
|
22
|
-
self.personalized_name =
|
21
|
+
self.full_address = full_address.to_s.strip
|
22
|
+
self.personalized_name = full_address if personalized_name.blank?
|
23
23
|
self.full_address.downcase!
|
24
|
-
self.local_part, self.domain_part =
|
24
|
+
self.local_part, self.domain_part = full_address.split '@', 2
|
25
25
|
end
|
26
26
|
|
27
27
|
# http://blog.csdn.net/wide288/article/details/20782399
|
@@ -16,8 +16,21 @@ describe Unidom::Contact::ContactSubscription, type: :model do
|
|
16
16
|
name: 'Home'
|
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, :name,
|
24
|
+
{ } => 0,
|
25
|
+
{ name: nil } => 2,
|
26
|
+
{ name: '' } => 2,
|
27
|
+
{ name: 'A' } => 1,
|
28
|
+
{ name: 'Al' } => 0,
|
29
|
+
{ name: 'Bob' } => 0,
|
30
|
+
{ name: 'A'*(name_max_length-1) } => 0,
|
31
|
+
{ name: 'A'*name_max_length } => 0,
|
32
|
+
{ name: 'A'*(name_max_length+1) } => 1
|
33
|
+
|
21
34
|
end
|
22
35
|
|
23
36
|
end
|
@@ -15,6 +15,23 @@ describe Unidom::Contact::EmailAddress, type: :model do
|
|
15
15
|
|
16
16
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
17
17
|
|
18
|
+
full_address_max_length = described_class.columns_hash['full_address'].limit
|
19
|
+
|
20
|
+
it_behaves_like 'validates', model_attributes, :full_address,
|
21
|
+
{ } => 0,
|
22
|
+
{ full_address: nil } => 2,
|
23
|
+
{ full_address: '' } => 2,
|
24
|
+
{ full_address: 'l' } => 1,
|
25
|
+
{ full_address: 'l@' } => 1,
|
26
|
+
{ full_address: 'l@d' } => 1,
|
27
|
+
{ full_address: 'l@us' } => 0,
|
28
|
+
{ full_address: 'l@com' } => 0,
|
29
|
+
{ full_address: 'l@jobs' } => 0,
|
30
|
+
{ full_address: 'l@jobs.com.cn' } => 0,
|
31
|
+
{ full_address: "l@#{'c'*(full_address_max_length-6)}.de" } => 0,
|
32
|
+
{ full_address: "l@#{'c'*(full_address_max_length-5)}.de" } => 0,
|
33
|
+
{ full_address: "l@#{'c'*(full_address_max_length-4)}.de" } => 1
|
34
|
+
|
18
35
|
end
|
19
36
|
|
20
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-contact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.4.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-
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|