mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 15:06:23 +02:00
Merge pull request #2784 from internetee/2783-fix-repp-log
2783 fix repp log
This commit is contained in:
commit
160a1bc88c
6 changed files with 68 additions and 24 deletions
46
.dockerignore
Normal file
46
.dockerignore
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# Git
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.github
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
.dockerignore
|
||||||
|
Dockerfile*
|
||||||
|
docker-compose*
|
||||||
|
|
||||||
|
# Rails specific
|
||||||
|
log/*
|
||||||
|
tmp/*
|
||||||
|
storage/*
|
||||||
|
.bundle
|
||||||
|
.byebug_history
|
||||||
|
.rspec
|
||||||
|
spec/
|
||||||
|
test/
|
||||||
|
coverage/
|
||||||
|
public/assets
|
||||||
|
public/packs
|
||||||
|
node_modules
|
||||||
|
yarn-error.log
|
||||||
|
|
||||||
|
# Environment files
|
||||||
|
.env*
|
||||||
|
config/master.key
|
||||||
|
config/credentials/*.key
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
README.md
|
||||||
|
CHANGELOG.md
|
||||||
|
LICENSE
|
||||||
|
docs/
|
||||||
|
|
||||||
|
# Editor files
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# OS specific
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
|
@ -1,7 +1,6 @@
|
||||||
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
|
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
|
||||||
ARG RUBY_VERSION=3.0.3
|
ARG RUBY_VERSION=3.0.3
|
||||||
ARG TARGETPLATFORM=linux/amd64
|
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim AS base
|
||||||
FROM --platform=${TARGETPLATFORM} registry.docker.com/library/ruby:$RUBY_VERSION-slim AS base
|
|
||||||
|
|
||||||
# Rails app lives here
|
# Rails app lives here
|
||||||
WORKDIR /opt/webapps/app
|
WORKDIR /opt/webapps/app
|
||||||
|
@ -77,6 +76,7 @@ RUN apt-get update -qq && \
|
||||||
zip \
|
zip \
|
||||||
unzip \
|
unzip \
|
||||||
libzip-dev \
|
libzip-dev \
|
||||||
|
nodejs \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class AdminDomainContact < DomainContact
|
class AdminDomainContact < DomainContact
|
||||||
include AgeValidation
|
include AgeValidation
|
||||||
|
|
||||||
validate :validate_contact_age
|
validate :validate_contact_age
|
||||||
|
|
||||||
# rubocop:disable Metrics/AbcSize
|
# rubocop:disable Metrics/AbcSize
|
||||||
|
@ -33,8 +33,6 @@ class AdminDomainContact < DomainContact
|
||||||
def validate_contact_age
|
def validate_contact_age
|
||||||
return unless contact&.underage?
|
return unless contact&.underage?
|
||||||
|
|
||||||
errors.add(:contact, I18n.t(
|
errors.add(:base, :contact_too_young)
|
||||||
'activerecord.errors.models.admin_domain_contact.contact_too_young'
|
|
||||||
))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,13 +17,17 @@ module AgeValidation
|
||||||
def underage_by_birthday?
|
def underage_by_birthday?
|
||||||
birth_date = Date.parse(ident)
|
birth_date = Date.parse(ident)
|
||||||
calculate_age(birth_date) < 18
|
calculate_age(birth_date) < 18
|
||||||
|
rescue ArgumentError
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def underage_by_estonian_id?
|
def underage_by_estonian_id?
|
||||||
return false unless estonian_id?
|
return false unless estonian_id?
|
||||||
|
|
||||||
birth_date = parse_estonian_id_birth_date(ident)
|
birth_date = parse_estonian_id_birth_date(ident)
|
||||||
calculate_age(birth_date) < 18
|
calculate_age(birth_date) < 18
|
||||||
|
rescue ArgumentError
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def estonian_id?
|
def estonian_id?
|
||||||
|
@ -50,4 +54,4 @@ module AgeValidation
|
||||||
|
|
||||||
Date.parse("#{birth_year}-#{month}-#{day}")
|
Date.parse("#{birth_year}-#{month}-#{day}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,11 +3,10 @@ class DomainContact < ApplicationRecord
|
||||||
# STI: admin_domain_contact
|
# STI: admin_domain_contact
|
||||||
include Versions # version/domain_contact_version.rb
|
include Versions # version/domain_contact_version.rb
|
||||||
include EppErrors
|
include EppErrors
|
||||||
|
|
||||||
belongs_to :contact
|
belongs_to :contact
|
||||||
belongs_to :domain
|
belongs_to :domain
|
||||||
|
|
||||||
validates :contact, presence: true
|
|
||||||
|
|
||||||
after_destroy :update_contact
|
after_destroy :update_contact
|
||||||
attr_accessor :value_typeahead
|
attr_accessor :value_typeahead
|
||||||
attr_writer :contact_code
|
attr_writer :contact_code
|
||||||
|
|
|
@ -20,15 +20,14 @@ class DomainContactTest < ActiveSupport::TestCase
|
||||||
ident_type: 'birthday',
|
ident_type: 'birthday',
|
||||||
ident: (Time.zone.now - 16.years).strftime('%Y-%m-%d')
|
ident: (Time.zone.now - 16.years).strftime('%Y-%m-%d')
|
||||||
)
|
)
|
||||||
|
|
||||||
domain_contact = AdminDomainContact.new(
|
domain_contact = AdminDomainContact.new(
|
||||||
domain: domains(:shop),
|
domain: domains(:shop),
|
||||||
contact: admin_contact
|
contact: admin_contact
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_not domain_contact.valid?
|
assert_not domain_contact.valid?
|
||||||
assert_includes domain_contact.errors.full_messages,
|
assert_includes domain_contact.errors.full_messages, 'Administrative contact must be at least 18 years old'
|
||||||
'Contact Administrative contact must be at least 18 years old'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validates_admin_contact_age_with_estonian_id
|
def test_validates_admin_contact_age_with_estonian_id
|
||||||
|
@ -38,15 +37,14 @@ class DomainContactTest < ActiveSupport::TestCase
|
||||||
ident: '61203150222',
|
ident: '61203150222',
|
||||||
ident_country_code: 'EE'
|
ident_country_code: 'EE'
|
||||||
)
|
)
|
||||||
|
|
||||||
domain_contact = AdminDomainContact.new(
|
domain_contact = AdminDomainContact.new(
|
||||||
domain: domains(:shop),
|
domain: domains(:shop),
|
||||||
contact: admin_contact
|
contact: admin_contact
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_not domain_contact.valid?
|
assert_not domain_contact.valid?
|
||||||
assert_includes domain_contact.errors.full_messages,
|
assert_includes domain_contact.errors.full_messages, 'Administrative contact must be at least 18 years old'
|
||||||
'Contact Administrative contact must be at least 18 years old'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_allows_adult_admin_contact_with_birthday
|
def test_allows_adult_admin_contact_with_birthday
|
||||||
|
@ -55,12 +53,12 @@ class DomainContactTest < ActiveSupport::TestCase
|
||||||
ident_type: 'birthday',
|
ident_type: 'birthday',
|
||||||
ident: (Time.zone.now - 20.years).strftime('%Y-%m-%d')
|
ident: (Time.zone.now - 20.years).strftime('%Y-%m-%d')
|
||||||
)
|
)
|
||||||
|
|
||||||
domain_contact = AdminDomainContact.new(
|
domain_contact = AdminDomainContact.new(
|
||||||
domain: domains(:shop),
|
domain: domains(:shop),
|
||||||
contact: admin_contact
|
contact: admin_contact
|
||||||
)
|
)
|
||||||
|
|
||||||
assert domain_contact.valid?
|
assert domain_contact.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,13 +69,12 @@ class DomainContactTest < ActiveSupport::TestCase
|
||||||
ident: '38903111310',
|
ident: '38903111310',
|
||||||
ident_country_code: 'EE'
|
ident_country_code: 'EE'
|
||||||
)
|
)
|
||||||
|
|
||||||
domain_contact = AdminDomainContact.new(
|
domain_contact = AdminDomainContact.new(
|
||||||
domain: domains(:shop),
|
domain: domains(:shop),
|
||||||
contact: admin_contact
|
contact: admin_contact
|
||||||
)
|
)
|
||||||
|
|
||||||
assert domain_contact.valid?
|
assert domain_contact.valid?
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue