Merge branch 'master' of github.com:domify/registry

This commit is contained in:
Martin Lensment 2015-07-29 11:20:30 +03:00
commit 00cfbbdc7f
54 changed files with 856 additions and 128 deletions

View file

@ -4,6 +4,8 @@ class Admin::PricelistsController < AdminController
def index
@q = Pricelist.search(params[:q])
@q.sorts = ['category asc', 'duration asc', 'operation_category asc',
'valid_from desc', 'valid_to asc'] if @q.sorts.empty?
@pricelists = @q.result.page(params[:page])
end

View file

@ -56,15 +56,7 @@ class ApplicationController < ActionController::Base
end
def user_for_paper_trail
if defined?(current_user) && current_user.present?
# Most of the time it's not loaded in correct time because PaperTrail before filter kicks in
# before current_user is defined. PaperTrail is triggered also at current_user
api_user_log_str(current_user)
elsif current_user.present?
"#{current_user.id}-#{current_user.username}"
else
'public'
end
user_log_str(current_user)
end
def depp_current_user
@ -74,11 +66,8 @@ class ApplicationController < ActionController::Base
)
end
def api_user_log_str(user)
if user.present?
"#{user.id}-api-#{user.username}"
else
'api-public'
end
def user_log_str(user)
return 'public' if user.nil?
"#{user.id}-#{user.class}: #{user.username}"
end
end

View file

@ -120,7 +120,7 @@ class EppController < ApplicationController
@current_user ||= ApiUser.find_by_id(epp_session[:api_user_id])
# by default PaperTrail uses before filter and at that
# time current_user is not yet present
::PaperTrail.whodunnit = api_user_log_str(@current_user)
::PaperTrail.whodunnit = user_log_str(@current_user)
::PaperSession.session = epp_session.session_id if epp_session.session_id.present?
@current_user
end
@ -350,6 +350,7 @@ class EppController < ApplicationController
# rubocop: enable Style/PredicateName
# rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/PerceivedComplexity
def write_to_epp_log
# return nil if EPP_LOG_ENABLED
request_command = params[:command] || params[:action] # error receives :command, other methods receive :action
@ -366,12 +367,13 @@ class EppController < ApplicationController
request_successful: epp_errors.empty?,
request_object: params[:epp_object_type],
response: @response,
api_user_name: api_user_log_str(@api_user || current_user),
api_user_name: @api_user.try(:username) || current_user.try(:username) || 'api-public',
api_user_registrar: @api_user.try(:registrar).try(:to_s) || current_user.try(:registrar).try(:to_s),
ip: request.ip
})
end
# rubocop: enable Metrics/CyclomaticComplexity
# rubocop: enable Metrics/PerceivedComplexity
def iptables_counter_update
return if ENV['iptables_counter_enabled'].blank? && ENV['iptables_counter_enabled'] != 'true'

View file

@ -8,6 +8,7 @@ class DomainDeleteConfirmJob < Que::Job
domain.apply_pending_delete!
domain.clean_pendings!
when RegistrantVerification::REJECTED
DomainMailer.pending_delete_rejected_notification(domain).deliver_now
domain.clean_pendings!
end
destroy # it's best to destroy the job in the same transaction

View file

@ -8,6 +8,7 @@ class DomainUpdateConfirmJob < Que::Job
domain.apply_pending_update!
domain.clean_pendings!
when RegistrantVerification::REJECTED
DomainMailer.pending_update_rejected_notification_for_new_registrant(domain).deliver_now
domain.clean_pendings!
end
destroy # it's best to destroy the job in the same transaction

View file

@ -1,4 +1,5 @@
class ApplicationMailer < ActionMailer::Base
append_view_path Rails.root.join('app', 'views', 'mailers')
default from: 'noreply@internet.ee'
layout 'mailer'
@ -8,8 +9,8 @@ class ApplicationMailer < ActionMailer::Base
emails = [emails] unless emails.is_a?(Array)
emails = emails.flatten
emails.each do |email|
next unless TEST_EMAILS.include?(email)
logger.warn "EMAIL SENDING WAS BLOCKED BY WHITELIST: #{email}"
next if TEST_EMAILS.include?(email)
logger.info "EMAIL SENDING WAS BLOCKED BY WHITELIST: #{email}"
return true
end
false
@ -18,7 +19,7 @@ class ApplicationMailer < ActionMailer::Base
# turn on delivery on specific (epp) request only, thus rake tasks does not deliver anything
def delivery_off?(model)
return false if model.deliver_emails == true
logger.warn "EMAIL SENDING WAS NOT ACTIVATED " \
logger.info "EMAIL SENDING WAS NOT ACTIVATED " \
"BY MODEL OBJECT: id ##{model.try(:id)} deliver_emails returned false"
true
end

View file

@ -1,16 +1,10 @@
class ContactMailer < ApplicationMailer
# rubocop:disable Metrics/MethodLength
def email_updated(contact)
def email_updated(email, contact)
return if delivery_off?(contact)
@contact = contact
emails = []
emails << [@contact.email, @contact.email_was] if @contact.registrant_domains.present?
emails << @contact.domains.map(&:registrant_email) if @contact.domains.present?
emails = emails.uniq
return if whitelist_blocked?(emails)
emails.each do |email|
return if whitelist_blocked?(email)
begin
mail(to: email, subject: "#{I18n.t(:contact_email_update_subject)} [#{@contact.code}]")
rescue EOFError,
@ -26,9 +20,7 @@ class ContactMailer < ApplicationMailer
Net::SMTPSyntaxError,
Net::SMTPUnknownError,
OpenSSL::SSL::SSLError => e
logger.warn "EMAIL SENDING FAILED: #{email}: #{e}"
logger.info "EMAIL SENDING FAILED: #{email}: #{e}"
end
end
end
# rubocop:enable Metrics/MethodLength
end

View file

@ -1,5 +1,5 @@
class DomainMailer < ApplicationMailer
def registrant_pending_updated(domain)
def pending_update_request_for_old_registrant(domain)
@domain = domain
return if delivery_off?(@domain)
@ -20,16 +20,83 @@ class DomainMailer < ApplicationMailer
return if whitelist_blocked?(@old_registrant.email)
mail(to: @old_registrant.email,
subject: "#{I18n.t(:domain_registrant_pending_updated_subject, name: @domain.name)} [#{@domain.name}]")
subject: "#{I18n.t(:pending_update_request_for_old_registrant_subject,
name: @domain.name)} [#{@domain.name}]")
end
def registrant_updated(domain)
def pending_update_notification_for_new_registrant(domain)
@domain = domain
return if delivery_off?(@domain)
if @domain.registrant_verification_token.blank?
logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}"
return
end
if @domain.registrant_verification_asked_at.blank?
logger.warn "EMAIL NOT DELIVERED: registrant_verification_asked_at is missing for #{@domain.name}"
return
end
@new_registrant = @domain.registrant # NB! new registrant at this point
@old_registrant = Registrant.find(@domain.registrant_id_was)
return if whitelist_blocked?(@new_registrant.email)
mail(to: @new_registrant.email,
subject: "#{I18n.t(:pending_update_notification_for_new_registrant_subject,
name: @domain.name)} [#{@domain.name}]")
end
def registrant_updated_notification_for_new_registrant(domain)
@domain = domain
return if delivery_off?(@domain)
return if whitelist_blocked?(@domain.registrant_email)
mail(to: @domain.registrant_email,
subject: "#{I18n.t(:domain_registrant_updated, name: @domain.name)} [#{@domain.name}]")
subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject,
name: @domain.name)} [#{@domain.name}]")
end
def registrant_updated_notification_for_old_registrant(domain)
@domain = domain
return if delivery_off?(@domain)
@old_registrant_email = domain.registrant_email # Nb! before applying pending updates
return if whitelist_blocked?(@old_registrant_email)
mail(to: @old_registrant_email,
subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject,
name: @domain.name)} [#{@domain.name}]")
end
def pending_update_rejected_notification_for_new_registrant(domain)
@domain = domain
# no delivery off control, driggered by que, no epp request
@new_registrant_email = @domain.pending_json[:new_registrant_email]
@new_registrant_name = @domain.pending_json[:new_registrant_name]
return if whitelist_blocked?(@new_registrant_email)
mail(to: @new_registrant_email,
subject: "#{I18n.t(:pending_update_rejected_notification_for_new_registrant_subject,
name: @domain.name)} [#{@domain.name}]")
end
def pending_update_expired_notification_for_new_registrant(domain)
@domain = domain
# no delivery off control, driggered by cron, no epp request
@new_registrant_email = @domain.pending_json[:new_registrant_email]
@new_registrant_name = @domain.pending_json[:new_registrant_name]
return if whitelist_blocked?(@new_registrant_email)
if @new_registrant_email.blank?
logger.info "EMAIL NOT DELIVERED: no registrant email [pending_update_expired_notification_for_new_registrant]"
return
end
mail(to: @new_registrant_email,
subject: "#{I18n.t(:pending_update_expired_notification_for_new_registrant_subject,
name: @domain.name)} [#{@domain.name}]")
end
def pending_deleted(domain)
@ -53,6 +120,46 @@ class DomainMailer < ApplicationMailer
return if whitelist_blocked?(@old_registrant.email)
mail(to: @old_registrant.email,
subject: "#{I18n.t(:domain_pending_deleted_subject, name: @domain.name)} [#{@domain.name}]")
subject: "#{I18n.t(:domain_pending_deleted_subject,
name: @domain.name)} [#{@domain.name}]")
end
def pending_delete_rejected_notification(domain)
@domain = domain
# no delivery off control, driggered by que, no epp request
if @domain.registrant_verification_token.blank?
logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}"
return
end
if @domain.registrant_verification_asked_at.blank?
logger.warn "EMAIL NOT DELIVERED: registrant_verification_asked_at is missing for #{@domain.name}"
return
end
return if whitelist_blocked?(@domain.registrant.email)
mail(to: @domain.registrant.email,
subject: "#{I18n.t(:pending_delete_rejected_notification_subject,
name: @domain.name)} [#{@domain.name}]")
end
def pending_delete_expired_notification(domain)
@domain = domain
# no delivery off control, driggered by cron, no epp request
return if whitelist_blocked?(@domain.registrant.email)
mail(to: @domain.registrant.email,
subject: "#{I18n.t(:pending_delete_expired_notification_subject,
name: @domain.name)} [#{@domain.name}]")
end
def delete_confirmation(domain)
@domain = domain
return if whitelist_blocked?(@domain.registrant.email)
mail(to: @domain.registrant.email,
subject: "#{I18n.t(:delete_confirmation_subject,
name: @domain.name)} [#{@domain.name}]")
end
end

View file

@ -20,17 +20,15 @@ module Versions
true
end
# needs refactoring
# TODO: optimization work
# belongs_to :api_creator, class_name: 'ApiUser', foreign_key: :creator_str
# belongs_to :creator, class_name: 'User', foreign_key: :creator_str
def creator
return nil if creator_str.blank?
if creator_str =~ /^\d-api-/
creator = ApiUser.find_by(id: creator_str)
else
if creator_str =~ /^\d+-AdminUser:/
creator = AdminUser.find_by(id: creator_str)
elsif creator_str =~ /^\d+-ApiUser:/
creator = ApiUser.find_by(id: creator_str)
elsif creator_str =~ /^\d+-api-/ # depricated
creator = ApiUser.find_by(id: creator_str)
end
creator.present? ? creator : creator_str
@ -39,10 +37,12 @@ module Versions
def updator
return nil if updator_str.blank?
if updator_str =~ /^\d-api-/
updator = ApiUser.find_by(id: updator_str)
else
if updator_str =~ /^\d+-AdminUser:/
updator = AdminUser.find_by(id: updator_str)
elsif updator_str =~ /^\d+-ApiUser:/
updator = ApiUser.find_by(id: updator_str)
elsif updator_str =~ /^\d+-api-/ # depricated
updator = ApiUser.find_by(id: updator_str)
end
updator.present? ? updator : updator_str

View file

@ -42,7 +42,14 @@ class Contact < ActiveRecord::Base
before_update :manage_emails
def manage_emails
return nil unless email_changed?
ContactMailer.email_updated(self).deliver_now
return nil unless deliver_emails == true
emails = []
emails << [email, email_was]
emails << domains.map(&:registrant_email) if domains.present?
emails = emails.flatten.uniq
emails.each do |e|
ContactMailer.email_updated(e, self).deliver_now
end
end
before_save :manage_statuses
@ -159,9 +166,19 @@ class Contact < ActiveRecord::Base
end
def destroy_orphans
logger.info "#{Time.zone.now.utc} - Destroying orphaned contacts\n"
count = find_orphans.destroy_all.count
logger.info "#{Time.zone.now.utc} - Successfully destroyed #{count} orphaned contacts\n"
STDOUT << "#{Time.zone.now.utc} - Destroying orphaned contacts\n" unless Rails.env.test?
orphans = find_orphans
unless Rails.env.test?
orphans.each do |m|
STDOUT << "#{Time.zone.now.utc} Contact.destroy_orphans: ##{m.id}\n"
end
end
count = orphans.destroy_all.count
STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{count} orphaned contacts\n" unless Rails.env.test?
end
def privs

View file

@ -90,7 +90,8 @@ module Depp
server.close_connection
rescue OpenSSL::SSL::SSLError
rescue OpenSSL::SSL::SSLError => e
Rails.logger.error "INVALID CERT: #{e}"
errors.add(:base, :invalid_cert)
end
end

View file

@ -182,6 +182,9 @@ class Domain < ActiveRecord::Base
)
end
# rubocop: disable Metrics/AbcSize
# rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/PerceivedComplexity
def clean_expired_pendings
STDOUT << "#{Time.zone.now.utc} - Clean expired domain pendings\n" unless Rails.env.test?
@ -196,19 +199,32 @@ class Domain < ActiveRecord::Base
next
end
count += 1
if domain.pending_update?
DomainMailer.pending_update_expired_notification_for_new_registrant(domain).deliver_now
end
if domain.pending_delete?
DomainMailer.pending_delete_expired_notification(domain).deliver_now
end
domain.clean_pendings!
STDOUT << "#{Time.zone.now.utc} Domain.clean_expired_pendings: ##{domain.id}\n" unless Rails.env.test?
end
STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} domain pendings\n" unless Rails.env.test?
count
end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/AbcSize
# rubocop: enable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/LineLength
def start_expire_period
STDOUT << "#{Time.zone.now.utc} - Expiring domains\n" unless Rails.env.test?
domains = Domain.where('valid_to <= ?', Time.zone.now)
domains.each do |domain|
next unless domain.expirable?
domain.set_expired!
domain.set_expired
STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} #{domain.changes}\n" unless Rails.env.test?
domain.save(validate: false)
end
STDOUT << "#{Time.zone.now.utc} - Successfully expired #{domains.count} domains\n" unless Rails.env.test?
@ -218,12 +234,11 @@ class Domain < ActiveRecord::Base
STDOUT << "#{Time.zone.now.utc} - Setting server_hold to domains\n" unless Rails.env.test?
d = Domain.where('outzone_at <= ?', Time.zone.now)
d.each do |x|
next unless x.server_holdable?
x.statuses << DomainStatus::SERVER_HOLD
# TODO: This should be managed by automatic_statuses
x.statuses.delete(DomainStatus::OK)
x.save
d.each do |domain|
next unless domain.server_holdable?
domain.statuses << DomainStatus::SERVER_HOLD
STDOUT << "#{Time.zone.now.utc} Domain.start_redemption_grace_period: ##{domain.id} #{domain.changes}\n" unless Rails.env.test?
domain.save
end
STDOUT << "#{Time.zone.now.utc} - Successfully set server_hold to #{d.count} domains\n" unless Rails.env.test?
@ -233,11 +248,11 @@ class Domain < ActiveRecord::Base
STDOUT << "#{Time.zone.now.utc} - Setting delete_candidate to domains\n" unless Rails.env.test?
d = Domain.where('delete_at <= ?', Time.zone.now)
d.each do |x|
x.statuses << DomainStatus::DELETE_CANDIDATE if x.delete_candidateable?
# TODO: This should be managed by automatic_statuses
x.statuses.delete(DomainStatus::OK)
x.save
d.each do |domain|
next unless domain.delete_candidateable?
domain.statuses << DomainStatus::DELETE_CANDIDATE
STDOUT << "#{Time.zone.now.utc} Domain.start_delete_period: ##{domain.id} #{domain.changes}\n" unless Rails.env.test?
domain.save
end
return if Rails.env.test?
@ -251,17 +266,20 @@ class Domain < ActiveRecord::Base
c = 0
Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x|
x.destroy
STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by deleteCandidate ##{x.id}\n" unless Rails.env.test?
c += 1
end
Domain.where('force_delete_at <= ?', Time.zone.now).each do |x|
x.destroy
STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by force delete time ##{x.id}\n" unless Rails.env.test?
c += 1
end
STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{c} domains\n" unless Rails.env.test?
end
# rubocop:enable Rails/FindEach
# rubocop: enable Metrics/LineLength
end
def name=(value)
@ -349,8 +367,12 @@ class Domain < ActiveRecord::Base
token = registrant_verification_token
asked_at = registrant_verification_asked_at
changes_cache = changes
new_registrant_id = registrant.id
new_registrant_email = registrant.email
new_registrant_name = registrant.name
DomainMailer.registrant_pending_updated(self).deliver_now
DomainMailer.pending_update_request_for_old_registrant(self).deliver_now
DomainMailer.pending_update_notification_for_new_registrant(self).deliver_now
reload # revert back to original
@ -359,6 +381,9 @@ class Domain < ActiveRecord::Base
self.registrant_verification_asked_at = asked_at
self.statuses = [DomainStatus::PENDING_UPDATE]
pending_json[:domain] = changes_cache
pending_json[:new_registrant_id] = new_registrant_id
pending_json[:new_registrant_email] = new_registrant_email
pending_json[:new_registrant_name] = new_registrant_name
end
# rubocop: disable Metrics/CyclomaticComplexity

View file

@ -420,6 +420,7 @@ class Epp::Domain < Domain
# rubocop: enable Metrics/AbcSize
def apply_pending_update!
old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(self)
preclean_pendings
user = ApiUser.find(pending_json['current_user_id'])
frame = Nokogiri::XML(pending_json['frame'])
@ -428,7 +429,8 @@ class Epp::Domain < Domain
return unless update(frame, user, false)
clean_pendings!
self.deliver_emails = true # turn on email delivery for epp
DomainMailer.registrant_updated(self).deliver_now
DomainMailer.registrant_updated_notification_for_new_registrant(self).deliver_now
old_registrant_email.deliver_now
end
def apply_pending_delete!
@ -436,6 +438,7 @@ class Epp::Domain < Domain
user = ApiUser.find(pending_json['current_user_id'])
frame = Nokogiri::XML(pending_json['frame'])
statuses.delete(DomainStatus::PENDING_DELETE)
DomainMailer.delete_confirmation(self).deliver_now
clean_pendings! if epp_destroy(frame, user, false)
end

View file

@ -45,6 +45,12 @@ class Invoice < ActiveRecord::Base
'due_date < ? AND cancelled_at IS NULL', cr_at
)
unless Rails.env.test?
invoices.each do |m|
STDOUT << "#{Time.zone.now.utc} Invoice.cancel_overdue_invoices: ##{m.id}\n"
end
end
count = invoices.update_all(cancelled_at: Time.zone.now)
STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} overdue invoices\n" unless Rails.env.test?

View file

@ -31,7 +31,7 @@
%dd= @epp_log.created_at
.row
.col-md-6
.col-md-12
.panel.panel-default
.panel-heading
%h3.panel-title= t(:request)
@ -43,7 +43,8 @@
= formatted_req
- else
= @epp_log.request
.col-md-6
.row
.col-md-12
.panel.panel-default
.panel-heading
%h3.panel-title= t(:response)

View file

@ -14,10 +14,10 @@
%tr
%th{class: 'col-xs-2'}
= sort_link(@q, 'category', t(:category))
%th{class: 'col-xs-2'}
= sort_link(@q, 'operation_category', t(:operation))
%th{class: 'col-xs-2'}
= sort_link(@q, 'duration', t(:duration))
%th{class: 'col-xs-2'}
= sort_link(@q, 'operation_category', t(:operation))
%th{class: 'col-xs-2'}
= sort_link(@q, 'price', t(:price))
%th{class: 'col-xs-2'}
@ -31,8 +31,8 @@
- @pricelists.each do |pricelist|
%tr
%td= pricelist.category
%td= pricelist.operation_category
%td= pricelist.duration
%td= pricelist.operation_category
%td= pricelist.price
%td= l(pricelist.valid_from, format: :ydate)
%td= l(pricelist.valid_to, format: :ydate)

View file

@ -29,9 +29,9 @@ Eesti Interneti SA
<br><br>
Hi <%= @contact.name %>
<br><br>
E-mail address of <% @contact.name %> has been changed<br>
previous address: <% @contact.email_was %><br>
new address: <% @contact.email %>
E-mail address of <%= @contact.name %> has been changed<br>
previous address: <%= @contact.email_was %><br>
new address: <%= @contact.email %>
<br><br>
E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @contact.registrar.name %>
<br><br>

View file

@ -29,9 +29,9 @@ Eesti Interneti SA
Hi <%= @contact.name %>
E-mail address of <% @contact.name %> has been changed
previous address: <% @contact.email_was %>
new address: <% @contact.email %>
E-mail address of <%= @contact.name %> has been changed
previous address: <%= @contact.email_was %>
new address: <%= @contact.email %>
E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @contact.registrar.name %>

View file

@ -0,0 +1,15 @@
Tere,
<br><br>
Domeeni <%= @domain.name %> kustutamise taotlus on registreerija poolt kinnitatud. Domeen <%= @domain.name %> on peatatud ja kustub registrist.
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Domain <%= @domain.name %> deletion confirmed and will be deleted.
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,15 @@
Tere,
Domeeni <%= @domain.name %> kustutamise taotlus on registreerija poolt kinnitatud. Domeen <%= @domain.name %> on peatatud ja kustub registrist.
Lugupidamisega
Eesti Interneti SA
--------------------------------------
Hi,
Domain <%= @domain.name %> deletion confirmed and will be deleted.
Best Regards,
Estonian Internet Foundation

View file

@ -0,0 +1,15 @@
Tere,
<br><br>
Domeeni <%= @domain.name %> kustutamise taotlust ei kinnitatud tähtaegselt registreerija <%= @domain.registrant_name %> poolt. Domeeni <%= @domain.name %> kustutamine on sellest tulenevalt tühistatud.
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Domain <%= @domain.name %> deletion cancelled.
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,15 @@
Tere,
Domeeni <%= @domain.name %> kustutamise taotlust ei kinnitatud tähtaegselt registreerija <%= @domain.registrant_name %> poolt. Domeeni <%= @domain.name %> kustutamine on sellest tulenevalt tühistatud.
Lugupidamisega
Eesti Interneti SA
--------------------------------------
Hi,
Domain <%= @domain.name %> deletion cancelled.
Best Regards,
Estonian Internet Foundation

View file

@ -0,0 +1,15 @@
Tere,
<br><br>
Domeeni <%= @domain.name %> kustutamise taotlus on registreerija <%= @domain.registrar_name %> poolt tagasi lükatud.
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Domain <%= @domain.name %> deletion rejected.
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,15 @@
Tere,
Domeeni <%= @domain.name %> kustutamise taotlus on registreerija <%= @domain.registrar_name %> poolt tagasi lükatud.
Lugupidamisega
Eesti Interneti SA
--------------------------------------
Hi,
Domain <%= @domain.name %> deletion rejected.
Best Regards,
Estonian Internet Foundation

View file

@ -0,0 +1,19 @@
Tere,
<br><br>
Domeeni <%= @domain.name %> registreerija <%= @domain.registrant_name %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @domain.name %> registreerija vahetus on sellest tulenevalt tühistatud.
<br><br>
Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Domain registrant change has been expired for the domain <%= @domain.name %>.
<br><br>
Please contact to your registrar <%= @domain.registrar_name %> if you have any questions.
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,19 @@
Tere,
Domeeni <%= @domain.name %> registreerija <%= @domain.registrant_name %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @domain.name %> registreerija vahetus on sellest tulenevalt tühistatud.
Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad
Lugupidamisega
Eesti Interneti SA
--------------------------------------
Hi,
Domain registrant change has been expired for the domain <%= @domain.name %>.
Please contact to your registrar <%= @domain.registrar_name %> if you have any questions.
Best Regards,
Estonian Internet Foundation

View file

@ -0,0 +1,49 @@
Tere,
<br><br>
Registripidaja <%= @domain.registrar_name %> vahendusel on algatatud <%= @domain.name %> domeeni omanikuvahetuse protseduur.
<br><br>
Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %>
<br><br>
Uued registreerija andmed:<br>
Nimi: <%= @domain.registrant_name %><br>
<% if @domain.registrant.priv? %>
Isikukood: <%= @domain.registrant_ident %><br>
<% else %>
Äriregistrikood: <%= @domain.registrant_ident %><br>
<% end %>
Tänav: <%= @domain.registrant_street %><br>
Linn: <%= @domain.registrant_city %><br>
Riik: <%= @domain.registrant_country %>
<br><br>
Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @old_registrant.name %> omanikuvahetuse tähtaegselt kinnitab.
<br><br>
Juhul kui <%= @old_registrant.name %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse.<br>
<br><br>
Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka.
<br><br>
Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Registrant change process for the domain <%= @domain.name %> has been started.
<br><br>
New registrant:<br>
Name: <%= @domain.registrant_name %><br>
<% if @domain.registrant.priv? %>
Personal code: <%= @domain.registrant_ident %><br>
<% else %>
Business Registry code: <%= @domain.registrant_ident %><br>
<% end %>
Street: <%= @domain.registrant_street %><br>
City: <%= @domain.registrant_city %><br>
Country: <%= @domain.registrant_country %><br>
<br><br>
Please contact to your registrar <%= @domain.registrar_name %> if you have any questions.
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,49 @@
Tere,
Registripidaja <%= @domain.registrar_name %> vahendusel on algatatud <%= @domain.name %> domeeni omanikuvahetuse protseduur.
Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %>
Uued registreerija andmed:
Nimi: <%= @domain.registrant_name %>
<% if @domain.registrant.priv? %>
Isikukood: <%= @domain.registrant_ident %>
<% else %>
Äriregistrikood: <%= @domain.registrant_ident %>
<% end %>
Tänav: <%= @domain.registrant_street %>
Linn: <%= @domain.registrant_city %>
Riik: <%= @domain.registrant_country %>
Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @old_registrant.name %> omanikuvahetuse tähtaegselt kinnitab.
Juhul kui <%= @old_registrant.name %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse.
Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka.
Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad
Lugupidamisega
Eesti Interneti SA
--------------------------------------
Hi,
Registrant change process for the domain <%= @domain.name %> has been started.
New registrant:
Name: <%= @domain.registrant_name %>
<% if @domain.registrant.priv? %>
Personal code: <%= @domain.registrant_ident %>
<% else %>
Business Registry code: <%= @domain.registrant_ident %>
<% end %>
Street: <%= @domain.registrant_street %>
City: <%= @domain.registrant_city %>
Country: <%= @domain.registrant_country %>
Please contact to your registrar <%= @domain.registrar_name %> if you have any questions.
Best Regards,
Estonian Internet Foundation

View file

@ -0,0 +1,19 @@
Tere,
<br><br>
Domeeni <%= @domain.name %> registreerija <%= @new_registrant_name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
<br><br>
Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad
<br><br>
Lugupidamisega,<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Registrant change was declined for the domain <%= @domain.name %>.
<br><br>
Please contact to your registrar <%= @domain.registrar_name %> if you have any questions.
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,19 @@
Tere,
Domeeni <%= @domain.name %> registreerija <%= @new_registrant_name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad
Lugupidamisega
Eesti Interneti SA
--------------------------------------
Hi,
Registrant change was declined for the domain <%= @domain.name %>.
Please contact to your registrar <%= @domain.registrar_name %> if you have any questions.
Best Regards,
Estonian Internet Foundation

View file

@ -0,0 +1,21 @@
Tere,
<br><br>
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
<br><br>
Uued registreerija:<br>
Nimi: <%= @domain.registrant_name %>
<br><br>
Lugupidamisega<br>
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi,
<br><br>
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
<br><br>
New registrant:<br>
Name: <%= @domain.registrant_name %>
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -0,0 +1,21 @@
Tere,
Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.
Uued registreerija:
Nimi: <%= @domain.registrant_name %>
Lugupidamisega
Eesti Interneti SA
--------------------------------------
Hi,
Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.
New registrant:
Name: <%= @domain.registrant_name %>
Best Regards,
Estonian Internet Foundation

View file

@ -0,0 +1,20 @@
# Log all active model user errors
# rubocop: disable Lint/AssignmentInCondition
# rubocop: disable Style/SignalException
module ActiveModel
class Errors
def add(attribute, message = :invalid, options = {})
message = normalize_message(attribute, message, options)
if exception = options[:strict]
exception = ActiveModel::StrictValidationFailed if exception == true
raise exception, full_message(attribute, message)
end
# CUSTOM logging
Rails.logger.info "USER MSG: ACTIVEMODEL: #{@base.try(:class)} [#{attribute}] #{message}" if message.present?
# END of CUSTOM logging
self[attribute] << message
end
end
end

View file

@ -0,0 +1,8 @@
# Log all user issues raised by active record
# rubocop: disable Metrics/LineLength
class ActiveRecord::Base
after_validation do |m|
Rails.logger.info "USER MSG: ACTIVERECORD: #{m.class} ##{m.id} #{m.errors.full_messages} #{m.errors['epp_errors']}" if m.errors.present?
true
end
end

View file

@ -0,0 +1,31 @@
# Log all flash messages
# rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/LineLength
module ActionDispatch
class Flash
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Style/MultilineOperationIndentation
def call(env)
@app.call(env)
ensure
session = Request::Session.find(env) || {}
flash_hash = env[KEY]
if flash_hash && (flash_hash.present? || session.key?('flash'))
session["flash"] = flash_hash.to_session_value
# EIS custom logging
Rails.logger.info "USER MSG: FLASH: #{session['flash']['flashes'].inspect}" if session['flash']
# END OF EIS custom logging
env[KEY] = flash_hash.dup
end
if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?)
session.key?('flash') && session['flash'].nil?
session.delete('flash')
end
end
end
end

View file

@ -0,0 +1,14 @@
# EIS custom rack hack in order to enable test external interfaces EPP/REPP inside webserver network
# rubocop:disable Metrics/LineLength
module Rack
class Request
def trusted_proxy?(ip)
if ENV['eis_trusted_proxies']
ENV['eis_trusted_proxies'].split(',').map(&:strip).include?(ip)
else
ip =~ /\A127\.0\.0\.1\Z|\A(10|172\.(1[6-9]|2[0-9]|30|31)|192\.168)\.|\A::1\Z|\Afd[0-9a-f]{2}:.+|\Alocalhost\Z|\Aunix\Z|\Aunix:/i
end
end
end
end
# rubocop:enable Metrics/LineLength

View file

@ -13,4 +13,8 @@ TEST_EMAILS = %w(
info@gitlab.eu
test@example.com
test@example.org
old@example.org
new@example.org
old@example.com
new@example.com
)

View file

@ -777,8 +777,16 @@ en:
unimplemented_object_service: 'Unimplemented object service'
contact_email_update_subject: 'Teie domeenide kontakt epostiaadress on muutunud / Contact e-mail addresses of your domains have changed'
object_status_prohibits_operation: 'Object status prohibits operation'
domain_registrant_pending_updated_subject: "Kinnitustaotlus domeeni %{name} registreerija vahetuseks / Application for approval for registrant chache of %{name}"
pending_update_request_for_old_registrant_subject: "Kinnitustaotlus domeeni %{name} registreerija vahetuseks / Application for approval for registrant chache of %{name}"
pending_update_notification_for_new_registrant_subject: "Domeeni %{name} registreerija vahetus protseduur on algatatud / %{name} registrant change"
pending_update_rejected_notification_for_new_registrant_subject: "Domeeni %{name} registreerija vahetuse taotlus tagasi lükatud / %{name} registrant change declined"
pending_update_expired_notification_for_new_registrant_subject: "Domeeni %{name} registreerija vahetuse taotlus on tühistatud / %{name} registrant change cancelled"
registrant_updated_notification_for_new_registrant_subject: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'
registrant_updated_notification_for_old_registrant_subject: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'
domain_pending_deleted_subject: "Kinnitustaotlus domeeni %{name} kustutamiseks .ee registrist / Application for approval for deletion of %{name}"
pending_delete_rejected_notification_subject: "Domeeni %{name} kustutamise taotlus tagasi lükatud / %{name) deletion declined"
pending_delete_expired_notification_subject: "Domeeni %{name} kustutamise taotlus on tühistatud / %{name} deletion cancelled"
delete_confirmation_subject: "Domeeni %{name} kustutatud / %{name} deleted"
whois: WHOIS
login_failed_check_id_card: 'Log in failed, check ID card'
not_valid_domain_verification_title: Domain verification not available
@ -872,7 +880,6 @@ en:
no_transfers_found: 'No transfers found'
parameter_value_range_error: 'Parameter value range error: %{key}'
payment_received: 'Payment received'
domain_registrant_updated: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'
api_user_not_found: 'API user not found'
domain_already_belongs_to_the_querying_registrar: 'Domain already belongs to the querying registrar'
notes: Notes

View file

@ -24,9 +24,10 @@ every :day, at: '12:10am' do
runner 'Invoice.cancel_overdue_invoices'
end
every :day, at: '12:15am' do
runner 'Domain.expire_domains'
end
# TODO
# every :day, at: '12:15am' do
# runner 'Domain.expire_domains'
# end
every :day, at: '12:20am' do
runner 'Domain.clean_expired_pendings'

View file

@ -85,7 +85,7 @@ describe 'EPP Contact', epp: true do
log.request_command.should == 'create'
log.request_object.should == 'contact'
log.request_successful.should == true
log.api_user_name.should == '1-api-registrar1'
log.api_user_name.should == 'registrar1'
log.api_user_registrar.should == 'registrar1'
end

View file

@ -67,7 +67,7 @@ describe 'EPP Domain', epp: true do
log.request_command.should == 'create'
log.request_object.should == 'domain'
log.request_successful.should == false
log.api_user_name.should == '1-api-registrar1'
log.api_user_name.should == 'registrar1'
log.api_user_registrar.should == 'registrar1'
log.request.should_not be_blank
log.response.should_not be_blank
@ -1061,7 +1061,7 @@ describe 'EPP Domain', epp: true do
log.request_command.should == 'transfer'
log.request_object.should == 'domain'
log.request_successful.should == true
log.api_user_name.should == '2-api-registrar2'
log.api_user_name.should == 'registrar2'
log.api_user_registrar.should == 'registrar2'
log.request.should_not be_blank
log.response.should_not be_blank

View file

@ -32,7 +32,7 @@ describe 'EPP Poll', epp: true do
log.request_command.should == 'poll'
log.request_object.should == 'poll'
log.request_successful.should == true
log.api_user_name.should == '1-api-registrar1'
log.api_user_name.should == 'registrar1'
log.api_user_registrar.should == @registrar1.name
log.request.should_not be_blank
log.response.should_not be_blank

View file

@ -47,7 +47,7 @@ describe 'EPP Session', epp: true do
log = ApiLog::EppLog.last
log.request_command.should == 'login'
log.request_successful.should == false
log.api_user_name.should == '2-api-inactive-user'
log.api_user_name.should == 'inactive-user'
end
it 'prohibits further actions unless logged in' do
@ -88,7 +88,7 @@ describe 'EPP Session', epp: true do
log = ApiLog::EppLog.last
log.request_command.should == 'login'
log.request_successful.should == true
log.api_user_name.should == '1-api-gitlab'
log.api_user_name.should == 'gitlab'
end
it 'does not log in twice' do
@ -104,7 +104,7 @@ describe 'EPP Session', epp: true do
log = ApiLog::EppLog.last
log.request_command.should == 'login'
log.request_successful.should == false
log.api_user_name.should == '1-api-gitlab'
log.api_user_name.should == 'gitlab'
end
it 'logs out epp user' do

View file

@ -4,8 +4,7 @@ describe ContactMailer do
describe 'email changed notification when delivery turned off' do
before :all do
@contact = Fabricate(:contact, email: 'test@example.ee')
@contact.email = 'test@example.com' # new email
@mail = ContactMailer.email_updated(@contact)
@mail = ContactMailer.email_updated('test@example.com', @contact)
end
it 'should not render email subject' do
@ -31,8 +30,7 @@ describe ContactMailer do
@contact = @domain.registrant
@contact.reload # until figured out why registrant_domains not loaded
@contact.deliver_emails = true
@contact.email = 'test@example.org' # new email
@mail = ContactMailer.email_updated(@contact)
@mail = ContactMailer.email_updated('info@example.org', @contact)
end
it 'should render email subject' do
@ -43,9 +41,8 @@ describe ContactMailer do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should have both old and new receiver email' do
@mail.to.size.should == 2
@mail.to.include? "test@example.org"
it 'should send to info email' do
@mail.to.should == ['info@example.org']
end
it 'should render body' do

View file

