mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
cd4486c79c
3 changed files with 31 additions and 0 deletions
|
@ -4,6 +4,8 @@ class Contact < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :addresses
|
has_many :addresses
|
||||||
|
|
||||||
|
validates_presence_of :code, :name, :phone, :email, :ident
|
||||||
|
|
||||||
validate :ident_must_be_valid
|
validate :ident_must_be_valid
|
||||||
validates :phone, format: { with: /\+\d{3}\.\d+/, message: "bad format" }
|
validates :phone, format: { with: /\+\d{3}\.\d+/, message: "bad format" }
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,22 @@
|
||||||
# available at http://guides.rubyonrails.org/i18n.html.
|
# available at http://guides.rubyonrails.org/i18n.html.
|
||||||
|
|
||||||
en:
|
en:
|
||||||
|
activerecord:
|
||||||
|
errors:
|
||||||
|
models:
|
||||||
|
contact:
|
||||||
|
attributes:
|
||||||
|
code:
|
||||||
|
blank: "Required parameter missing - code"
|
||||||
|
name:
|
||||||
|
blank: "Required parameter missing - name"
|
||||||
|
phone:
|
||||||
|
blank: "Required parameter missing - phone"
|
||||||
|
email:
|
||||||
|
blank: "Required parameter missing - email"
|
||||||
|
ident:
|
||||||
|
blank: "Required parameter missing - ident"
|
||||||
|
|
||||||
errors:
|
errors:
|
||||||
messages:
|
messages:
|
||||||
epp_domain_reserved: 'Domain name is reserved or restricted'
|
epp_domain_reserved: 'Domain name is reserved or restricted'
|
||||||
|
|
|
@ -15,6 +15,19 @@ describe Contact do
|
||||||
@contact.ident = "123abc"
|
@contact.ident = "123abc"
|
||||||
expect(@contact.valid?).to be false
|
expect(@contact.valid?).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should return missing parameter error messages' do
|
||||||
|
@contact = Contact.new
|
||||||
|
expect(@contact.valid?).to eq false
|
||||||
|
|
||||||
|
expect(@contact.errors.messages).to match_array({
|
||||||
|
:code=>["Required parameter missing - code"],
|
||||||
|
:name=>["Required parameter missing - name"],
|
||||||
|
:phone=>["Required parameter missing - phone", "bad format"],
|
||||||
|
:email=>["Required parameter missing - email"],
|
||||||
|
:ident=>["Required parameter missing - ident"]
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue