mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Contact status ok by default
This commit is contained in:
parent
b2488c7ebe
commit
5341a42a43
2 changed files with 13 additions and 0 deletions
|
@ -40,6 +40,14 @@ class Contact < ActiveRecord::Base
|
|||
before_create :generate_code
|
||||
before_create :generate_auth_info
|
||||
after_create :ensure_disclosure
|
||||
after_save :manage_automatic_statuses
|
||||
def manage_automatic_statuses
|
||||
if statuses.empty? && valid?
|
||||
statuses.create(value: ContactStatus::OK)
|
||||
elsif statuses.length > 1 || !valid?
|
||||
statuses.find_by(value: ContactStatus::OK).try(:destroy)
|
||||
end
|
||||
end
|
||||
|
||||
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
||||
|
||||
|
|
|
@ -147,6 +147,11 @@ describe Contact do
|
|||
@contact.auth_info.should == 'password'
|
||||
end
|
||||
|
||||
it 'should have ok status by default' do
|
||||
@contact.statuses.size.should == 1
|
||||
@contact.statuses.first.value.should == 'ok'
|
||||
end
|
||||
|
||||
context 'as birthday' do
|
||||
before :all do
|
||||
@contact.ident_type = 'birthday'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue