mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 13:44:47 +02:00
parent
7c45a85cea
commit
3e2a24ca62
2 changed files with 20 additions and 1 deletions
|
@ -37,7 +37,7 @@ class Contact < ActiveRecord::Base
|
|||
validates_associated :identifier
|
||||
|
||||
validate :validate_html
|
||||
validate :validate_country_code
|
||||
validate :validate_country_code, if: 'self.class.address_processing?'
|
||||
|
||||
after_initialize do
|
||||
self.status_notes = {} if status_notes.nil?
|
||||
|
|
19
test/models/contact/postal_address_test.rb
Normal file
19
test/models/contact/postal_address_test.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ContactPostalAddressTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@contact = contacts(:john)
|
||||
end
|
||||
|
||||
def test_invalid_if_country_code_is_invalid_and_address_processing_is_on
|
||||
Setting.address_processing = true
|
||||
@contact.country_code = 'invalid'
|
||||
assert @contact.invalid?
|
||||
end
|
||||
|
||||
def test_valid_if_country_code_is_invalid_and_address_processing_is_off
|
||||
Setting.address_processing = false
|
||||
@contact.country_code = 'invalid'
|
||||
assert @contact.valid?
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue