Refactor country

This commit is contained in:
Martin Lensment 2015-02-02 12:07:59 +02:00
parent 195aa4a890
commit b86e2d1edb
3 changed files with 8 additions and 8 deletions

View file

@ -9,8 +9,8 @@ class User < ActiveRecord::Base
validates :username, :password, presence: true validates :username, :password, presence: true
validates :identity_code, uniqueness: true, allow_blank: true validates :identity_code, uniqueness: true, allow_blank: true
validates :identity_code, presence: true, if: -> { country.iso == 'EE' } validates :identity_code, presence: true, if: -> { country.alpha2 == 'EE' }
validates :email, presence: true, if: -> { country.iso != 'EE' } validates :email, presence: true, if: -> { country.alpha2 != 'EE' }
validate :validate_identity_code validate :validate_identity_code

View file

@ -5,7 +5,7 @@ xml.tag!('contact:postalInfo', type: 'int') do
if @disclosure.try(:addr) || @owner if @disclosure.try(:addr) || @owner
xml.tag!('contact:addr') do xml.tag!('contact:addr') do
xml.tag!('contact:street', address.street) if address xml.tag!('contact:street', address.street) if address
xml.tag!('contact:cc', address.try(:country).try(:iso)) unless address.try(:country).nil? xml.tag!('contact:cc', address.country_code) unless address.country_code.nil?
xml.tag!('contact:city', address.city) if address xml.tag!('contact:city', address.city) if address
end end
end end

View file

@ -8,7 +8,7 @@ registrar1 = Registrar.where(
reg_no: '10300220', reg_no: '10300220',
address: 'Pärnu mnt 2, Tallinna linn, Harju maakond, 11415', address: 'Pärnu mnt 2, Tallinna linn, Harju maakond, 11415',
email: 'registrar1@example.com', email: 'registrar1@example.com',
country: Country.first country_code: 'EE'
).first_or_create! ).first_or_create!
ApiUser.where( ApiUser.where(
@ -23,7 +23,7 @@ registrar2 = Registrar.where(
reg_no: '10529229', reg_no: '10529229',
address: 'Vabaduse pst 32, 11316 Tallinn', address: 'Vabaduse pst 32, 11316 Tallinn',
email: 'registrar2@example.com', email: 'registrar2@example.com',
country: Country.first country_code: 'EE'
).first_or_create! ).first_or_create!
ApiUser.where( ApiUser.where(
@ -38,7 +38,7 @@ User.where(
password: 'test1', password: 'test1',
email: 'user1@example.ee', email: 'user1@example.ee',
identity_code: '37810013855', identity_code: '37810013855',
country: Country.where(name: 'Estonia').first country_code: 'EE'
).first_or_create! ).first_or_create!
User.where( User.where(
@ -46,7 +46,7 @@ User.where(
password: 'test2', password: 'test2',
email: 'user2@example.ee', email: 'user2@example.ee',
identity_code: '37810010085', identity_code: '37810010085',
country: Country.where(name: 'Estonia').first country_code: 'EE'
).first_or_create! ).first_or_create!
User.where( User.where(
@ -54,7 +54,7 @@ User.where(
password: 'test3', password: 'test3',
email: 'user3@example.ee', email: 'user3@example.ee',
identity_code: '37810010727', identity_code: '37810010727',
country: Country.where(name: 'Estonia').first country_code: 'EE'
).first_or_create! ).first_or_create!
User.update_all(roles: ['admin']) User.update_all(roles: ['admin'])