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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f92027a30bb1656c21c247f66048446e0f4156b5
4
- data.tar.gz: 1fede8e9a05da9232209c3ee2a97a5acd0b05c77
3
+ metadata.gz: 90ab4bbccf8f42e982b867ce4137a4526bf900ae
4
+ data.tar.gz: 77b6f26b29d6cea5c19c48063a0d5779c6317957
5
5
  SHA512:
6
- metadata.gz: 48dd22339d50ae676bce792edfdf0ed1fc3eacbcbfca6f907879bd2c27e9c6966097a3be421064c2fb033cd0578e4285ebd99335e2bc0a251dd297f852e0d941
7
- data.tar.gz: f96bd9bef4dd37ddbd2d89b40b603d81af278eacc0dee283d2104993781197b2278ee102003f5c7a4c00fc49d9d1d72d452c1350d706e8bb2844060ccf97b3a2
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, presence: true, length: { in: 2..self.columns_hash['name'].limit }
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 = self.full_address if self.personalized_name.blank?
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 = self.full_address.split '@', 2
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
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Contact
3
- VERSION = '1.4'.freeze
3
+ VERSION = '1.4.1'.freeze
4
4
  end
5
5
  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: '1.4'
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-01-30 00:00:00.000000000 Z
11
+ date: 2017-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common