@ -1,11 +1,11 @@
require 'rails_helper'
describe DomainMailer do
describe 'registrant changed notification when delivery turned off' do
describe 'pending update request for an old registrant when delivery turned off' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant)
@mail = DomainMailer.registrant_pending_updated(@domain)
@mail = DomainMailer.pending_update_request_for_old_registrant(@domain)
end
it 'should not render email subject' do
@ -25,7 +25,7 @@ describe DomainMailer do
end
end
describe 'email changed notification' do
describe 'pending update request for an old registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@new_registrant = Fabricate(:registrant, email: 'test@example.org')
@ -34,7 +34,7 @@ describe DomainMailer do
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@domain.registrant = @new_registrant
@mail = DomainMailer.registrant_pending_updated(@domain)
@mail = DomainMailer.pending_update_request_for_old_registrant(@domain)
end
it 'should render email subject' do
@ -58,6 +58,142 @@ describe DomainMailer do
end
end
describe 'pending upadte notification for a new registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'old@example.com')
@new_registrant = Fabricate(:registrant, email: 'new@example.org')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@domain.registrant = @new_registrant
@mail = DomainMailer.pending_update_notification_for_new_registrant(@domain)
end
it 'should render email subject' do
@mail.subject.should =~ /protseduur on algatatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to new registrant email' do
@mail.to.should == ["new@example.org"]
end
it 'should render body' do
@mail.body.encoded.should =~ /vahendusel on algatatud/
end
end
describe 'pending update notification for a new registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'old@example.com')
@new_registrant = Fabricate(:registrant, email: 'new@example.org')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@domain.registrant = @new_registrant
@mail = DomainMailer.pending_update_notification_for_new_registrant(@domain)
end
it 'should render email subject' do
@mail.subject.should =~ /protseduur on algatatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to new registrant email' do
@mail.to.should == ["new@example.org"]
end
it 'should render body' do
@mail.body.encoded.should =~ /vahendusel on algatatud/
end
end
describe 'pending update rejected notification for a new registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'old@example.com')
@new_registrant = Fabricate(:registrant, email: 'new@example.org')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@domain.pending_json[:new_registrant_email] = 'new@example.org'
@domain.pending_json[:new_registrant_name] = 'test name'
@mail = DomainMailer.pending_update_rejected_notification_for_new_registrant(@domain)
end
it 'should render email subject' do
@mail.subject.should =~ /vahetuse taotlus tagasi lükatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to new registrant email' do
@mail.to.should == ["new@example.org"]
end
it 'should render body' do
@mail.body.encoded.should =~ /Registrant change was declined/
end
end
describe 'registrant updated notification for a new registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@mail = DomainMailer.registrant_updated_notification_for_new_registrant(@domain)
end
it 'should render email subject' do
@mail.subject.should =~ /registreerija vahetus teostatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send to registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /registreerija vahetuse taotlus on kinnitatud/
end
end
describe 'registrant updated notification for a old registrant' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
@mail = DomainMailer.registrant_updated_notification_for_old_registrant(@domain)
end
it 'should render email subject' do
@mail.subject.should =~ /registreerija vahetus teostatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send to registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /registreerija vahetuse taotlus on kinnitatud/
end
end
describe 'domain pending delete notification when delivery turned off' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@ -113,28 +249,84 @@ describe DomainMailer do
end
end
describe 'registrant successfully changed confirmation' do
describe 'pending delete rejected notification' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, registrant: @registrant)
@domain = Fabricate(:domain, name: 'delete-pending-rejected.ee', registrant: @registrant)
@domain.deliver_emails = true
@mail = DomainMailer.registrant_updated(@domain)
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@mail = DomainMailer.pending_delete_rejected_notification(@domain)
end
it 'should render email subject' do
@mail.subject.should =~ /registreerija vahetus teostatud/
@mail.subject.should =~ /kustutamise taotlus tagasi lükatud/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send to registrant email' do
it 'should send confirm email to old registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /registreerija vahetuse taotlus on kinnitatud/
@mail.body.encoded.should =~ /deletion rejected/
end
end
describe 'pending delete expired notification' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, name: 'pending-delete-expired.ee', registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@mail = DomainMailer.pending_delete_expired_notification(@domain)
end
it 'should render email subject' do
@mail.subject.should =~ /deletion cancelled/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to old registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /deletion cancelled/
end
end
describe 'pending delete rejected notification' do
before :all do
@registrant = Fabricate(:registrant, email: 'test@example.com')
@domain = Fabricate(:domain, name: 'delete-confirmed.ee', registrant: @registrant)
@domain.deliver_emails = true
@domain.registrant_verification_token = '123'
@domain.registrant_verification_asked_at = Time.zone.now
@mail = DomainMailer.delete_confirmation(@domain)
end
it 'should render email subject' do
@mail.subject.should =~ /deleted/
end
it 'should have sender email' do
@mail.from.should == ["noreply@internet.ee"]
end
it 'should send confirm email to old registrant email' do
@mail.to.should == ["test@example.com"]
end
it 'should render body' do
@mail.body.encoded.should =~ /confirmed and will be deleted/
end
end
end

View file

@ -387,10 +387,10 @@ describe Domain do
@api_user = Fabricate(:api_user)
@user.id.should == 1
@api_user.id.should == 2
::PaperTrail.whodunnit = '2-api-testuser'
::PaperTrail.whodunnit = '2-ApiUser: testuser'
@domain = Fabricate(:domain)
@domain.creator_str.should == '2-api-testuser'
@domain.creator_str.should == '2-ApiUser: testuser'
@domain.creator.should == @api_user
@domain.creator.should_not == @user
@ -399,14 +399,14 @@ describe Domain do
it 'should return api_creator when created by api user' do
with_versioning do
@user = Fabricate(:admin_user)
@api_user = Fabricate(:api_user)
@user.id.should == 3
@api_user.id.should == 4
::PaperTrail.whodunnit = '3-testuser'
@user = Fabricate(:admin_user, id: 1000)
@api_user = Fabricate(:api_user, id: 2000)
@user.id.should == 1000
@api_user.id.should == 2000
::PaperTrail.whodunnit = '1000-AdminUser: testuser'
@domain = Fabricate(:domain)
@domain.creator_str.should == '3-testuser'
@domain.creator_str.should == '1000-AdminUser: testuser'
@domain.creator.should == @user
@domain.creator.should_not == @api_user