diff --git a/CHANGELOG.md b/CHANGELOG.md index 49cd0b4e1..6b06c9812 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +18.11.2016 +* Domain expiration emails are now sent out to admin contacts as well. Sending bug is fixed. +* Include detailed registrar's contact info in emails + 25.10.2016 * Outdated specs removed, failing specs fixed, rspec config improved diff --git a/app/controllers/admin/zonefiles_controller.rb b/app/controllers/admin/zonefiles_controller.rb index 7d3b68ec6..1c0fed936 100644 --- a/app/controllers/admin/zonefiles_controller.rb +++ b/app/controllers/admin/zonefiles_controller.rb @@ -3,7 +3,7 @@ class Admin::ZonefilesController < ApplicationController # TODO: Refactor this def create - if ZonefileSetting.pluck(:origin).include?(params[:origin]) + if ZonefileSetting.origins.include?(params[:origin]) @zonefile = ActiveRecord::Base.connection.execute( "select generate_zonefile('#{params[:origin]}')" diff --git a/app/jobs/domain_delete_confirm_email_job.rb b/app/jobs/domain_delete_confirm_email_job.rb new file mode 100644 index 000000000..65cf948f9 --- /dev/null +++ b/app/jobs/domain_delete_confirm_email_job.rb @@ -0,0 +1,22 @@ +class DomainDeleteConfirmEmailJob < Que::Job + def run(domain_id) + domain = Domain.find(domain_id) + + log(domain) + DomainDeleteMailer.confirm(domain: domain, + registrar: domain.registrar, + registrant: domain.registrant).deliver_now + end + + private + + def log(domain) + message = "Send DomainDeleteMailer#confirm email for domain #{domain.name} (##{domain.id})" \ + " to #{domain.registrant_email}" + logger.info(message) + end + + def logger + Rails.logger + end +end diff --git a/app/jobs/domain_delete_forced_email_job.rb b/app/jobs/domain_delete_forced_email_job.rb new file mode 100644 index 000000000..1ddd95bb9 --- /dev/null +++ b/app/jobs/domain_delete_forced_email_job.rb @@ -0,0 +1,22 @@ +class DomainDeleteForcedEmailJob < Que::Job + def run(domain_id) + domain = Domain.find(domain_id) + + log(domain) + DomainDeleteMailer.forced(domain: domain, + registrar: domain.registrar, + registrant: domain.registrant).deliver_now + end + + private + + def log(domain) + message = "Send DomainDeleteMailer#forced email for domain #{domain.name} (##{domain.id})" \ + " to #{domain.primary_contact_emails.join(', ')}" + logger.info(message) + end + + def logger + Rails.logger + end +end diff --git a/app/jobs/domain_expire_email_job.rb b/app/jobs/domain_expire_email_job.rb new file mode 100644 index 000000000..9b70a54e6 --- /dev/null +++ b/app/jobs/domain_expire_email_job.rb @@ -0,0 +1,9 @@ +class DomainExpireEmailJob < Que::Job + def run(domain_id) + domain = Domain.find(domain_id) + + return if domain.registered? + + DomainExpireMailer.expired(domain: domain, registrar: domain.registrar).deliver_now + end +end diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 4a47cc364..7d4fc488f 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -16,7 +16,10 @@ class DomainUpdateConfirmJob < Que::Job domain.clean_pendings! raise_errors!(domain) when RegistrantVerification::REJECTED - domain.send_mail :pending_update_rejected_notification_for_new_registrant + RegistrantChangeMailer.rejected(domain: domain, + registrar: domain.registrar, + registrant: domain.registrant).deliver_now + domain.poll_message!(:poll_pending_update_rejected_by_registrant) domain.clean_pendings_lowlevel end diff --git a/app/jobs/registrant_change_confirm_email_job.rb b/app/jobs/registrant_change_confirm_email_job.rb new file mode 100644 index 000000000..7d2dd79ad --- /dev/null +++ b/app/jobs/registrant_change_confirm_email_job.rb @@ -0,0 +1,23 @@ +class RegistrantChangeConfirmEmailJob < Que::Job + def run(domain_id, new_registrant_id) + domain = Domain.find(domain_id) + new_registrant = Registrant.find(new_registrant_id) + + log(domain) + RegistrantChangeMailer.confirm(domain: domain, + registrar: domain.registrar, + current_registrant: domain.registrant, + new_registrant: new_registrant).deliver_now + end + + private + + def log(domain) + message = "Send RegistrantChangeMailer#confirm email for domain #{domain.name} (##{domain.id}) to #{domain.registrant_email}" + logger.info(message) + end + + def logger + Rails.logger + end +end diff --git a/app/jobs/registrant_change_expired_email_job.rb b/app/jobs/registrant_change_expired_email_job.rb new file mode 100644 index 000000000..3c1bc35e2 --- /dev/null +++ b/app/jobs/registrant_change_expired_email_job.rb @@ -0,0 +1,20 @@ +class RegistrantChangeExpiredEmailJob < Que::Job + def run(domain_id) + domain = Domain.find(domain_id) + log(domain) + RegistrantChangeMailer.expired(domain: domain, + registrar: domain.registrar, + registrant: domain.registrant).deliver_now + end + + private + + def log(domain) + message = "Send RegistrantChangeMailer#expired email for domain #{domain.name} (##{domain.id}) to #{domain.new_registrant_email}" + logger.info(message) + end + + def logger + Rails.logger + end +end diff --git a/app/jobs/registrant_change_notice_email_job.rb b/app/jobs/registrant_change_notice_email_job.rb new file mode 100644 index 000000000..a0bf26c52 --- /dev/null +++ b/app/jobs/registrant_change_notice_email_job.rb @@ -0,0 +1,22 @@ +class RegistrantChangeNoticeEmailJob < Que::Job + def run(domain_id, new_registrant_id) + domain = Domain.find(domain_id) + new_registrant = Registrant.find(new_registrant_id) + log(domain, new_registrant) + RegistrantChangeMailer.notice(domain: domain, + registrar: domain.registrar, + current_registrant: domain.registrant, + new_registrant: new_registrant).deliver_now + end + + private + + def log(domain, new_registrant) + message = "Send RegistrantChangeMailer#notice email for domain #{domain.name} (##{domain.id}) to #{new_registrant.email}" + logger.info(message) + end + + def logger + Rails.logger + end +end diff --git a/app/mailers/.keep b/app/mailers/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/mailers/domain_delete_mailer.rb b/app/mailers/domain_delete_mailer.rb new file mode 100644 index 000000000..c8703e0ac --- /dev/null +++ b/app/mailers/domain_delete_mailer.rb @@ -0,0 +1,24 @@ +class DomainDeleteMailer < ApplicationMailer + def confirm(domain:, registrar:, registrant:) + @domain = DomainPresenter.new(domain: domain, view: view_context) + @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context) + @confirm_url = confirm_url(domain) + + subject = default_i18n_subject(domain_name: domain.name) + mail(to: registrant.email, subject: subject) + end + + def forced(domain:, registrar:, registrant:) + @domain = DomainPresenter.new(domain: domain, view: view_context) + @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context) + @registrant = RegistrantPresenter.new(registrant: registrant, view: view_context) + + mail(to: domain.primary_contact_emails) + end + + private + + def confirm_url(domain) + registrant_domain_delete_confirm_url(domain, token: domain.registrant_verification_token) + end +end diff --git a/app/mailers/domain_expire_mailer.rb b/app/mailers/domain_expire_mailer.rb new file mode 100644 index 000000000..ecbd8ee3d --- /dev/null +++ b/app/mailers/domain_expire_mailer.rb @@ -0,0 +1,38 @@ +class DomainExpireMailer < ApplicationMailer + def expired(domain:, registrar:) + @domain = domain_presenter(domain: domain) + @registrar = registrar_presenter(registrar: registrar) + + recipient = filter_invalid_emails(emails: domain.primary_contact_emails, domain: domain) + subject = default_i18n_subject(domain_name: domain.name) + + logger.info("Send DomainExpireMailer#expired email for domain #{domain.name} (##{domain.id})" \ + " to #{recipient.join(', ')}") + + mail(to: recipient, subject: subject) + end + + private + + def domain_presenter(domain:) + DomainPresenter.new(domain: domain, view: view_context) + end + + def registrar_presenter(registrar:) + RegistrarPresenter.new(registrar: registrar, view: view_context) + end + + # Needed because there are invalid emails in the database, which have been imported from legacy app + def filter_invalid_emails(emails:, domain:) + emails.select do |email| + valid = EmailValidator.new(email).valid? + + unless valid + logger.info("Unable to send DomainExpireMailer#expired email for domain #{domain.name} (##{domain.id})" \ + " to invalid recipient #{email}") + end + + valid + end + end +end diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index afdfe89fc..bb8c55492 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -1,15 +1,6 @@ class DomainMailer < ApplicationMailer include Que::Mailer - def pending_update_request_for_old_registrant(params) - compose_from(params) - end - - def pending_update_notification_for_new_registrant(params) - compose_from(params) - end - - def registrant_updated_notification_for_new_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver) @domain = Domain.find_by(id: domain_id) return unless @domain @@ -39,39 +30,6 @@ class DomainMailer < ApplicationMailer name: @domain.name)} [#{@domain.name}]") end - def pending_update_rejected_notification_for_new_registrant(params) - compose_from(params) - end - - def pending_update_expired_notification_for_new_registrant(params) - compose_from(params) - end - - def pending_deleted(domain_id, old_registrant_id, should_deliver) - @domain = Domain.find_by(id: domain_id) - @old_registrant = Registrant.find(old_registrant_id) - return unless @domain - return if delivery_off?(@domain, should_deliver) - - 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 - - confirm_path = "#{ENV['registrant_url']}/registrant/domain_delete_confirms" - @verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}" - - return if whitelist_blocked?(@old_registrant.email) - mail(to: format(@old_registrant.email), - subject: "#{I18n.t(:domain_pending_deleted_subject, - name: @domain.name)} [#{@domain.name}]") - end - def pending_delete_rejected_notification(domain_id, should_deliver) @domain = Domain.find_by(id: domain_id) return unless @domain @@ -117,29 +75,6 @@ class DomainMailer < ApplicationMailer name: @domain.name)} [#{@domain.name}]") end - def expiration_reminder(domain_id) - @domain = Domain.find_by(id: domain_id) - return if @domain.nil? || !@domain.statuses.include?(DomainStatus::EXPIRED) || whitelist_blocked?(@domain.registrant.email) - return if whitelist_blocked?(@domain.registrant.email) - - mail(to: format(@domain.registrant.email), - subject: "#{I18n.t(:expiration_remind_subject, - name: @domain.name)} [#{@domain.name}]") - end - - - def force_delete(domain_id, should_deliver) - @domain = Domain.find_by(id: domain_id) - return if delivery_off?(@domain, should_deliver) - emails = ([@domain.registrant.email] + @domain.admin_contacts.map { |x| format(x.email) }).uniq - return if whitelist_blocked?(emails) - - formatted_emails = emails.map { |x| format(x) } - mail(to: formatted_emails, - subject: "#{I18n.t(:force_delete_subject)}" - ) - end - private # app/models/DomainMailModel provides the data for mail that can be composed_from # which ensures that values of objects are captured when they are valid, not later when this method is executed diff --git a/app/mailers/registrant_change_mailer.rb b/app/mailers/registrant_change_mailer.rb new file mode 100644 index 000000000..4523834e0 --- /dev/null +++ b/app/mailers/registrant_change_mailer.rb @@ -0,0 +1,45 @@ +class RegistrantChangeMailer < ApplicationMailer + def confirm(domain:, registrar:, current_registrant:, new_registrant:) + @domain = DomainPresenter.new(domain: domain, view: view_context) + @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context) + @new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context) + @confirm_url = confirm_url(domain) + + subject = default_i18n_subject(domain_name: domain.name) + mail(to: current_registrant.email, subject: subject) + end + + def notice(domain:, registrar:, current_registrant:, new_registrant:) + @domain = DomainPresenter.new(domain: domain, view: view_context) + @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context) + @current_registrant = RegistrantPresenter.new(registrant: current_registrant, view: view_context) + @new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context) + + subject = default_i18n_subject(domain_name: domain.name) + mail(to: new_registrant.email, subject: subject) + end + + def rejected(domain:, registrar:, registrant:) + @domain = DomainPresenter.new(domain: domain, view: view_context) + @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context) + @registrant = RegistrantPresenter.new(registrant: registrant, view: view_context) + + subject = default_i18n_subject(domain_name: domain.name) + mail(to: domain.new_registrant_email, subject: subject) + end + + def expired(domain:, registrar:, registrant:) + @domain = DomainPresenter.new(domain: domain, view: view_context) + @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context) + @registrant = RegistrantPresenter.new(registrant: registrant, view: view_context) + + subject = default_i18n_subject(domain_name: domain.name) + mail(to: domain.new_registrant_email, subject: subject) + end + + private + + def confirm_url(domain) + registrant_domain_update_confirm_url(domain, token: domain.registrant_verification_token) + end +end diff --git a/app/models/concerns/domain/expirable.rb b/app/models/concerns/domain/expirable.rb new file mode 100644 index 000000000..be1928826 --- /dev/null +++ b/app/models/concerns/domain/expirable.rb @@ -0,0 +1,31 @@ +module Concerns::Domain::Expirable + extend ActiveSupport::Concern + + included do + alias_attribute :expire_time, :valid_to + end + + class_methods do + def expired + where("#{attribute_alias(:expire_time)} <= ?", Time.zone.now) + end + end + + def registered? + !expired? + end + + def expired? + expire_time <= Time.zone.now + end + + def expirable? + return false if expire_time > Time.zone.now + + if statuses.include?(DomainStatus::EXPIRED) && outzone_at.present? && delete_at.present? + return false + end + + true + end +end diff --git a/app/models/contact.rb b/app/models/contact.rb index 50e78ef54..822394d22 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -250,6 +250,13 @@ class Contact < ActiveRecord::Base kit.to_pdf end + def names + pluck(:name) + end + + def emails + pluck(:email) + end end def roid diff --git a/app/models/domain.rb b/app/models/domain.rb index 0b3f6cdea..c9c301bd2 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -3,12 +3,19 @@ class Domain < ActiveRecord::Base include UserEvents include Versions # version/domain_version.rb include Statuses + include Concerns::Domain::Expirable + has_paper_trail class_name: "DomainVersion", meta: { children: :children_log } attr_accessor :roles attr_accessor :legal_document_id + alias_attribute :on_hold_time, :outzone_at + alias_attribute :force_delete_time, :force_delete_at + alias_attribute :outzone_time, :outzone_at + alias_attribute :delete_time, :delete_at + # TODO: whois requests ip whitelist for full info for own domains and partial info for other domains # TODO: most inputs should be trimmed before validatation, probably some global logic? @@ -206,11 +213,6 @@ class Domain < ActiveRecord::Base DomainCron.send(__method__) end - def self.start_expire_period - ActiveSupport::Deprecation.instance.deprecation_warning(DomainCron, __method__) - DomainCron.send(__method__) - end - def self.start_redemption_grace_period ActiveSupport::Deprecation.instance.deprecation_warning(DomainCron, __method__) DomainCron.send(__method__) @@ -284,16 +286,6 @@ class Domain < ActiveRecord::Base domain_transfers.find_by(status: DomainTransfer::PENDING) end - def expirable? - return false if valid_to > Time.zone.now - - if statuses.include?(DomainStatus::EXPIRED) && outzone_at.present? && delete_at.present? - return false - end - - true - end - def server_holdable? return false if statuses.include?(DomainStatus::SERVER_HOLD) return false if statuses.include?(DomainStatus::SERVER_MANUAL_INZONE) @@ -310,7 +302,7 @@ class Domain < ActiveRecord::Base def renewable? if Setting.days_to_renew_domain_before_expire != 0 # if you can renew domain at days_to_renew before domain expiration - if (valid_to.to_date - Date.today) + 1 > Setting.days_to_renew_domain_before_expire + if (expire_time.to_date - Date.today) + 1 > Setting.days_to_renew_domain_before_expire return false end end @@ -387,10 +379,10 @@ class Domain < ActiveRecord::Base new_registrant_email = registrant.email new_registrant_name = registrant.name - send_mail :pending_update_request_for_old_registrant - send_mail :pending_update_notification_for_new_registrant + RegistrantChangeConfirmEmailJob.enqueue(id, new_registrant_id) + RegistrantChangeNoticeEmailJob.enqueue(id, new_registrant_id) - reload # revert back to original + reload self.pending_json = pending_json_cache self.registrant_verification_token = token @@ -402,8 +394,8 @@ class Domain < ActiveRecord::Base pending_json['new_registrant_name'] = new_registrant_name # This pending_update! method is triggered by before_update - # Note, all before_save callbacks are excecuted before before_update, - # thus automatic statuses has already excectued by this point + # Note, all before_save callbacks are executed before before_update, + # thus automatic statuses has already executed by this point # and we need to trigger automatic statuses manually (second time). manage_automatic_statuses end @@ -449,7 +441,7 @@ class Domain < ActiveRecord::Base pending_delete_confirmation! save(validate: false) # should check if this did succeed - DomainMailer.pending_deleted(id, registrant_id_was, deliver_emails).deliver + DomainDeleteConfirmEmailJob.enqueue(id) end def cancel_pending_delete @@ -570,12 +562,15 @@ class Domain < ActiveRecord::Base end self.force_delete_at = (Time.zone.now + (Setting.redemption_grace_period.days + 1.day)).utc.beginning_of_day unless force_delete_at + transaction do save!(validate: false) registrar.messages.create!( body: I18n.t('force_delete_set_on_domain', domain: name) ) - DomainMailer.force_delete(id, true).deliver + + DomainDeleteForcedEmailJob.enqueue(id) + return true end false @@ -597,7 +592,7 @@ class Domain < ActiveRecord::Base end def set_graceful_expired - self.outzone_at = valid_to + self.class.expire_warning_period + self.outzone_at = expire_time + self.class.expire_warning_period self.delete_at = outzone_at + self.class.redemption_grace_period self.statuses |= [DomainStatus::EXPIRED] end @@ -627,7 +622,7 @@ class Domain < ActiveRecord::Base when DomainStatus::SERVER_MANUAL_INZONE # removal causes server hold to set self.outzone_at = Time.zone.now if self.force_delete_at.present? when DomainStatus::DomainStatus::EXPIRED # removal causes server hold to set - self.outzone_at = self.valid_to + 15.day + self.outzone_at = self.expire_time + 15.day when DomainStatus::DomainStatus::SERVER_HOLD # removal causes server hold to set self.outzone_at = nil end @@ -725,6 +720,33 @@ class Domain < ActiveRecord::Base DomainMailer.send(action, DomainMailModel.new(self).send(action)).deliver end + def admin_contact_names + admin_contacts.names + end + + def admin_contact_emails + admin_contacts.emails + end + + def tech_contact_names + tech_contacts.names + end + + def nameserver_hostnames + nameservers.hostnames + end + + def primary_contact_emails + (admin_contact_emails << registrant_email).uniq + end + + def new_registrant_email + pending_json['new_registrant_email'] + end + + def new_registrant_id + pending_json['new_registrant_id'] + end def self.to_csv CSV.generate do |csv| @@ -747,5 +769,13 @@ class Domain < ActiveRecord::Base def self.redemption_grace_period Setting.redemption_grace_period.days end + + def self.outzone_candidates + where("#{attribute_alias(:outzone_time)} < ?", Time.zone.now) + end + + def self.delete_candidates + where("#{attribute_alias(:delete_time)} < ?", Time.zone.now) + end end # rubocop: enable Metrics/ClassLength diff --git a/app/models/domain_cron.rb b/app/models/domain_cron.rb index 549e3b1da..b4da056a2 100644 --- a/app/models/domain_cron.rb +++ b/app/models/domain_cron.rb @@ -16,7 +16,7 @@ class DomainCron end count += 1 if domain.pending_update? - DomainMailer.pending_update_expired_notification_for_new_registrant(domain.id).deliver + RegistrantChangeExpiredEmailJob.enqueue(domain.id) end if domain.pending_delete? || domain.pending_delete_confirmation? DomainMailer.pending_delete_expired_notification(domain.id, true).deliver @@ -32,18 +32,24 @@ class DomainCron end def self.start_expire_period - STDOUT << "#{Time.zone.now.utc} - Expiring domains\n" unless Rails.env.test? - ::PaperTrail.whodunnit = "cron - #{__method__}" - domains = Domain.where('valid_to <= ?', Time.zone.now) + domains = Domain.expired marked = 0 real = 0 + domains.each do |domain| next unless domain.expirable? real += 1 domain.set_graceful_expired STDOUT << "#{Time.zone.now.utc} DomainCron.start_expire_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? - domain.save(validate: false) and marked += 1 + + send_time = domain.valid_to + Setting.expiration_reminder_mail.to_i.days + saved = domain.save(validate: false) + + if saved + DomainExpireEmailJob.enqueue(domain.id, run_at: send_time) + marked += 1 + end end STDOUT << "#{Time.zone.now.utc} - Successfully expired #{marked} of #{real} domains\n" unless Rails.env.test? @@ -53,10 +59,12 @@ class DomainCron STDOUT << "#{Time.zone.now.utc} - Setting server_hold to domains\n" unless Rails.env.test? ::PaperTrail.whodunnit = "cron - #{__method__}" - d = Domain.where('outzone_at <= ?', Time.zone.now) + + domains = Domain.outzone_candidates marked = 0 real = 0 - d.each do |domain| + + domains.each do |domain| next unless domain.server_holdable? real += 1 domain.statuses << DomainStatus::SERVER_HOLD @@ -96,16 +104,18 @@ class DomainCron c = 0 - Domain.where('delete_at <= ?', Time.zone.now.end_of_day.utc).each do |x| - next unless x.delete_candidateable? + domains = Domain.delete_candidates - x.statuses << DomainStatus::DELETE_CANDIDATE + domains.each do |domain| + next unless domain.delete_candidateable? + + domain.statuses << DomainStatus::DELETE_CANDIDATE # If domain successfully saved, add it to delete schedule - if x.save(validate: false) + if domain.save(validate: false) ::PaperTrail.whodunnit = "cron - #{__method__}" - DomainDeleteJob.enqueue(x.id, run_at: rand(((24*60) - (DateTime.now.hour * 60 + DateTime.now.minute))).minutes.from_now) - STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: job added by deleteCandidate status ##{x.id} (#{x.name})\n" unless Rails.env.test? + DomainDeleteJob.enqueue(domain.id, run_at: rand(((24*60) - (DateTime.now.hour * 60 + DateTime.now.minute))).minutes.from_now) + STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: job added by deleteCandidate status ##{domain.id} (#{domain.name})\n" unless Rails.env.test? c += 1 end end diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index d443d8783..3f92a3138 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -1,49 +1,11 @@ class DomainMailModel # Capture current values used in app/views/mailers/domain_mailer/* and app/mailers/domain_mailer will send later - + def initialize(domain) @domain = domain @params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id} end - def pending_update_request_for_old_registrant - registrant_old - subject(:pending_update_request_for_old_registrant_subject) - confirm_update - domain_info - compose - end - - def pending_update_notification_for_new_registrant - registrant # new registrant at this point - subject(:pending_update_notification_for_new_registrant_subject) - domain_info - compose - end - - - def pending_update_rejected_notification_for_new_registrant - registrant_pending - subject(:pending_update_rejected_notification_for_new_registrant_subject) - @params[:deliver_emails] = true # triggered from que - @params[:registrar_name] = @domain.registrar.name - compose - end - - def pending_update_expired_notification_for_new_registrant - registrant_pending - subject(:pending_update_expired_notification_for_new_registrant_subject) - domain_info - compose - end - - def pending_deleted - registrant - subject(:domain_pending_deleted_subject) - confirm_delete - compose - end - def pending_delete_rejected_notification registrant subject(:pending_delete_rejected_notification_subject) @@ -69,11 +31,11 @@ class DomainMailModel end private - + def registrant_old @params[:recipient] = format Registrant.find(@domain.registrant_id_was).email end - + def registrant @params[:recipient] = format @domain.registrant.email end @@ -83,7 +45,7 @@ class DomainMailModel @params[:new_registrant_name] = @domain.pending_json['new_registrant_name'] @params[:old_registrant_name] = @domain.registrant.name end - + # registrant and domain admin contacts def admins emails = ([@domain.registrant.email] + @domain.admin_contacts.map { |x| format(x.email) }) @@ -106,26 +68,22 @@ class DomainMailModel def confirm_update verification_url('domain_update_confirms') end - - def confirm_delete - verification_url('domain_delete_confirms') - end def compose @params end - + def verification_url(path) token = verification_token or return @params[:verification_url] = "#{ENV['registrant_url']}/registrant/#{path}/#{@domain.id}?token=#{token}" end - + def verification_token return warn_missing(:registrant_verification_token) if @domain.registrant_verification_token.blank? return warn_missing(:registrant_verification_asked_at) if @domain.registrant_verification_asked_at.blank? @domain.registrant_verification_token end - + def domain_info [:name, :registrar_name, :registrant_name, :registrant_ident, :registrant_email, @@ -143,7 +101,7 @@ class DomainMailModel warn_missing item nil end - + def warn_missing(item) warn_not_delivered "#{item.to_s} is missing for #{@domain.name}" end @@ -154,6 +112,6 @@ class DomainMailModel # Rails.logger.warn message nil end - + end diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 2feef25be..55590e70f 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -571,7 +571,6 @@ class Epp::Domain < Domain frame.css('delete').children.css('delete').attr('verified').to_s.downcase != 'yes' registrant_verification_asked!(frame.to_s, user_id) - self.deliver_emails = true # turn on email delivery for epp pending_delete! manage_automatic_statuses true # aka 1001 pending_delete diff --git a/app/models/nameserver.rb b/app/models/nameserver.rb index 7b4daab3d..fb56f1198 100644 --- a/app/models/nameserver.rb +++ b/app/models/nameserver.rb @@ -18,7 +18,7 @@ class Nameserver < ActiveRecord::Base before_validation :normalize_attributes before_validation :check_puny_symbols before_validation :check_label_length - + delegate :name, to: :domain, prefix: true def epp_code_map @@ -117,5 +117,9 @@ class Nameserver < ActiveRecord::Base # ignoring ips rel end + + def hostnames + pluck(:hostname) + end end end diff --git a/app/models/zonefile_setting.rb b/app/models/zonefile_setting.rb index 4a9656b7a..9f2b2b862 100644 --- a/app/models/zonefile_setting.rb +++ b/app/models/zonefile_setting.rb @@ -32,6 +32,10 @@ class ZonefileSetting < ActiveRecord::Base STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n" end + def self.origins + pluck(:origin) + end + def to_s origin end diff --git a/app/presenters/domain_presenter.rb b/app/presenters/domain_presenter.rb new file mode 100644 index 000000000..b09743c5e --- /dev/null +++ b/app/presenters/domain_presenter.rb @@ -0,0 +1,37 @@ +class DomainPresenter + delegate :name, :registrant_name, to: :domain + + def initialize(domain:, view:) + @domain = domain + @view = view + end + + def on_hold_date + view.l(domain.on_hold_time, format: :date) if domain.on_hold_time + end + + def delete_date + view.l(domain.delete_time, format: :date) if domain.delete_time + end + + def force_delete_date + view.l(domain.force_delete_time, format: :date) if domain.force_delete_time + end + + def admin_contact_names + domain.admin_contact_names.join(', ') + end + + def tech_contact_names + domain.tech_contact_names.join(', ') + end + + def nameserver_names + domain.nameserver_hostnames.join(', ') + end + + private + + attr_reader :domain + attr_reader :view +end diff --git a/app/presenters/registrant_presenter.rb b/app/presenters/registrant_presenter.rb new file mode 100644 index 000000000..f7fcb3094 --- /dev/null +++ b/app/presenters/registrant_presenter.rb @@ -0,0 +1,17 @@ +class RegistrantPresenter + delegate :name, :ident, :email, :priv?, :street, :city, to: :registrant + + def initialize(registrant:, view:) + @registrant = registrant + @view = view + end + + def country + + end + + private + + attr_reader :registrant + attr_reader :view +end diff --git a/app/presenters/registrar_presenter.rb b/app/presenters/registrar_presenter.rb new file mode 100644 index 000000000..1fe415feb --- /dev/null +++ b/app/presenters/registrar_presenter.rb @@ -0,0 +1,27 @@ +class RegistrarPresenter + def initialize(registrar:, view:) + @registrar = registrar + @view = view + end + + def name + registrar.name + end + + def email + registrar.email + end + + def phone + registrar.phone + end + + def url + registrar.url + end + + private + + attr_reader :registrar + attr_reader :view +end diff --git a/app/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb index be83f0835..427a330f3 100644 --- a/app/validators/domain_name_validator.rb +++ b/app/validators/domain_name_validator.rb @@ -12,9 +12,9 @@ class DomainNameValidator < ActiveModel::EachValidator return true unless value value = value.mb_chars.downcase.strip - origins = ZonefileSetting.pluck(:origin) + origins = ZonefileSetting.origins # if someone tries to register an origin domain, let this validation pass - # the error will be catched in blocked domains validator + # the error will be caught in blocked domains validator return true if origins.include?(value) general_domains = /(#{origins.join('|')})/ diff --git a/app/views/mailers/domain_mailer/pending_deleted.html.erb b/app/views/mailers/domain_delete_mailer/confirm.html.erb similarity index 74% rename from app/views/mailers/domain_mailer/pending_deleted.html.erb rename to app/views/mailers/domain_delete_mailer/confirm.html.erb index 6d0a47f57..e62890ed1 100644 --- a/app/views/mailers/domain_mailer/pending_deleted.html.erb +++ b/app/views/mailers/domain_delete_mailer/confirm.html.erb @@ -1,11 +1,14 @@ Tere

-Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja <%= @domain.registrar_name %> poole. +Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: + +<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %> +

Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan.

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.
-<%= link_to @verification_url, @verification_url %> +<%= link_to @confirm_url, @confirm_url %>

Lugupidamisega
Eesti Interneti Sihtasutus @@ -14,10 +17,13 @@ Eesti Interneti Sihtasutus

Hi,

-Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. Incase of problems please contact your registrar <%= @domain.registrar_name %>. +Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. Incase of problems please contact your registrar: + +<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %> +

To confirm the update please visit this website, once again review the data and press approve:
-<%= link_to @verification_url, @verification_url %> +<%= link_to @confirm_url, @confirm_url %>

The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automatically rejected if it is not approved nor rejected before.

diff --git a/app/views/mailers/domain_mailer/pending_deleted.text.erb b/app/views/mailers/domain_delete_mailer/confirm.text.erb similarity index 76% rename from app/views/mailers/domain_mailer/pending_deleted.text.erb rename to app/views/mailers/domain_delete_mailer/confirm.text.erb index cc49cbbb0..7d2e1cb05 100644 --- a/app/views/mailers/domain_mailer/pending_deleted.text.erb +++ b/app/views/mailers/domain_delete_mailer/confirm.text.erb @@ -1,11 +1,13 @@ Tere -Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja <%= @domain.registrar_name %> poole. +Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: + +<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %> Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan. 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. -<%= link_to @verification_url, @verification_url %> +<%= @confirm_url %> Lugupidamisega Eesti Interneti Sihtasutus @@ -14,10 +16,12 @@ Eesti Interneti Sihtasutus Hi, -Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. Incase of problems please contact your registrar <%= @domain.registrar_name %>. +Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. In case of problems please contact your registrar: + +<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %> To confirm the update please visit this website, once again review the data and press approve: -<%= link_to @verification_url, @verification_url %> +<%= @confirm_url %> The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automatically rejected if it is not approved nor rejected before. diff --git a/app/views/mailers/domain_mailer/force_delete.html.erb b/app/views/mailers/domain_delete_mailer/forced.html.erb similarity index 50% rename from app/views/mailers/domain_mailer/force_delete.html.erb rename to app/views/mailers/domain_delete_mailer/forced.html.erb index adb8a5f70..4b984bf57 100644 --- a/app/views/mailers/domain_mailer/force_delete.html.erb +++ b/app/views/mailers/domain_delete_mailer/forced.html.erb @@ -1,7 +1,4 @@ -
-

Eesti Interneti Sihtasutus

-
-
@@ -11,56 +8,65 @@

.ee domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed:

-

Registreerija nimi: <%= @domain.registrant %>
-Registrikood: <%= @domain.registrant.try(:ident) %>

+

Registreerija nimi: <%= @registrant.name %>
+Registrikood: <%= @registrant.ident %>

-

Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et juriidiline isik registrikoodiga <%= @domain.registrant.try(:ident) %> on äriregistrist kustutatud.

+

Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et juriidiline isik registrikoodiga <%= @registrant.ident %> on äriregistrist kustutatud.

Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registreerijaks, siis algatas EIS <%= l(Time.zone.now, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.4 domeeni <%= @domain.name %> suhtes 30 päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks.

-

Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @domain.registrar %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale esimesel võimalusel.

+

Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @registrar.name %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale esimesel võimalusel.

-

Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :date) %> juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist “kes ees, see mees” põhimõttel uuesti registreerida.

+

Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= @domain.force_delete_date %> juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist “kes ees, see mees” põhimõttel uuesti registreerida.

-

Lisaküsimuste korral võtke palun ühendust oma registripidajaga <%= @domain.registrar %>. Registripidajate kontaktid leiate aadressilt http://www.internet.ee/registripidajad



+

Lisaküsimuste korral võtke palun ühendust oma registripidajaga:

+<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %> +
Dear contact of <%= @domain.name %> domain

The following details for domain name <%= @domain.name %> have been entered into the .ee domain registry:

-

Registrant's name: <%= @domain.registrant %>
-Registry code: <%= @domain.registrant.try(:ident) %>

+

Registrant's name: <%= @registrant.name %>
+Registry code: <%= @registrant.ident %>

-

Estonian Internet Foundation (EIS) has learned that the legal person with registry code <%= @domain.registrant.try(:ident) %> has been deleted from the Business Registry.

+

Estonian Internet Foundation (EIS) has learned that the legal person with registry code <%= @registrant.ident %> has been deleted from the Business Registry.

As a terminated legal person cannot be the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(Time.zone.now, format: :date) %> according to the Domain Regulation (http://www.internet.ee/domains/), using the 30-day delete procedure. The domain will remain available on the Internet during the delete procedure.

-

According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @domain.registrar %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible.

+

According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @registrar.name %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible.

-

If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours on <%= l(@domain.force_delete_at, format: :date) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis.

+

If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours on <%= @domain.force_delete_date %>. After deletion it is possible to reregister the domain on a "first come, first served" basis.

-

Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/registrars/



+

Should you have additional questions, please contact your registrar:

+<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %> +
Уважаемое контактное лицо домена <%= @domain.name %>

В регистр доменов Целевого учреждения Eesti Internet (EIS) внесены следующие данные относительно домена <%= @domain.name %>:

-

Имя регистранта: <%= @domain.registrant %>
-Регистрационный код: <%= @domain.registrant.try(:ident) %>

+

Имя регистранта: <%= @registrant.name %>
+Регистрационный код: <%= @registrant.ident %>

-

EIS стало известно, что юридическое лицо с регистрационным кодом <%= @domain.registrant.try(:ident) %> удалено из коммерческого реестра.

+

EIS стало известно, что юридическое лицо с регистрационным кодом <%= @registrant.ident %> удалено из коммерческого реестра.

Поскольку прекратившее деятельность юридическое лицо не может являться регистрантом домена, то согласно пункту 6.4 Правил домена (http://www.internet.ee/domeny/) EIS <%= l(Time.zone.now, format: :date) %> инициировало удаление домена <%= @domain.name %> с применением 30-дневной процедуры удаления. На протяжении процесса удаления домен остается доступным в Интернете.

-

Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @domain.registrar %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления.

+

Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @registrar.name %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления.

-

Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :date) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел".

+

Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= @domain.force_delete_date %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел".

-

Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/registratory/



+

Просим обратиться к своему регистратору:

+ +<%= render 'mailers/shared/registrar/registrar.ru.html', registrar: @registrar %> + + +

@@ -73,4 +79,4 @@ Registry code: <%= @domain.registrant.try(:ident) %>

+
diff --git a/app/views/mailers/domain_delete_mailer/forced.text.erb b/app/views/mailers/domain_delete_mailer/forced.text.erb new file mode 100644 index 000000000..688c5d445 --- /dev/null +++ b/app/views/mailers/domain_delete_mailer/forced.text.erb @@ -0,0 +1,67 @@ +Lugupeetud domeeni <%= @domain.name %> kontaktisik + +.ee domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed: + +Registreerija nimi: <%= @registrant.name %> +Registrikood: <%= @registrant.ident %> + +Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et juriidiline isik registrikoodiga <%= @registrant.ident %> on äriregistrist kustutatud. + +Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registreerijaks, siis algatas EIS <%= l(Time.zone.now, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.4 domeeni <%= @domain.name %> suhtes 30 päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks. + +Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @registrar.name %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale esimesel võimalusel. + +Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= @domain.force_delete_date %> juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist "kes ees, see mees" põhimõttel uuesti registreerida. + +Lisaküsimuste korral võtke palun ühendust oma registripidajaga: + +<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %> + + + +Dear contact of <%= @domain.name %> domain + +The following details for domain name <%= @domain.name %> have been entered into the .ee domain registry: + +Registrant's name: <%= @registrant.name %> +Registry code: <%= @registrant.ident %> + +Estonian Internet Foundation (EIS) has learned that the legal person with registry code <%= @registrant.ident %> has been deleted from the Business Registry. + +As a terminated legal person cannot be the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(Time.zone.now, format: :date) %> according to the Domain Regulation (http://www.internet.ee/domains/), using the 30-day delete procedure. The domain will remain available on the Internet during the delete procedure. + +According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @registrar.name %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible. + +If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours on <%= @domain.force_delete_date %>. After deletion it is possible to reregister the domain on a "first come, first served" basis. + +Should you have additional questions, please contact your registrar: + +<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %> + + +Уважаемое контактное лицо домена <%= @domain.name %> + +В регистр доменов Целевого учреждения Eesti Internet (EIS) внесены следующие данные относительно домена <%= @domain.name %>: + +Имя регистранта: <%= @registrant.name %> +Регистрационный код: <%= @registrant.ident %> + +EIS стало известно, что юридическое лицо с регистрационным кодом <%= @registrant.ident %> удалено из коммерческого реестра. + +Поскольку прекратившее деятельность юридическое лицо не может являться регистрантом домена, то согласно пункту 6.4 Правил домена (http://www.internet.ee/domeny) EIS <%= l(Time.zone.now, format: :date) %> инициировало удаление домена <%= @domain.name %> с применением 30-дневной процедуры удаления. На протяжении процесса удаления домен остается доступным в Интернете. + +Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @registrar.name %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления. + +Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= @domain.force_delete_date %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел". + +Просим обратиться к своему регистратору: + +<%= render 'mailers/shared/registrar/registrar.ru.text', registrar: @registrar %> + + +Lugupidamisega, +Best Regards, +С уважением, +--- +Eesti Interneti Sihtasutus +Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/expiration_reminder.html.erb b/app/views/mailers/domain_expire_mailer/expired.html.erb similarity index 51% rename from app/views/mailers/domain_mailer/expiration_reminder.html.erb rename to app/views/mailers/domain_expire_mailer/expired.html.erb index 9404838ae..d9a96b50a 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.html.erb +++ b/app/views/mailers/domain_expire_mailer/expired.html.erb @@ -1,17 +1,19 @@ Domeen <%= @domain.name %> on aegunud
Lugupeetud .ee domeeni kasutaja

-Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :date) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :date) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. +Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= @domain.on_hold_date %> internetis kättesaadav. Alates <%= @domain.delete_date %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele.

-Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @domain.registrar.name %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. +Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja: +<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>

Domeeni <%= @domain.name %> kohta on registris järgmised andmed:

Registreerija: <%= @domain.registrant_name %>
-Halduskontakt: <%= @domain.admin_contacts.map(&:name).join ', ' %>
-Tehniline kontakt: <%= @domain.tech_contacts.map(&:name).join ', ' %>
-Registripidaja: <%= @domain.registrar.name %>
-Nimeserverid: <%= @domain.nameservers.join(', ') %>
+Halduskontakt: <%= @domain.admin_contact_names %>
+Tehniline kontakt: <%= @domain.tech_contact_names %>
+Nimeserverid: <%= @domain.nameserver_names %>
+ + Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. <%= ENV['registrant_url'] %>.


Lugupidamisega
@@ -22,17 +24,19 @@ Eesti Interneti Sihtasutus The <%= @domain.name %> domain has expired
Dear user of .ee domain,

-The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :date) %>. From <%= l(@domain.delete_at, format: :date) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. +The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= @domain.on_hold_date %>. From <%= @domain.delete_date %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis.

-To renew the domain registration, please contact your registrar <%= @domain.registrar.name %>. You can find the registrar's contacts at http://internet.ee/registrars. +To renew the domain registration, please contact your registrar: +<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>

The following data for the <%= @domain.name %> domain have been entered into the registry:

Registrant: <%= @domain.registrant_name %>
-Administrative contact: <%= @domain.admin_contacts.map(&:name).join ', ' %>
-Technical contact: <%= @domain.tech_contacts.map(&:name).join ', ' %>
-Registrar: <%= @domain.registrar.name %>
-Name servers: <%= @domain.nameservers.join(', ') %>
+Administrative contact: <%= @domain.admin_contact_names %>
+Technical contact: <%= @domain.tech_contact_names %>
+Name servers: <%= @domain.nameserver_names %>
+ + You can find an overview of all your domains at the registrant's portal. <%= ENV['registrant_url'] %>.


Best Regards,
@@ -43,18 +47,27 @@ Estonian Internet Foundation Домен <%= @domain.name %> устарел
Уважаемый пользователь домена .ee

-Доменное имя <%= @domain.name %> устарело и с <%= l(@domain.outzone_at, format: :date) %> недоступно в Интернете. С <%= l(@domain.delete_at, format: :date) %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". + +Доменное имя <%= @domain.name %> устарело и с <%= @domain.on_hold_date %> недоступно в Интернете. С <%= @domain.delete_date %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". +

-Для продления регистрации домена просим обратиться к своему регистратору <%= @domain.registrar.name %>. Контактные данные регистраторов можно найти по адресу http://internet.ee/registratory. + +Для продления регистрации домена просим обратиться к своему регистратору: +<%= render 'mailers/shared/registrar/registrar.ru.html', registrar: @registrar %>

+ Относительно домена <%= @domain.name %> в реестр внесены следующие данные:

+ Регистрант: <%= @domain.registrant_name %>
-Административный контакт: <%= @domain.admin_contacts.map(&:name).join ', ' %>
-Технический контакт: <%= @domain.tech_contacts.map(&:name).join ', ' %>
-Регистратор: <%= @domain.registrar.name %>
-Серверы доменных имен: <%= @domain.nameservers.join(', ') %>
+Административный контакт: <%= @domain.admin_contact_names %>
+Технический контакт: <%= @domain.tech_contact_names %>
+Серверы доменных имен: <%= @domain.nameserver_names %>
+ + Обзор всех связанных с Вами доменов можете получить на портале регистранта. <%= ENV['registrant_url'] %>.
+

+ С наилучшими пожеланиями
Целевое учреждение Eesti Internet diff --git a/app/views/mailers/domain_expire_mailer/expired.text.erb b/app/views/mailers/domain_expire_mailer/expired.text.erb new file mode 100644 index 000000000..ab0ba5a14 --- /dev/null +++ b/app/views/mailers/domain_expire_mailer/expired.text.erb @@ -0,0 +1,66 @@ +Domeen <%= @domain.name %> on aegunud +Lugupeetud .ee domeeni kasutaja + +Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= @domain.on_hold_date %> internetis kättesaadav. Alates <%= @domain.delete_date %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. + +Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja: + +<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %> + +Domeeni <%= @domain.name %> kohta on registris järgmised andmed: + +Registreerija: <%= @domain.registrant_name %> +Halduskontakt: <%= @domain.admin_contact_names %> +Tehniline kontakt: <%= @domain.tech_contact_names %> +Nimeserverid: <%= @domain.nameserver_names %> + +Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. <%= ENV['registrant_url'] %>. + +Parimate soovidega +Eesti Interneti Sihtasutus + +-------------------------------------- + +The <%= @domain.name %> domain has expired +Dear user of .ee domain, + +The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= @domain.on_hold_date %>. From <%= @domain.delete_date %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. + +To renew the domain registration, please contact your registrar: + +<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %> + +The following data for the <%= @domain.name %> domain have been entered into the registry: + +Registrant: <%= @domain.registrant_name %> +Administrative contact: <%= @domain.admin_contact_names %> +Technical contact: <%= @domain.tech_contact_names %> +Name servers: <%= @domain.nameserver_names %> + +You can find an overview of all your domains at the registrant's portal. <%= ENV['registrant_url'] %>. + +Best Regards, +Estonian Internet Foundation + +-------------------------------------- + +Домен <%= @domain.name %> устарел +Уважаемый пользователь домена .ee + +Доменное имя <%= @domain.name %> устарело и с <%= @domain.on_hold_date %> недоступно в Интернете. С <%= @domain.delete_date %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". + +Для продления регистрации домена просим обратиться к своему регистратору: + +<%= render 'mailers/shared/registrar/registrar.ru.text', registrar: @registrar %> + +Относительно домена <%= @domain.name %> в реестр внесены следующие данные: + +Регистрант: <%= @domain.registrant_name %> +Административный контакт: <%= @domain.admin_contact_names %> +Технический контакт: <%= @domain.tech_contact_names %> +Серверы доменных имен: <%= @domain.nameserver_names %> + +Обзор всех связанных с Вами доменов можете получить на портале регистранта. <%= ENV['registrant_url'] %>. + +С наилучшими пожеланиями +Целевое учреждение Eesti Internet diff --git a/app/views/mailers/domain_mailer/expiration_reminder.text.erb b/app/views/mailers/domain_mailer/expiration_reminder.text.erb deleted file mode 100644 index 5148df211..000000000 --- a/app/views/mailers/domain_mailer/expiration_reminder.text.erb +++ /dev/null @@ -1,60 +0,0 @@ -Domeen <%= @domain.name %> on aegunud -Lugupeetud .ee domeeni kasutaja - -Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :date) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :date) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. - -Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @domain.registrar.name %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. - -Domeeni <%= @domain.name %> kohta on registris järgmised andmed: - -Registreerija: <%= @domain.registrant_name %> -Halduskontakt: <%= @domain.admin_contacts.map(&:name).join ', ' %> -Tehniline kontakt: <%= @domain.tech_contacts.map(&:name).join ', ' %> -Registripidaja: <%= @domain.registrar.name %> -Nimeserverid: <%= @domain.nameservers.join(', ') %> -Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. <%= ENV['registrant_url'] %>. - -Parimate soovidega -Eesti Interneti Sihtasutus - --------------------------------------- - -The <%= @domain.name %> domain has expired -Dear user of .ee domain, - -The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :date) %>. From <%= l(@domain.delete_at, format: :date) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. - -To renew the domain registration, please contact your registrar <%= @domain.registrar.name %>. You can find the registrar's contacts at http://internet.ee/registrars. - -The following data for the <%= @domain.name %> domain have been entered into the registry: - -Registrant: <%= @domain.registrant_name %> -Administrative contact: <%= @domain.admin_contacts.map(&:name).join ', ' %> -Technical contact: <%= @domain.tech_contacts.map(&:name).join ', ' %> -Registrar: <%= @domain.registrar.name %> -Name servers: <%= @domain.nameservers.join(', ') %> -You can find an overview of all your domains at the registrant's portal. <%= ENV['registrant_url'] %>. - -Best Regards, -Estonian Internet Foundation - --------------------------------------- - -Домен <%= @domain.name %> устарел -Уважаемый пользователь домена .ee - -Доменное имя <%= @domain.name %> устарело и с <%= l(@domain.outzone_at, format: :date) %> недоступно в Интернете. С <%= l(@domain.delete_at, format: :date) %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". - -Для продления регистрации домена просим обратиться к своему регистратору <%= @domain.registrar.name %>. Контактные данные регистраторов можно найти по адресу http://internet.ee/registratory. - -Относительно домена <%= @domain.name %> в реестр внесены следующие данные: - -Регистрант: <%= @domain.registrant_name %> -Административный контакт: <%= @domain.admin_contacts.map(&:name).join ', ' %> -Технический контакт: <%= @domain.tech_contacts.map(&:name).join ', ' %> -Регистратор: <%= @domain.registrar.name %> -Серверы доменных имен: <%= @domain.nameservers.join(', ') %> -Обзор всех связанных с Вами доменов можете получить на портале регистранта. <%= ENV['registrant_url'] %>. - -С наилучшими пожеланиями -Целевое учреждение Eesti Internet diff --git a/app/views/mailers/domain_mailer/force_delete.text.erb b/app/views/mailers/domain_mailer/force_delete.text.erb deleted file mode 100644 index 12f3af85f..000000000 --- a/app/views/mailers/domain_mailer/force_delete.text.erb +++ /dev/null @@ -1,63 +0,0 @@ -Lugupeetud domeeni <%= @domain.name %> kontaktisik - -.ee domeeniregistrisse on domeeni <%= @domain.name %> kohta kantud järgmised andmed: - -Registreerija nimi: <%= @domain.registrant %> -Registrikood: <%= @domain.registrant.try(:ident) %> - -Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et juriidiline isik registrikoodiga <%= @domain.registrant.try(:ident) %> on äriregistrist kustutatud. - -Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registreerijaks, siis algatas EIS <%= l(Time.zone.now, format: :date) %> vastavalt Domeenireeglite (http://www.internet.ee/domeenid/) punktile 6.4 domeeni <%= @domain.name %> suhtes 30 päeva pikkuse kustutusmenetluse. Kustutamise käigus jääb domeen internetis kättesaadavaks. - -Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @domain.registrar %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleb esitada Registripidajale esimesel võimalusel. - -Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :date) %> juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist "kes ees, see mees" põhimõttel uuesti registreerida. - -Lisaküsimuste korral võtke palun ühendust oma registripidajaga <%= @domain.registrar %>. Registripidajate kontaktid leiate aadressilt http://www.internet.ee/registripidajad/ - - - -Dear contact of <%= @domain.name %> domain - -The following details for domain name <%= @domain.name %> have been entered into the .ee domain registry: - -Registrant's name: <%= @domain.registrant %> -Registry code: <%= @domain.registrant.try(:ident) %> - -Estonian Internet Foundation (EIS) has learned that the legal person with registry code <%= @domain.registrant.try(:ident) %> has been deleted from the Business Registry. - -As a terminated legal person cannot be the registrant of a domain, the EIS started the deletion process of <%= @domain.name %> domain on <%= l(Time.zone.now, format: :date) %> according to the Domain Regulation (http://www.internet.ee/domains/), using the 30-day delete procedure. The domain will remain available on the Internet during the delete procedure. - -According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @domain.registrar %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible. - -If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours on <%= l(@domain.force_delete_at, format: :date) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis. - -Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/registrars/ - - - -Уважаемое контактное лицо домена <%= @domain.name %> - -В регистр доменов Целевого учреждения Eesti Internet (EIS) внесены следующие данные относительно домена <%= @domain.name %>: - -Имя регистранта: <%= @domain.registrant %> -Регистрационный код: <%= @domain.registrant.try(:ident) %> - -EIS стало известно, что юридическое лицо с регистрационным кодом <%= @domain.registrant.try(:ident) %> удалено из коммерческого реестра. - -Поскольку прекратившее деятельность юридическое лицо не может являться регистрантом домена, то согласно пункту 6.4 Правил домена (http://www.internet.ee/domeny) EIS <%= l(Time.zone.now, format: :date) %> инициировало удаление домена <%= @domain.name %> с применением 30-дневной процедуры удаления. На протяжении процесса удаления домен остается доступным в Интернете. - -Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @domain.registrar %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления. - -Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :date) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел". - -Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/registratory - - - -Lugupidamisega, -Best Regards, -С уважением, ---- -Eesti Interneti Sihtasutus -Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb deleted file mode 100644 index 800ff33e1..000000000 --- a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -Tere -

-Domeeni <%= @params[:name] %> registreerija <%= @params[:registrant_name] %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @params[:name] %> registreerija vahetus on sellest tulenevalt tühistatud. -

-Küsimuste korral palun võtke ühendust oma registripidajaga <%= @params[:registrar_name] %>. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. -

-Lugupidamisega
-Eesti Interneti Sihtasutus -

-
-

-Hi, -

-Domain registrant change request has been expired for the domain <%= @params[:name] %>. -

-Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions. You can find the registrar's contacts at http://internet.ee/registrars. -

-Best Regards,
-Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb deleted file mode 100644 index 88ddefe9d..000000000 --- a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb +++ /dev/null @@ -1,19 +0,0 @@ -Tere - -Domeeni <%= @params[:name] %> registreerija <%= @params[:registrant_name] %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @params[:name] %> registreerija vahetus on sellest tulenevalt tühistatud. - -Küsimuste korral palun võtke ühendust oma registripidajaga <%= @params[:registrar_name] %>. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. - -Lugupidamisega -Eesti Interneti Sihtasutus - --------------------------------------- - -Hi, - -Domain registrant change request has been expired for the domain <%= @params[:name] %>. - -Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions. You can find the registrar's contacts at http://internet.ee/registrars. - -Best Regards, -Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb deleted file mode 100644 index a58aaef12..000000000 --- a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb +++ /dev/null @@ -1,53 +0,0 @@ -Tere -

-Registripidaja <%= @params[:registrar_name] %> vahendusel on algatatud <%= @params[:name] %> domeeni omanikuvahetuse protseduur. -

-Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja <%= @params[:registrar_name] %> poole. -

-Uue registreerija andmed:
-Nimi: <%= @params[:registrant_name] %>
-<% if @params[:registrant_priv] %> - Isikukood: <%= @params[:registrant_ident] %>
-<% else %> - Äriregistrikood: <%= @params[:registrant_ident] %>
-<% end %> -Tänav: <%= @params[:registrant_street] %>
-Linn: <%= @params[:registrant_city] %>
-Riik: <%= @params[:registrant_country] %> -

-Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @params[:old_registrant_name] %> omanikuvahetuse tähtaegselt kinnitab. -

-Juhul kui <%= @params[:old_registrant_name] %> lükkab omanikuvahetuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. -

-Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. -

-Lugupidamisega
-Eesti Interneti Sihtasutus -

-
-

-Hi, -

-Registrant change process for the domain <%= @params[:name] %> has been started. -

-Please verify the details of the following change request. In case of problems contact your registrar <%= @params[:registrar_name] %> -

-New registrant:
-Name: <%= @params[:registrant_name] %>
-<% if @params[:registrant_priv] %> -Personal code: <%= @params[:registrant_ident] %>
-<% else %> -Business Registry code: <%= @params[:registrant_ident] %>
-<% end %> -Street: <%= @params[:registrant_street] %>
-City: <%= @params[:registrant_city] %>
-Country: <%= @params[:registrant_country] %> -

-The registrant change procedure will be completed only after the current registrant <%= @params[:old_registrant_name] %> has approved it. -

-Change request will be cancelled in case <%= @params[:old_registrant_name] %> rejects or does not approve it in <%= Setting.expire_pending_confirmation %> hours. -

-Please contact registrar <%= @params[:registrar_name] %> in case of questions. You can find the registrar's contacts at http://internet.ee/registrars. -

-Best Regards,
-Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb deleted file mode 100644 index 9c1a6aebe..000000000 --- a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb +++ /dev/null @@ -1,53 +0,0 @@ -Tere - -Registripidaja <%= @params[:registrar_name] %> vahendusel on algatatud <%= @params[:name] %> domeeni omanikuvahetuse protseduur. - -Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja <%= @params[:registrar_name] %> poole. - -Uue registreerija andmed: -Nimi: <%= @params[:registrant_name] %> -<% if @params[:registrant_priv] %> -Isikukood: <%= @params[:registrant_ident] %> -<% else %> -Äriregistrikood: <%= @params[:registrant_ident] %> -<% end %> -Tänav: <%= @params[:registrant_street] %> -Linn: <%= @params[:registrant_city] %> -Riik: <%= @params[:registrant_country] %> - -Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @params[:old_registrant_name] %> omanikuvahetuse tähtaegselt kinnitab. - -Juhul kui <%= @params[:old_registrant_name] %> lükkab omanikuvahetuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. - -Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. - -Lugupidamisega -Eesti Interneti Sihtasutus - --------------------------------------- - -Hi, - -Registrant change process for the domain <%= @params[:name] %> has been started. - -Please verify the details of the following change request. In case of problems contact your registrar <%= @params[:registrar_name] %> - -New registrant: -Name: <%= @params[:registrant_name] %> -<% if @params[:registrant_priv] %> -Personal code: <%= @params[:registrant_ident] %> -<% else %> -Business Registry code: <%= @params[:registrant_ident] %> -<% end %> -Street: <%= @params[:registrant_street] %> -City: <%= @params[:registrant_city] %> -Country: <%= @params[:registrant_country] %> - -The registrant change procedure will be completed only after the current registrant <%= @params[:old_registrant_name] %> has approved it. - -Change request will be cancelled in case <%= @params[:old_registrant_name] %> rejects or does not approve it in <%= Setting.expire_pending_confirmation %> hours. - -Please contact registrar <%= @params[:registrar_name] %> in case of questions. You can find the registrar's contacts at http://internet.ee/registrars. - -Best Regards, -Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb deleted file mode 100644 index 0dca95ee9..000000000 --- a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -Tere -

-Domeeni <%= @params[:name] %> registreerija <%= @params[:old_registrant_name] %> on domeeni registreerija vahetamise taotluse tagasi lükanud. -

-Küsimuste korral võtke palun ühendust oma registripidajaga <%= @params[:registrar_name] %>. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. -

-Lugupidamisega
-Eesti Interneti Sihtasutus -

-
-

-Hi, -

-Registrant change for the domain <%= @params[:name] %> was rejected by the registrant <%= @params[:old_registrant_name] %>. -

-Please contact your registrar <%= @params[:registrar_name] %> if you have any questions. You can find the registrar's contacts at http://internet.ee/registrars. -

-Best Regards,
-Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb deleted file mode 100644 index bf9ecc80a..000000000 --- a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb +++ /dev/null @@ -1,20 +0,0 @@ -Tere - -Domeeni <%= @params[:name] %> registreerija <%= @params[:old_registrant_name] %> on domeeni registreerija vahetamise taotluse tagasi lükanud. - -Küsimuste korral võtke palun ühendust oma registripidajaga <%= @params[:registrar_name] %>. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. - -Lugupidamisega -Eesti Interneti Sihtasutus - --------------------------------------- - -Hi, - -Registrant change for the domain <%= @params[:name] %> was rejected by the registrant <%= @params[:old_registrant_name] %> -. - -Please contact your registrar <%= @params[:registrar_name] %> if you have any questions. You can find the registrar's contacts at http://internet.ee/registrars. - -Best Regards, -Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb deleted file mode 100644 index 9015a8945..000000000 --- a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb +++ /dev/null @@ -1,48 +0,0 @@ -Tere -

-Registrisse laekus taotlus domeeni <%= @params[:name] %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja <%= @params[:registrar_name] %> poole. -

-Uue registreerija andmed:
-Nimi: <%= @params[:registrant_name] %>
-<% if @params[:registrant_priv] %> -Isikukood: <%= @params[:registrant_ident] %>
-<% else %> -Äriregistrikood: <%= @params[:registrant_ident] %>
-<% end %> -Tänav: <%= @params[:registrant_street] %>
-Linn: <%= @params[:registrant_city] %>
-Riik: <%= @params[:registrant_country] %> -

-Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka. -

-Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
- -<%= link_to @params[:verification_url], @params[:verification_url] %> -

-Lugupidamisega
-Eesti Interneti Sihtasutus -

-
-

-Hi, -

-Application for changing registrant of your domain <%= @params[:name] %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @params[:registrar_name] %> -

-New registrant:
-Name: <%= @params[:registrant_name] %>
-<% if @params[:registrant_priv] %> -Personal code: <%= @params[:registrant_ident] %>
-<% else %> -Business Registry code: <%= @params[:registrant_ident] %>
-<% end %> -Street: <%= @params[:registrant_street] %>
-City: <%= @params[:registrant_city] %>
-Country: <%= @params[:registrant_country] %> -

-The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before. -

-To confirm the update please visit this website, once again review the data and press approve:
-<%= link_to @params[:verification_url], @params[:verification_url] %> -

-Best Regards,
-Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb deleted file mode 100644 index d2ee28479..000000000 --- a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb +++ /dev/null @@ -1,45 +0,0 @@ -Tere - -Registrisse laekus taotlus domeeni <%= @params[:name] %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja <%= @params[:registrar_name] %> poole. - -Uue registreerija andmed: -Nimi: <%= @params[:registrant_name] %> -<% if @params[:registrant_priv] %> -Isikukood: <%= @params[:registrant_ident] %> -<% else %> -Äriregistrikood: <%= @params[:registrant_ident] %> -<% end %> -Tänav: <%= @params[:registrant_street] %> -Linn: <%= @params[:registrant_city] %> -Riik: <%= @params[:registrant_country] %> - -Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka. -Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan: -<%= @params[:verification_url] %> - -Lugupidamisega -Eesti Interneti Sihtasutus - --------------------------------------- - -Hi, - -Application for changing registrant of your domain <%= @params[:name] %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @params[:registrar_name] %> - -New registrant: -Name: <%= @params[:registrant_name] %> -<% if @params[:registrant_priv] %> -Personal code: <%= @params[:registrant_ident] %> -<% else %> -Business Registry code: <%= @params[:registrant_ident] %> -<% end %> -Street: <%= @params[:registrant_street] %> -City: <%= @params[:registrant_city] %> -Country: <%= @params[:registrant_country] %> - -The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before. -To confirm the update please visit this website, once again review the data and press approve: -<%= @params[:verification_url] %> - -Best Regards, -Estonian Internet Foundation diff --git a/app/views/mailers/registrant_change_mailer/confirm.html.erb b/app/views/mailers/registrant_change_mailer/confirm.html.erb new file mode 100644 index 000000000..a2e889dc6 --- /dev/null +++ b/app/views/mailers/registrant_change_mailer/confirm.html.erb @@ -0,0 +1,38 @@ +Tere +

+Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: + +<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %> + +

+Uue registreerija andmed:
+<%= render 'mailers/shared/registrant/registrant.et.html', registrant: @new_registrant %> +

+Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka. +

+Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
+ +<%= link_to @confirm_url, @confirm_url %> +

+Lugupidamisega
+Eesti Interneti Sihtasutus +

+
+

+Hi, +

+Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. In case of problems please turn to your registrar: + +<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %> + +

+New registrant:
+<%= render 'mailers/shared/registrant/registrant.en.html', registrant: @new_registrant %> +

+The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before. +

+To confirm the update please visit this website, once again review the data and press approve:
+<%= link_to @confirm_url, @confirm_url %> +

+Best Regards,
+Estonian Internet Foundation diff --git a/app/views/mailers/registrant_change_mailer/confirm.text.erb b/app/views/mailers/registrant_change_mailer/confirm.text.erb new file mode 100644 index 000000000..2af2381fc --- /dev/null +++ b/app/views/mailers/registrant_change_mailer/confirm.text.erb @@ -0,0 +1,33 @@ +Tere + +Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: + +<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %> + +Uue registreerija andmed: +<%= render 'mailers/shared/registrant/registrant.et.text', registrant: @new_registrant %> + +Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka. +Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan: +<%= @confirm_url %> + +Lugupidamisega +Eesti Interneti Sihtasutus + +-------------------------------------- + +Hi, + +Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. In case of problems please turn to your registrar: + +<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %> + +New registrant: +<%= render 'mailers/shared/registrant/registrant.en.text', registrant: @new_registrant %> + +The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before. +To confirm the update please visit this website, once again review the data and press approve: +<%= @confirm_url %> + +Best Regards, +Estonian Internet Foundation diff --git a/app/views/mailers/registrant_change_mailer/expired.html.erb b/app/views/mailers/registrant_change_mailer/expired.html.erb new file mode 100644 index 000000000..0d369a970 --- /dev/null +++ b/app/views/mailers/registrant_change_mailer/expired.html.erb @@ -0,0 +1,25 @@ +Tere +

+Domeeni <%= @domain.name %> registreerija <%= @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 oma registripidajaga: + +<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %> + +

+Lugupidamisega
+Eesti Interneti Sihtasutus +

+
+

+Hi, +

+Domain registrant change request has been expired for the domain <%= @domain.name %>. +

+Please contact to your registrar if you have any questions: + +<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %> + +

+Best Regards,
+Estonian Internet Foundation diff --git a/app/views/mailers/registrant_change_mailer/expired.text.erb b/app/views/mailers/registrant_change_mailer/expired.text.erb new file mode 100644 index 000000000..7ec3fecbd --- /dev/null +++ b/app/views/mailers/registrant_change_mailer/expired.text.erb @@ -0,0 +1,23 @@ +Tere + +Domeeni <%= @domain.name %> registreerija <%= @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 oma registripidajaga: + +<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %> + +Lugupidamisega +Eesti Interneti Sihtasutus + +-------------------------------------- + +Hi, + +Domain registrant change request has been expired for the domain <%= @domain.name %>. + +Please contact to your registrar if you have any questions: + +<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %> + +Best Regards, +Estonian Internet Foundation diff --git a/app/views/mailers/registrant_change_mailer/notice.html.erb b/app/views/mailers/registrant_change_mailer/notice.html.erb new file mode 100644 index 000000000..6aecaf0b3 --- /dev/null +++ b/app/views/mailers/registrant_change_mailer/notice.html.erb @@ -0,0 +1,39 @@ +Tere +

+Registripidaja <%= @registrar.name %> vahendusel on algatatud <%= @domain.name %> domeeni omanikuvahetuse protseduur. +

+Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: + +<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %> + +

+Uue registreerija andmed:
+<%= render 'mailers/shared/registrant/registrant.et.html', registrant: @new_registrant %> +

+Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @current_registrant.name %> omanikuvahetuse tähtaegselt kinnitab. +

+Juhul kui <%= @current_registrant.name %> lükkab omanikuvahetuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. +

+Lugupidamisega
+Eesti Interneti Sihtasutus +

+
+

+Hi, +

+Registrant change process for the domain <%= @domain.name %> has been started. +

+Please verify the details of the following change request. In case of problems contact your registrar: + +<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %> + +

+New registrant:
+<%= render 'mailers/shared/registrant/registrant.en.html', registrant: @new_registrant %> +

+The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it. +

+Change request will be cancelled in case <%= @current_registrant.name %> rejects or does not approve it in <%= Setting.expire_pending_confirmation %> hours. +

+Best Regards,
+Estonian Internet Foundation diff --git a/app/views/mailers/registrant_change_mailer/notice.text.erb b/app/views/mailers/registrant_change_mailer/notice.text.erb new file mode 100644 index 000000000..bd1fb5d0f --- /dev/null +++ b/app/views/mailers/registrant_change_mailer/notice.text.erb @@ -0,0 +1,37 @@ +Tere + +Registripidaja <%= @registrar.name %> vahendusel on algatatud <%= @domain.name %> domeeni omanikuvahetuse protseduur. + +Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: + +<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %> + +Uue registreerija andmed: +<%= render 'mailers/shared/registrant/registrant.et.text', registrant: @new_registrant %> + +Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @current_registrant.name %> omanikuvahetuse tähtaegselt kinnitab. + +Juhul kui <%= @current_registrant.name %> lükkab omanikuvahetuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. + +Lugupidamisega +Eesti Interneti Sihtasutus + +-------------------------------------- + +Hi, + +Registrant change process for the domain <%= @domain.name %> has been started. + +Please verify the details of the following change request. In case of problems contact your registrar: + +<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %> + +New registrant: +<%= render 'mailers/shared/registrant/registrant.en.text', registrant: @new_registrant %> + +The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it. + +Change request will be cancelled in case <%= @current_registrant.name %> rejects or does not approve it in <%= Setting.expire_pending_confirmation %> hours. + +Best Regards, +Estonian Internet Foundation diff --git a/app/views/mailers/registrant_change_mailer/rejected.html.erb b/app/views/mailers/registrant_change_mailer/rejected.html.erb new file mode 100644 index 000000000..2521dd52a --- /dev/null +++ b/app/views/mailers/registrant_change_mailer/rejected.html.erb @@ -0,0 +1,25 @@ +Tere +

+Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud. +

+Küsimuste korral võtke palun ühendust oma registripidajaga: + +<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %> + +

+Lugupidamisega
+Eesti Interneti Sihtasutus +

+
+

+Hi, +

+Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @registrant.name %>. +

+Please contact your registrar if you have any questions: + +<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %> + +

+Best Regards,
+Estonian Internet Foundation diff --git a/app/views/mailers/registrant_change_mailer/rejected.text.erb b/app/views/mailers/registrant_change_mailer/rejected.text.erb new file mode 100644 index 000000000..166f6f394 --- /dev/null +++ b/app/views/mailers/registrant_change_mailer/rejected.text.erb @@ -0,0 +1,23 @@ +Tere + +Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud. + +Küsimuste korral võtke palun ühendust oma registripidajaga: + +<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %> + +Lugupidamisega +Eesti Interneti Sihtasutus + +-------------------------------------- + +Hi, + +Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @registrant.name %>. + +Please contact your registrar if you have any questions: + +<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %> + +Best Regards, +Estonian Internet Foundation diff --git a/app/views/mailers/shared/registrant/_registrant.en.html.erb b/app/views/mailers/shared/registrant/_registrant.en.html.erb new file mode 100644 index 000000000..300157c83 --- /dev/null +++ b/app/views/mailers/shared/registrant/_registrant.en.html.erb @@ -0,0 +1,9 @@ +Name: <%= registrant.name %>
+<% if registrant.priv? %> + Personal code: <%= registrant.ident %>
+<% else %> + Business Registry code: <%= registrant.ident %>
+<% end %> +Street: <%= registrant.street %>
+City: <%= registrant.city %>
+Country: <%= registrant.country %> diff --git a/app/views/mailers/shared/registrant/_registrant.en.text.erb b/app/views/mailers/shared/registrant/_registrant.en.text.erb new file mode 100644 index 000000000..649e2c452 --- /dev/null +++ b/app/views/mailers/shared/registrant/_registrant.en.text.erb @@ -0,0 +1,9 @@ +Name: <%= registrant.name %> +<% if registrant.priv? %> + Personal code: <%= registrant.ident %> +<% else %> + Business Registry code: <%= registrant.ident %> +<% end %> +Street: <%= registrant.street %> +City: <%= registrant.city %> +Country: <%= registrant.country %> diff --git a/app/views/mailers/shared/registrant/_registrant.et.html.erb b/app/views/mailers/shared/registrant/_registrant.et.html.erb new file mode 100644 index 000000000..789b88490 --- /dev/null +++ b/app/views/mailers/shared/registrant/_registrant.et.html.erb @@ -0,0 +1,9 @@ +Nimi: <%= registrant.name %>
+<% if registrant.priv? %> + Isikukood: <%= registrant.ident %>
+<% else %> + Äriregistrikood: <%= registrant.ident %>
+<% end %> +Tänav: <%= registrant.street %>
+Linn: <%= registrant.city %>
+Riik: <%= registrant.country %> diff --git a/app/views/mailers/shared/registrant/_registrant.et.text.erb b/app/views/mailers/shared/registrant/_registrant.et.text.erb new file mode 100644 index 000000000..01ece5e67 --- /dev/null +++ b/app/views/mailers/shared/registrant/_registrant.et.text.erb @@ -0,0 +1,9 @@ +Nimi: <%= registrant.name %> +<% if registrant.priv? %> + Isikukood: <%= registrant.ident %> +<% else %> + Äriregistrikood: <%= registrant.ident %> +<% end %> +Tänav: <%= registrant.street %> +Linn: <%= registrant.city %> +Riik: <%= registrant.country %> diff --git a/app/views/mailers/shared/registrar/_registrar.en.html.erb b/app/views/mailers/shared/registrar/_registrar.en.html.erb new file mode 100644 index 000000000..699fcd19d --- /dev/null +++ b/app/views/mailers/shared/registrar/_registrar.en.html.erb @@ -0,0 +1,6 @@ +

+ <%= registrar.name %>
+ Email: <%= registrar.email %>
+ Phone: <%= registrar.phone %>
+ Website: <%= registrar.url %> +

diff --git a/app/views/mailers/shared/registrar/_registrar.en.text.erb b/app/views/mailers/shared/registrar/_registrar.en.text.erb new file mode 100644 index 000000000..96882b11d --- /dev/null +++ b/app/views/mailers/shared/registrar/_registrar.en.text.erb @@ -0,0 +1,4 @@ +<%= registrar.name %> +Email: <%= registrar.email %> +Phone: <%= registrar.phone %> +Website: <%= registrar.url %> diff --git a/app/views/mailers/shared/registrar/_registrar.et.html.erb b/app/views/mailers/shared/registrar/_registrar.et.html.erb new file mode 100644 index 000000000..199115210 --- /dev/null +++ b/app/views/mailers/shared/registrar/_registrar.et.html.erb @@ -0,0 +1,6 @@ +

+ <%= registrar.name %>
+ Email: <%= registrar.email %>
+ Telefon: <%= registrar.phone %>
+ Veebileht: <%= registrar.url %> +

diff --git a/app/views/mailers/shared/registrar/_registrar.et.text.erb b/app/views/mailers/shared/registrar/_registrar.et.text.erb new file mode 100644 index 000000000..0e8b16e30 --- /dev/null +++ b/app/views/mailers/shared/registrar/_registrar.et.text.erb @@ -0,0 +1,4 @@ +<%= registrar.name %> +Email: <%= registrar.email %> +Telefon: <%= registrar.phone %> +Veebileht: <%= registrar.url %> diff --git a/app/views/mailers/shared/registrar/_registrar.ru.html.erb b/app/views/mailers/shared/registrar/_registrar.ru.html.erb new file mode 100644 index 000000000..1c258f10d --- /dev/null +++ b/app/views/mailers/shared/registrar/_registrar.ru.html.erb @@ -0,0 +1,6 @@ +

+ <%= registrar.name %>
+ Электронная почта: <%= registrar.email %>
+ Телефон: <%= registrar.phone %>
+ Веб-сайт: <%= registrar.url %> +

diff --git a/app/views/mailers/shared/registrar/_registrar.ru.text.erb b/app/views/mailers/shared/registrar/_registrar.ru.text.erb new file mode 100644 index 000000000..0a74e8974 --- /dev/null +++ b/app/views/mailers/shared/registrar/_registrar.ru.text.erb @@ -0,0 +1,4 @@ +<%= registrar.name %> +Электронная почта: <%= registrar.email %> +Телефон: <%= registrar.phone %> +Веб-сайт: <%= registrar.url %> diff --git a/bin/rspec b/bin/rspec index 8bc84617e..534d2bb5f 100755 --- a/bin/rspec +++ b/bin/rspec @@ -1,4 +1,8 @@ #!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end # # This file was generated by Bundler. # diff --git a/bin/spring b/bin/spring index adc409e83..7b45d374f 100755 --- a/bin/spring +++ b/bin/spring @@ -1,19 +1,15 @@ #!/usr/bin/env ruby -# This file loads spring without using Bundler, in order to be fast -# It gets overwritten when you run the `spring binstub` command +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. unless defined?(Spring) - require 'rubygems' - require 'bundler' + require "rubygems" + require "bundler" - match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) - if match - ENV['GEM_PATH'] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) - ENV['GEM_HOME'] = nil - Gem.paths = ENV - - gem 'spring', match[1] - require 'spring/binstub' + if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m) + Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq } + gem "spring", match[1] + require "spring/binstub" end end diff --git a/config/application.rb b/config/application.rb index 43f3f7183..109fa4d1b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -35,6 +35,7 @@ module Registry # Autoload all model subdirs config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')] config.autoload_paths << Rails.root.join('lib') + config.eager_load_paths << config.root.join('lib', 'validators') # Add the fonts path config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts') diff --git a/config/environments/test.rb b/config/environments/test.rb index 53bed3bc7..9f6a888d1 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -60,6 +60,7 @@ Rails.application.configure do Bullet.add_whitelist type: :counter_cache, class_name: 'Contact', association: :versions end + config.active_job.queue_adapter = :test config.logger = ActiveSupport::Logger.new(nil) end diff --git a/config/locales/en.yml b/config/locales/en.yml index abb9fb289..0988e1ce0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -339,7 +339,6 @@ en: contact_details: 'Contact details' ident: 'Ident' ident_type: 'Ident type' - address: 'Address' country: 'Country' city: 'City' street: 'Street' @@ -795,13 +794,8 @@ 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' - pending_update_request_for_old_registrant_subject: "Kinnitustaotlus domeeni %{name} registreerija vahetuseks / Application for approval for registrant change 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" @@ -937,13 +931,11 @@ en: new_mail_template: New mail template failure: "It was not saved" contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact' - force_delete_subject: 'Kustutusmenetluse teade' welcome_to_eis_registrar_portal: 'Welcome to EIS Registrar portal' interfaces: 'Interfaces' list_format_is_in_yaml: 'List format is in YAML' if_auth_info_is_left_empty_it_will_be_auto_generated: 'If auth info is left empty, it will be auto generated.' each_domain_name_must_end_with_colon_sign: 'Each domain name must end with colon (:) sign.' - expiration_remind_subject: 'The %{name} domain has expired' next: 'Next' previous: 'Previous' personal_domain_verification_url: 'Personal domain verification url' diff --git a/config/locales/mailers/domain_delete.en.yml b/config/locales/mailers/domain_delete.en.yml new file mode 100644 index 000000000..93e656b1e --- /dev/null +++ b/config/locales/mailers/domain_delete.en.yml @@ -0,0 +1,6 @@ +en: + domain_delete_mailer: + confirm: + subject: Kinnitustaotlus domeeni %{domain_name} kustutamiseks .ee registrist / Application for approval for deletion of %{domain_name} + forced: + subject: Kustutusmenetluse teade diff --git a/config/locales/mailers/domain_expire.en.yml b/config/locales/mailers/domain_expire.en.yml new file mode 100644 index 000000000..3fb6e97da --- /dev/null +++ b/config/locales/mailers/domain_expire.en.yml @@ -0,0 +1,4 @@ +en: + domain_expire_mailer: + expired: + subject: The %{domain_name} domain has expired diff --git a/config/locales/mailers/registrant_change.en.yml b/config/locales/mailers/registrant_change.en.yml new file mode 100644 index 000000000..9cd95f648 --- /dev/null +++ b/config/locales/mailers/registrant_change.en.yml @@ -0,0 +1,10 @@ +en: + registrant_change_mailer: + confirm: + subject: Kinnitustaotlus domeeni %{domain_name} registreerija vahetuseks / Application for approval for registrant change of %{domain_name} + notice: + subject: Domeeni %{domain_name} registreerija vahetus protseduur on algatatud / %{domain_name} registrant change + rejected: + subject: Domeeni %{domain_name} registreerija vahetuse taotlus tagasi lükatud / %{domain_name} registrant change declined + expired: + subject: Domeeni %{domain_name} registreerija vahetuse taotlus on tühistatud / %{domain_name} registrant change cancelled diff --git a/lib/validators/email_validator.rb b/lib/validators/email_validator.rb new file mode 100644 index 000000000..60b1b3ce1 --- /dev/null +++ b/lib/validators/email_validator.rb @@ -0,0 +1,15 @@ +class EmailValidator + def self.regexp + Devise::email_regexp + end + + def initialize(email) + @email = email + end + + def valid? + email =~ self.class.regexp + end + + attr_reader :email +end diff --git a/spec/factories/admin_domain_contact.rb b/spec/factories/admin_domain_contact.rb new file mode 100644 index 000000000..786825214 --- /dev/null +++ b/spec/factories/admin_domain_contact.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :admin_domain_contact, parent: :domain_contact, class: AdminDomainContact do + + end +end diff --git a/spec/factories/contact.rb b/spec/factories/contact.rb new file mode 100644 index 000000000..5218da399 --- /dev/null +++ b/spec/factories/contact.rb @@ -0,0 +1,16 @@ +FactoryGirl.define do + factory :contact do + name 'test' + sequence(:code) { |n| "test#{n}" } + phone '+123.456789' + email 'test@test.com' + street 'test' + city 'test' + zip 12345 + country_code 'EE' + ident '37605030299' + ident_type 'priv' + ident_country_code 'EE' + registrar + end +end diff --git a/spec/factories/dnskey.rb b/spec/factories/dnskey.rb new file mode 100644 index 000000000..e06387487 --- /dev/null +++ b/spec/factories/dnskey.rb @@ -0,0 +1,15 @@ +FactoryGirl.define do + factory :dnskey do + alg Dnskey::ALGORITHMS.first + flags Dnskey::FLAGS.first + protocol Dnskey::PROTOCOLS.first + ds_digest_type 2 + domain + public_key 'AwEAAaOf5+lz3ftsL+0CCvfJbhUF/NVsNh8BKo61oYs5fXVbuWDiH872 '\ + 'LC8uKDO92TJy7Q4TF9XMAKMMlf1GMAxlRspD749SOCTN00sqfWx1OMTu '\ + 'a28L1PerwHq7665oDJDKqR71btcGqyLKhe2QDvCdA0mENimF1NudX1BJ '\ + 'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\ + 'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\ + 'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs=' + end +end diff --git a/spec/factories/domain.rb b/spec/factories/domain.rb new file mode 100644 index 000000000..5a396362d --- /dev/null +++ b/spec/factories/domain.rb @@ -0,0 +1,15 @@ +FactoryGirl.define do + factory :domain do + sequence(:name) { |n| "test#{n}.com" } + period 1 + period_unit 'y' # Year + registrar + registrant + + after :build do |domain| + domain.nameservers << FactoryGirl.build_pair(:nameserver) + domain.admin_domain_contacts << FactoryGirl.build(:admin_domain_contact) + domain.tech_domain_contacts << FactoryGirl.build(:tech_domain_contact) + end + end +end diff --git a/spec/factories/domain_contact.rb b/spec/factories/domain_contact.rb new file mode 100644 index 000000000..ae05fd293 --- /dev/null +++ b/spec/factories/domain_contact.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :domain_contact do + contact + end +end diff --git a/spec/factories/nameserver.rb b/spec/factories/nameserver.rb new file mode 100644 index 000000000..ebe7a7909 --- /dev/null +++ b/spec/factories/nameserver.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :nameserver do + sequence(:hostname) { |n| "ns.test#{n}.ee" } + ipv4 '192.168.1.1' + end +end diff --git a/spec/factories/registrant.rb b/spec/factories/registrant.rb new file mode 100644 index 000000000..c4846fcd4 --- /dev/null +++ b/spec/factories/registrant.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :registrant, parent: :contact, class: Registrant do + name 'test' + end +end diff --git a/spec/factories/registrar.rb b/spec/factories/registrar.rb new file mode 100644 index 000000000..dd581a1d1 --- /dev/null +++ b/spec/factories/registrar.rb @@ -0,0 +1,13 @@ +FactoryGirl.define do + factory :registrar do + sequence(:name) { |n| "test#{n}" } + sequence(:code) { |n| "test#{n}" } + sequence(:reg_no) { |n| "test#{n}" } + street 'test' + city 'test' + state 'test' + zip 'test' + email 'test@test.com' + country_code 'EE' + end +end diff --git a/spec/factories/tech_domain_contact.rb b/spec/factories/tech_domain_contact.rb new file mode 100644 index 000000000..e407474a3 --- /dev/null +++ b/spec/factories/tech_domain_contact.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :tech_domain_contact, parent: :domain_contact, class: TechDomainContact do + + end +end diff --git a/spec/factory_lint_spec.rb b/spec/factory_lint_spec.rb new file mode 100644 index 000000000..37988cca0 --- /dev/null +++ b/spec/factory_lint_spec.rb @@ -0,0 +1,7 @@ +require_relative 'rails_helper' + +RSpec.describe 'FactoryGirl', db: true do + it 'lints factories' do + FactoryGirl.lint + end +end diff --git a/spec/jobs/domain_delete_confirm_email_job_spec.rb b/spec/jobs/domain_delete_confirm_email_job_spec.rb new file mode 100644 index 000000000..0b2a0a6b7 --- /dev/null +++ b/spec/jobs/domain_delete_confirm_email_job_spec.rb @@ -0,0 +1,40 @@ +require 'rails_helper' + +RSpec.describe DomainDeleteConfirmEmailJob do + describe '#run' do + let(:domain) { instance_double(Domain) } + let(:message) { instance_double(ActionMailer::MessageDelivery) } + + before :example do + expect(Domain).to receive(:find).and_return(domain) + allow(domain).to receive_messages( + id: 1, + name: 'test.com', + registrant_email: 'registrant@test.com', + registrar: 'registrar', + registrant: 'registrant') + end + + after :example do + domain_id = 1 + described_class.enqueue(domain_id) + end + + it 'creates log record' do + log_message = 'Send DomainDeleteMailer#confirm email for domain test.com (#1) to registrant@test.com' + + allow(DomainDeleteMailer).to receive(:confirm).and_return(message) + allow(message).to receive(:deliver_now) + + expect(Rails.logger).to receive(:info).with(log_message) + end + + it 'sends email' do + expect(DomainDeleteMailer).to receive(:confirm).with(domain: domain, + registrar: 'registrar', + registrant: 'registrant') + .and_return(message) + expect(message).to receive(:deliver_now) + end + end +end diff --git a/spec/jobs/domain_delete_forced_email_job_spec.rb b/spec/jobs/domain_delete_forced_email_job_spec.rb new file mode 100644 index 000000000..05dab987b --- /dev/null +++ b/spec/jobs/domain_delete_forced_email_job_spec.rb @@ -0,0 +1,40 @@ +require 'rails_helper' + +RSpec.describe DomainDeleteForcedEmailJob do + describe '#run' do + let(:domain) { instance_double(Domain) } + let(:message) { instance_double(ActionMailer::MessageDelivery) } + + before :example do + expect(Domain).to receive(:find).and_return(domain) + allow(domain).to receive_messages( + id: 1, + name: 'test.com', + registrar: 'registrar', + registrant: 'registrant', + primary_contact_emails: %w(test@test.com test@test.com)) + end + + after :example do + domain_id = 1 + described_class.enqueue(domain_id) + end + + it 'creates log record' do + log_message = 'Send DomainDeleteMailer#forced email for domain test.com (#1) to test@test.com, test@test.com' + + allow(DomainDeleteMailer).to receive(:forced).and_return(message) + allow(message).to receive(:deliver_now) + + expect(Rails.logger).to receive(:info).with(log_message) + end + + it 'sends email' do + expect(DomainDeleteMailer).to receive(:forced).with(domain: domain, + registrar: 'registrar', + registrant: 'registrant') + .and_return(message) + expect(message).to receive(:deliver_now) + end + end +end diff --git a/spec/jobs/domain_expire_email_job_spec.rb b/spec/jobs/domain_expire_email_job_spec.rb new file mode 100644 index 000000000..a25999b77 --- /dev/null +++ b/spec/jobs/domain_expire_email_job_spec.rb @@ -0,0 +1,43 @@ +require 'rails_helper' + +RSpec.describe DomainExpireEmailJob do + describe '#run' do + let(:domain) { instance_double(Domain) } + + before :example do + expect(Domain).to receive(:find).and_return(domain) + end + + after :example do + domain_id = 1 + described_class.enqueue(domain_id) + end + + context 'when domain is expired' do + let(:message) { instance_double(ActionMailer::MessageDelivery) } + + before :example do + allow(domain).to receive_messages( + registrar: 'registrar', + registered?: false, + primary_contact_emails: %w(test@test.com test@test.com)) + end + + it 'sends email' do + expect(DomainExpireMailer).to receive(:expired).with(domain: domain, registrar: 'registrar') + .and_return(message) + expect(message).to receive(:deliver_now) + end + end + + context 'when domain is registered' do + before :example do + allow(domain).to receive(:registered?).and_return(true) + end + + it 'does not send email' do + expect(DomainExpireMailer).to_not receive(:expired) + end + end + end +end diff --git a/spec/jobs/registrant_change_confirm_email_job_spec.rb b/spec/jobs/registrant_change_confirm_email_job_spec.rb new file mode 100644 index 000000000..ea8eb1096 --- /dev/null +++ b/spec/jobs/registrant_change_confirm_email_job_spec.rb @@ -0,0 +1,43 @@ +require 'rails_helper' + +RSpec.describe RegistrantChangeConfirmEmailJob do + describe '#run' do + let(:domain) { instance_double(Domain) } + let(:message) { instance_double(ActionMailer::MessageDelivery) } + + before :example do + expect(Domain).to receive(:find).and_return(domain) + expect(Registrant).to receive(:find).and_return('new registrant') + allow(domain).to receive_messages( + id: 1, + name: 'test.com', + registrant_email: 'registrant@test.com', + registrar: 'registrar', + registrant: 'registrant') + end + + after :example do + domain_id = 1 + new_registrant_id = 1 + described_class.enqueue(domain_id, new_registrant_id) + end + + it 'creates log record' do + log_message = 'Send RegistrantChangeMailer#confirm email for domain test.com (#1) to registrant@test.com' + + allow(RegistrantChangeMailer).to receive(:confirm).and_return(message) + allow(message).to receive(:deliver_now) + + expect(Rails.logger).to receive(:info).with(log_message) + end + + it 'sends email' do + expect(RegistrantChangeMailer).to receive(:confirm).with(domain: domain, + registrar: 'registrar', + current_registrant: 'registrant', + new_registrant: 'new registrant') + .and_return(message) + expect(message).to receive(:deliver_now) + end + end +end diff --git a/spec/jobs/registrant_change_expired_email_job_spec.rb b/spec/jobs/registrant_change_expired_email_job_spec.rb new file mode 100644 index 000000000..1486417ea --- /dev/null +++ b/spec/jobs/registrant_change_expired_email_job_spec.rb @@ -0,0 +1,40 @@ +require 'rails_helper' + +RSpec.describe RegistrantChangeExpiredEmailJob do + describe '#run' do + let(:domain) { instance_double(Domain, + id: 1, + name: 'test.com', + new_registrant_email: 'new-registrant@test.com', + registrar: 'registrar', + registrant: 'registrant') + } + let(:message) { instance_double(ActionMailer::MessageDelivery) } + + before :example do + expect(Domain).to receive(:find).and_return(domain) + end + + after :example do + domain_id = 1 + described_class.enqueue(domain_id) + end + + it 'creates log record' do + log_message = 'Send RegistrantChangeMailer#expired email for domain test.com (#1) to new-registrant@test.com' + + allow(RegistrantChangeMailer).to receive(:expired).and_return(message) + allow(message).to receive(:deliver_now) + + expect(Rails.logger).to receive(:info).with(log_message) + end + + it 'sends email' do + expect(RegistrantChangeMailer).to receive(:expired).with(domain: domain, + registrar: 'registrar', + registrant: 'registrant') + .and_return(message) + expect(message).to receive(:deliver_now) + end + end +end diff --git a/spec/jobs/registrant_change_notice_email_job_spec.rb b/spec/jobs/registrant_change_notice_email_job_spec.rb new file mode 100644 index 000000000..1eb1d6d94 --- /dev/null +++ b/spec/jobs/registrant_change_notice_email_job_spec.rb @@ -0,0 +1,44 @@ +require 'rails_helper' + +RSpec.describe RegistrantChangeNoticeEmailJob do + describe '#run' do + let(:domain) { instance_double(Domain, + id: 1, + name: 'test.com', + registrant_email: 'registrant@test.com', + registrar: 'registrar', + registrant: 'registrant') + } + let(:new_registrant) { instance_double(Registrant, email: 'new-registrant@test.com') } + let(:message) { instance_double(ActionMailer::MessageDelivery) } + + before :example do + expect(Domain).to receive(:find).and_return(domain) + expect(Registrant).to receive(:find).and_return(new_registrant) + end + + after :example do + domain_id = 1 + new_registrant_id = 1 + described_class.enqueue(domain_id, new_registrant_id) + end + + it 'creates log record' do + log_message = 'Send RegistrantChangeMailer#notice email for domain test.com (#1) to new-registrant@test.com' + + allow(RegistrantChangeMailer).to receive(:notice).and_return(message) + allow(message).to receive(:deliver_now) + + expect(Rails.logger).to receive(:info).with(log_message) + end + + it 'sends email' do + expect(RegistrantChangeMailer).to receive(:notice).with(domain: domain, + registrar: 'registrar', + current_registrant: 'registrant', + new_registrant: new_registrant) + .and_return(message) + expect(message).to receive(:deliver_now) + end + end +end diff --git a/spec/lib/validators/email_validator_spec.rb b/spec/lib/validators/email_validator_spec.rb new file mode 100644 index 000000000..ecaadc8a7 --- /dev/null +++ b/spec/lib/validators/email_validator_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +RSpec.describe EmailValidator do + describe '#valid?' do + subject(:valid) { described_class.new(email).valid? } + + context 'when email is valid' do + let(:email) { 'test@test.com' } + + it 'returns truthy' do + expect(valid).to be_truthy + end + end + + context 'when email is invalid' do + let(:email) { 'invalid' } + + it 'returns falsey' do + expect(valid).to be_falsey + end + end + end +end diff --git a/spec/mailers/domain_delete_mailer_spec.rb b/spec/mailers/domain_delete_mailer_spec.rb new file mode 100644 index 000000000..5a2f775c1 --- /dev/null +++ b/spec/mailers/domain_delete_mailer_spec.rb @@ -0,0 +1,82 @@ +require 'rails_helper' + +RSpec.describe DomainDeleteMailer do + describe '#confirm' do + let(:domain) { instance_spy(Domain, name: 'test.com') } + let(:registrar) { instance_spy(Registrar) } + let(:registrant) { instance_spy(Registrant, email: 'registrant@test.com') } + + let(:domain_presenter) { instance_spy(DomainPresenter) } + let(:registrar_presenter) { instance_spy(RegistrarPresenter) } + + subject(:message) { described_class.confirm(domain: domain, + registrar: registrar, + registrant: registrant) + } + + before :example do + expect(DomainPresenter).to receive(:new).and_return(domain_presenter) + expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter) + end + + it 'has sender' do + expect(message.from).to eq(['noreply@internet.ee']) + end + + it 'has registrant\'s email as a recipient' do + expect(message.to).to match_array(['registrant@test.com']) + end + + it 'has subject' do + subject = 'Kinnitustaotlus domeeni test.com kustutamiseks .ee registrist' \ + ' / Application for approval for deletion of test.com' + + expect(message.subject).to eq(subject) + end + + it 'has confirm url' do + allow(domain).to receive(:id).and_return(1) + expect(domain).to receive(:registrant_verification_token).and_return('test') + url = registrant_domain_delete_confirm_url(domain, token: 'test') + expect(message.body.parts.first.decoded).to include(url) + end + + it 'sends message' do + expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + + describe '#forced' do + let(:domain) { instance_spy(Domain, name: 'test.com') } + let(:domain_presenter) { instance_spy(DomainPresenter) } + let(:registrar_presenter) { instance_spy(RegistrarPresenter) } + let(:registrant_presenter) { instance_spy(RegistrantPresenter) } + subject(:message) { described_class.forced(domain: domain, + registrar: 'registrar', + registrant: 'registrant') + } + + before :example do + expect(DomainPresenter).to receive(:new).and_return(domain_presenter) + expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter) + expect(RegistrantPresenter).to receive(:new).and_return(registrant_presenter) + end + + it 'has sender' do + expect(message.from).to eq(['noreply@internet.ee']) + end + + it 'has recipient' do + expect(domain).to receive(:primary_contact_emails).and_return(['recipient@test.com']) + expect(message.to).to match_array(['recipient@test.com']) + end + + it 'has valid subject' do + expect(message.subject).to eq('Kustutusmenetluse teade') + end + + it 'sends message' do + expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end +end diff --git a/spec/mailers/domain_expire_mailer_spec.rb b/spec/mailers/domain_expire_mailer_spec.rb new file mode 100644 index 000000000..e5660c11b --- /dev/null +++ b/spec/mailers/domain_expire_mailer_spec.rb @@ -0,0 +1,71 @@ +require 'rails_helper' + +RSpec.describe DomainExpireMailer do + describe '#expired' do + let(:domain) { instance_spy(Domain, + id: 1, + name: 'test.com', + primary_contact_emails: recipient) + } + let(:domain_presenter) { instance_spy(DomainPresenter) } + let(:registrar_presenter) { instance_spy(RegistrarPresenter) } + subject(:message) { described_class.expired(domain: domain, registrar: nil) } + + before :example do + expect(DomainPresenter).to receive(:new).and_return(domain_presenter) + expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter) + end + + context 'when all recipients are valid' do + let(:recipient) { %w[recipient@test.com recipient@test.com] } + + it 'has sender' do + expect(message.from).to eq(['noreply@internet.ee']) + end + + it 'delivers to all recipients' do + expect(message.to).to match_array(%w[recipient@test.com recipient@test.com]) + end + + it 'has subject' do + expect(message.subject).to eq('The test.com domain has expired') + end + + it 'logs valid emails' do + log_message = 'Send DomainExpireMailer#expired email for domain test.com (#1) to recipient@test.com,' \ + ' recipient@test.com' + expect(described_class.logger).to receive(:info).with(log_message) + message.deliver_now + end + + it 'sends message' do + expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + + context 'when some recipient is invalid' do + let(:recipient) { %w[invalid_email valid@test.com] } + + before :example do + allow(described_class.logger).to receive(:info) + end + + it 'does not deliver to invalid recipient' do + expect(message.to).to match_array(%w[valid@test.com]) + end + + it 'does not log invalid email in success message' do + log_message = 'Send DomainExpireMailer#expired email for domain test.com (#1) to valid@test.com' + expect(described_class.logger).to receive(:info).with(log_message) + message.deliver_now + end + + it 'logs invalid email in error message' do + log_message = 'Unable to send DomainExpireMailer#expired email for domain test.com (#1) to' \ + ' invalid recipient invalid_email' + expect(described_class.logger).to receive(:info).with(log_message) + message.deliver_now + end + end + end +end diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb new file mode 100644 index 000000000..a3f4a42c7 --- /dev/null +++ b/spec/mailers/domain_mailer_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe DomainMailer do + +end diff --git a/spec/mailers/registrant_change_mailer_spec.rb b/spec/mailers/registrant_change_mailer_spec.rb new file mode 100644 index 000000000..be1e7d105 --- /dev/null +++ b/spec/mailers/registrant_change_mailer_spec.rb @@ -0,0 +1,176 @@ +require 'rails_helper' + +RSpec.describe RegistrantChangeMailer do + describe '#confirm' do + let(:domain) { instance_spy(Domain, name: 'test.com') } + let(:registrar) { instance_spy(Registrar) } + let(:current_registrant) { instance_spy(Registrant, email: 'registrant@test.com') } + let(:new_registrant) { instance_spy(Registrant) } + + let(:domain_presenter) { instance_spy(DomainPresenter) } + let(:registrar_presenter) { instance_spy(RegistrarPresenter) } + let(:new_registrant_presenter) { instance_spy(RegistrantPresenter) } + + subject(:message) { described_class.confirm(domain: domain, + registrar: registrar, + current_registrant: current_registrant, + new_registrant: new_registrant) + } + + before :example do + expect(DomainPresenter).to receive(:new).and_return(domain_presenter) + expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter) + expect(RegistrantPresenter).to receive(:new).and_return(new_registrant_presenter) + end + + it 'has sender' do + expect(message.from).to eq(['noreply@internet.ee']) + end + + it 'has current registrant\s email as a recipient' do + expect(message.to).to match_array(['registrant@test.com']) + end + + it 'has subject' do + subject = 'Kinnitustaotlus domeeni test.com registreerija vahetuseks' \ + ' / Application for approval for registrant change of test.com' + + expect(message.subject).to eq(subject) + end + + it 'has confirmation url' do + allow(domain).to receive(:id).and_return(1) + expect(domain).to receive(:registrant_verification_token).and_return('test') + url = registrant_domain_update_confirm_url(domain, token: 'test') + expect(message.body.parts.first.decoded).to include(url) + end + + it 'sends message' do + expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + + describe '#notice' do + let(:domain) { instance_spy(Domain, name: 'test.com') } + let(:registrar) { instance_spy(Registrar) } + let(:current_registrant) { instance_spy(Registrant) } + let(:new_registrant) { instance_spy(Registrant, email: 'registrant@test.com') } + + let(:domain_presenter) { instance_spy(DomainPresenter) } + let(:registrar_presenter) { instance_spy(RegistrarPresenter) } + let(:current_registrant_presenter) { instance_spy(RegistrantPresenter) } + let(:new_registrant_presenter) { instance_spy(RegistrantPresenter) } + + subject(:message) { described_class.notice(domain: domain, + registrar: registrar, + current_registrant: current_registrant, + new_registrant: new_registrant) + } + + before :example do + expect(DomainPresenter).to receive(:new).and_return(domain_presenter) + expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter) + expect(RegistrantPresenter).to receive(:new).with(registrant: current_registrant, view: anything).and_return(current_registrant_presenter) + expect(RegistrantPresenter).to receive(:new).with(registrant: new_registrant, view: anything).and_return(new_registrant_presenter) + end + + it 'has sender' do + expect(message.from).to eq(['noreply@internet.ee']) + end + + it 'has new registrant\s email as a recipient' do + expect(message.to).to match_array(['registrant@test.com']) + end + + it 'has subject' do + subject = 'Domeeni test.com registreerija vahetus protseduur on algatatud' \ + ' / test.com registrant change' + + expect(message.subject).to eq(subject) + end + + it 'sends message' do + expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + + describe '#rejected' do + let(:domain) { instance_spy(Domain, name: 'test.com', new_registrant_email: 'new.registrant@test.com') } + let(:registrar) { instance_spy(Registrar) } + let(:registrant) { instance_spy(Registrant) } + + let(:domain_presenter) { instance_spy(DomainPresenter) } + let(:registrar_presenter) { instance_spy(RegistrarPresenter) } + let(:registrant_presenter) { instance_spy(RegistrantPresenter) } + + subject(:message) { described_class.rejected(domain: domain, + registrar: registrar, + registrant: registrant) + } + + before :example do + expect(DomainPresenter).to receive(:new).and_return(domain_presenter) + expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter) + expect(RegistrantPresenter).to receive(:new).and_return(registrant_presenter) + end + + it 'has sender' do + expect(message.from).to eq(['noreply@internet.ee']) + end + + it 'has new registrant\s email as a recipient' do + expect(message.to).to match_array(['new.registrant@test.com']) + end + + it 'has subject' do + subject = 'Domeeni test.com registreerija vahetuse taotlus tagasi lükatud' \ + ' / test.com registrant change declined' + + expect(message.subject).to eq(subject) + end + + it 'sends message' do + expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + + describe '#expired' do + let(:domain) { instance_spy(Domain, name: 'test.com', new_registrant_email: 'new.registrant@test.com') } + let(:registrar) { instance_spy(Registrar) } + let(:registrant) { instance_spy(Registrant) } + + let(:domain_presenter) { instance_spy(DomainPresenter) } + let(:registrar_presenter) { instance_spy(RegistrarPresenter) } + let(:registrant_presenter) { instance_spy(RegistrantPresenter) } + + subject(:message) { described_class.expired(domain: domain, + registrar: registrar, + registrant: registrant) + } + + before :example do + expect(DomainPresenter).to receive(:new).and_return(domain_presenter) + expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter) + expect(RegistrantPresenter).to receive(:new).and_return(registrant_presenter) + end + + it 'has sender' do + expect(message.from).to eq(['noreply@internet.ee']) + end + + it 'has new registrant\s email as a recipient' do + expect(message.to).to match_array(['new.registrant@test.com']) + end + + it 'has subject' do + subject = 'Domeeni test.com registreerija vahetuse taotlus on tühistatud' \ + ' / test.com registrant change cancelled' + + expect(message.subject).to eq(subject) + end + + it 'sends message' do + expect { message.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end +end diff --git a/spec/models/bank_transaction_spec.rb b/spec/models/bank_transaction_spec.rb index 27640453c..627427d57 100644 --- a/spec/models/bank_transaction_spec.rb +++ b/spec/models/bank_transaction_spec.rb @@ -34,17 +34,6 @@ describe BankTransaction do @bank_transaction.errors.full_messages.should match_array([]) end - it 'should bind transaction with invoice manually' do - r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663') - invoice = r.issue_prepayment_invoice(200, 'add some money') - - bt = Fabricate(:bank_transaction, { sum: 240 }) - bt.bind_invoice(invoice.number) - - invoice.receipt_date.should_not be_blank - r.cash_account.balance.should == 200.0 - end - it 'should not bind transaction with mismatching sums' do r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663') invoice = r.issue_prepayment_invoice(200, 'add some money') diff --git a/spec/models/concerns/domain/expirable_spec.rb b/spec/models/concerns/domain/expirable_spec.rb new file mode 100644 index 000000000..2a2c9b9cf --- /dev/null +++ b/spec/models/concerns/domain/expirable_spec.rb @@ -0,0 +1,65 @@ +require 'rails_helper' + +RSpec.describe Domain, db: false do + it { is_expected.to alias_attribute(:expire_time, :valid_to) } + + describe '::expired', db: true do + before :example do + travel_to Time.zone.parse('05.07.2010 00:00') + + Fabricate(:zonefile_setting, origin: 'ee') + + Fabricate.create(:domain, id: 1, expire_time: Time.zone.parse('04.07.2010 23:59')) + Fabricate.create(:domain, id: 2, expire_time: Time.zone.parse('05.07.2010 00:00')) + Fabricate.create(:domain, id: 3, expire_time: Time.zone.parse('05.07.2010 00:01')) + end + + it 'returns expired domains' do + expect(described_class.expired.ids).to eq([1, 2]) + end + end + + describe '#registered?' do + let(:domain) { described_class.new } + + context 'when not expired' do + before :example do + expect(domain).to receive(:expired?).and_return(false) + end + + specify { expect(domain).to be_registered } + end + + context 'when expired' do + before :example do + expect(domain).to receive(:expired?).and_return(true) + end + + specify { expect(domain).to_not be_registered } + end + end + + describe '#expired?' do + before :example do + travel_to Time.zone.parse('05.07.2010 00:00') + end + + context 'when :expire_time is in the past' do + let(:domain) { described_class.new(expire_time: Time.zone.parse('04.07.2010 23:59')) } + + specify { expect(domain).to be_expired } + end + + context 'when :expire_time is now' do + let(:domain) { described_class.new(expire_time: Time.zone.parse('05.07.2010 00:00')) } + + specify { expect(domain).to be_expired } + end + + context 'when :expire_time is in the future' do + let(:domain) { described_class.new(expire_time: Time.zone.parse('05.07.2010 00:01')) } + + specify { expect(domain).to_not be_expired } + end + end +end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index a5a680439..b20f4bf60 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -1,9 +1,8 @@ require 'rails_helper' -describe Contact do +RSpec.describe Contact do before :example do Fabricate(:zonefile_setting, origin: 'ee') - @api_user = Fabricate(:api_user) end context 'about class' do @@ -363,3 +362,25 @@ describe Contact, '.destroy_orphans' do Contact.count.should == cc end end + +RSpec.describe Contact, db: false do + describe '::names' do + before :example do + expect(described_class).to receive(:pluck).with(:name).and_return('names') + end + + it 'returns names' do + expect(described_class.names).to eq('names') + end + end + + describe '::emails' do + before :example do + expect(described_class).to receive(:pluck).with(:email).and_return('emails') + end + + it 'returns emails' do + expect(described_class.emails).to eq('emails') + end + end +end diff --git a/spec/models/dnskey_spec.rb b/spec/models/dnskey_spec.rb index ef0f52475..5267f3eac 100644 --- a/spec/models/dnskey_spec.rb +++ b/spec/models/dnskey_spec.rb @@ -2,6 +2,25 @@ require 'rails_helper' describe Dnskey do before :example do + Setting.ds_algorithm = 2 + Setting.ds_data_allowed = true + Setting.ds_data_with_key_allowed = true + Setting.key_data_allowed = true + + Setting.dnskeys_min_count = 0 + Setting.dnskeys_max_count = 9 + Setting.ns_min_count = 2 + Setting.ns_max_count = 11 + + Setting.transfer_wait_time = 0 + + Setting.admin_contacts_min_count = 1 + Setting.admin_contacts_max_count = 10 + Setting.tech_contacts_min_count = 0 + Setting.tech_contacts_max_count = 10 + + Setting.client_side_status_editing_enabled = true + Fabricate(:zonefile_setting, origin: 'ee') end diff --git a/spec/models/domain_contact_spec.rb b/spec/models/domain_contact_spec.rb index de62276df..783d7e69b 100644 --- a/spec/models/domain_contact_spec.rb +++ b/spec/models/domain_contact_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' describe DomainContact do - before :all do + before :example do @api_user = Fabricate(:domain_contact) end context 'with invalid attribute' do - before :all do + before :example do @domain_contact = DomainContact.new end @@ -31,7 +31,7 @@ describe DomainContact do end context 'with valid attributes' do - before :all do + before :example do @domain_contact = Fabricate(:domain_contact) end @@ -51,10 +51,12 @@ describe DomainContact do end it 'should have one version' do + @domain_contact = Fabricate.create(:domain_contact) + with_versioning do @domain_contact.versions.reload.should == [] - @domain_contact.updated_at = Time.zone.now # trigger new version - @domain_contact.save + @domain_contact.contact = Fabricate.create(:contact) + @domain_contact.save! @domain_contact.errors.full_messages.should match_array([]) @domain_contact.versions.size.should == 1 end @@ -62,7 +64,7 @@ describe DomainContact do end context 'with valid attributes with tech domain contact' do - before :all do + before :example do @domain_contact = Fabricate(:tech_domain_contact) end @@ -82,10 +84,12 @@ describe DomainContact do end it 'should have one version' do + @domain_contact = Fabricate.create(:domain_contact) + with_versioning do @domain_contact.versions.reload.should == [] - @domain_contact.updated_at = Time.zone.now # trigger new version - @domain_contact.save + @domain_contact.contact = Fabricate.create(:contact) + @domain_contact.save! @domain_contact.errors.full_messages.should match_array([]) @domain_contact.versions.size.should == 1 end @@ -93,7 +97,7 @@ describe DomainContact do end context 'with valid attributes with admin domain contact' do - before :all do + before :example do @domain_contact = Fabricate(:admin_domain_contact) end @@ -115,7 +119,7 @@ describe DomainContact do it 'should have one version' do with_versioning do @domain_contact.versions.reload.should == [] - @domain_contact.updated_at = Time.zone.now # trigger new version + @domain_contact.contact = Fabricate.create(:contact) @domain_contact.save @domain_contact.errors.full_messages.should match_array([]) @domain_contact.versions.size.should == 1 diff --git a/spec/models/domain_cron_spec.rb b/spec/models/domain_cron_spec.rb new file mode 100644 index 000000000..50c4ca80a --- /dev/null +++ b/spec/models/domain_cron_spec.rb @@ -0,0 +1,41 @@ +require 'rails_helper' + +RSpec.describe DomainCron do + it 'should expire domains' do + Fabricate(:zonefile_setting, origin: 'ee') + @domain = Fabricate(:domain) + + Setting.expire_warning_period = 1 + Setting.redemption_grace_period = 1 + + described_class.start_expire_period + @domain.statuses.include?(DomainStatus::EXPIRED).should == false + + old_valid_to = Time.zone.now - 10.days + @domain.valid_to = old_valid_to + @domain.save + + described_class.start_expire_period + @domain.reload + @domain.statuses.include?(DomainStatus::EXPIRED).should == true + + described_class.start_expire_period + @domain.reload + @domain.statuses.include?(DomainStatus::EXPIRED).should == true + end + + it 'should start redemption grace period' do + Fabricate(:zonefile_setting, origin: 'ee') + @domain = Fabricate(:domain) + + old_valid_to = Time.zone.now - 10.days + @domain.valid_to = old_valid_to + @domain.statuses = [DomainStatus::EXPIRED] + @domain.outzone_at, @domain.delete_at = nil, nil + @domain.save + + described_class.start_expire_period + @domain.reload + @domain.statuses.include?(DomainStatus::EXPIRED).should == true + end +end diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 9560f7505..78ada6d51 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -2,6 +2,25 @@ require 'rails_helper' RSpec.describe Domain do before :example do + Setting.ds_algorithm = 2 + Setting.ds_data_allowed = true + Setting.ds_data_with_key_allowed = true + Setting.key_data_allowed = true + + Setting.dnskeys_min_count = 0 + Setting.dnskeys_max_count = 9 + Setting.ns_min_count = 2 + Setting.ns_max_count = 11 + + Setting.transfer_wait_time = 0 + + Setting.admin_contacts_min_count = 1 + Setting.admin_contacts_max_count = 10 + Setting.tech_contacts_min_count = 0 + Setting.tech_contacts_max_count = 10 + + Setting.client_side_status_editing_enabled = true + Fabricate(:zonefile_setting, origin: 'ee') Fabricate(:zonefile_setting, origin: 'pri.ee') Fabricate(:zonefile_setting, origin: 'med.ee') @@ -157,24 +176,11 @@ RSpec.describe Domain do end it 'should start redemption grace period' do - DomainCron.start_redemption_grace_period - @domain.reload - @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false - - @domain.outzone_at = Time.zone.now - @domain.statuses << DomainStatus::SERVER_MANUAL_INZONE # this prohibits server_hold - @domain.save + domain = Fabricate(:domain) DomainCron.start_redemption_grace_period - @domain.reload - @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false - - @domain.statuses = [] - @domain.save - - DomainCron.start_redemption_grace_period - @domain.reload - @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true + domain.reload + domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false end it 'should set force delete time' do @@ -329,139 +335,6 @@ RSpec.describe Domain do end end - it 'should start redemption grace period' do - DomainCron.start_redemption_grace_period - @domain.reload - @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false - - @domain.outzone_at = Time.zone.now - @domain.statuses << DomainStatus::SERVER_MANUAL_INZONE # this prohibits server_hold - @domain.save - - DomainCron.start_redemption_grace_period - @domain.reload - @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false - - @domain.statuses = [] - @domain.save - - DomainCron.start_redemption_grace_period - @domain.reload - @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true - end - - it 'should know its create price' do - Fabricate(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '1year', - price: 1.50, - valid_from: Time.zone.parse('2015-01-01'), - valid_to: nil - }) - - domain = Fabricate(:domain) - domain.pricelist('create').price.amount.should == 1.50 - - domain = Fabricate(:domain, period: 12, period_unit: 'm') - domain.pricelist('create').price.amount.should == 1.50 - - domain = Fabricate(:domain, period: 365, period_unit: 'd') - domain.pricelist('create').price.amount.should == 1.50 - - Fabricate(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '2years', - price: 3, - valid_from: Time.zone.parse('2015-01-01'), - valid_to: nil - }) - - domain = Fabricate(:domain, period: 2) - domain.pricelist('create').price.amount.should == 3.0 - - domain = Fabricate(:domain, period: 24, period_unit: 'm') - domain.pricelist('create').price.amount.should == 3.0 - - domain = Fabricate(:domain, period: 730, period_unit: 'd') - domain.pricelist('create').price.amount.should == 3.0 - - Fabricate(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '3years', - price: 6, - valid_from: Time.zone.parse('2015-01-01'), - valid_to: nil - }) - - domain = Fabricate(:domain, period: 3) - domain.pricelist('create').price.amount.should == 6.0 - - domain = Fabricate(:domain, period: 36, period_unit: 'm') - domain.pricelist('create').price.amount.should == 6.0 - - domain = Fabricate(:domain, period: 1095, period_unit: 'd') - domain.pricelist('create').price.amount.should == 6.0 - end - - it 'should know its renew price' do - Fabricate(:pricelist, { - category: 'ee', - operation_category: 'renew', - duration: '1year', - price: 1.30, - valid_from: Time.zone.parse('2015-01-01'), - valid_to: nil - }) - - domain = Fabricate(:domain) - domain.pricelist('renew').price.amount.should == 1.30 - - domain = Fabricate(:domain, period: 12, period_unit: 'm') - domain.pricelist('renew').price.amount.should == 1.30 - - domain = Fabricate(:domain, period: 365, period_unit: 'd') - domain.pricelist('renew').price.amount.should == 1.30 - - Fabricate(:pricelist, { - category: 'ee', - operation_category: 'renew', - duration: '2years', - price: 3.1, - valid_from: Time.zone.parse('2015-01-01'), - valid_to: nil - }) - - domain = Fabricate(:domain, period: 2) - domain.pricelist('renew').price.amount.should == 3.1 - - domain = Fabricate(:domain, period: 24, period_unit: 'm') - domain.pricelist('renew').price.amount.should == 3.1 - - domain = Fabricate(:domain, period: 730, period_unit: 'd') - domain.pricelist('renew').price.amount.should == 3.1 - - Fabricate(:pricelist, { - category: 'ee', - operation_category: 'renew', - duration: '3years', - price: 6.1, - valid_from: Time.zone.parse('2015-01-01'), - valid_to: nil - }) - - domain = Fabricate(:domain, period: 3) - domain.pricelist('renew').price.amount.should == 6.1 - - domain = Fabricate(:domain, period: 36, period_unit: 'm') - domain.pricelist('renew').price.amount.should == 6.1 - - domain = Fabricate(:domain, period: 1095, period_unit: 'd') - domain.pricelist('renew').price.amount.should == 6.1 - end - it 'should set pending update' do @domain.statuses = DomainStatus::OK # restore @domain.save @@ -826,6 +699,11 @@ RSpec.describe Domain do end RSpec.describe Domain, db: false do + it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) } + it { is_expected.to alias_attribute(:delete_time, :delete_at) } + it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) } + it { is_expected.to alias_attribute(:outzone_time, :outzone_at) } + describe '::expire_warning_period', db: true do before :example do Setting.expire_warning_period = 1 @@ -863,6 +741,70 @@ RSpec.describe Domain, db: false do end end + describe '#admin_contact_names' do + let(:domain) { described_class.new } + + before :example do + expect(Contact).to receive(:names).and_return('names') + end + + it 'returns admin contact names' do + expect(domain.admin_contact_names).to eq('names') + end + end + + describe '#admin_contact_emails' do + let(:domain) { described_class.new } + + before :example do + expect(Contact).to receive(:emails).and_return('emails') + end + + it 'returns admin contact emails' do + expect(domain.admin_contact_emails).to eq('emails') + end + end + + describe '#tech_contact_names' do + let(:domain) { described_class.new } + + before :example do + expect(Contact).to receive(:names).and_return('names') + end + + it 'returns technical contact names' do + expect(domain.tech_contact_names).to eq('names') + end + end + + describe '#nameserver_hostnames' do + let(:domain) { described_class.new } + + before :example do + expect(Nameserver).to receive(:hostnames).and_return('hostnames') + end + + it 'returns name server hostnames' do + expect(domain.nameserver_hostnames).to eq('hostnames') + end + end + + describe '#primary_contact_emails' do + let(:domain) { described_class.new } + + before :example do + expect(domain).to receive(:registrant_email).and_return('registrant@test.com') + expect(domain).to receive(:admin_contact_emails).and_return(%w(admin.contact@test.com admin.contact@test.com)) + end + + it 'returns unique list of registrant and administrative contact emails' do + expect(domain.primary_contact_emails).to match_array(%w( + registrant@test.com + admin.contact@test.com + )) + end + end + describe '#set_graceful_expired' do let(:domain) { described_class.new } @@ -882,4 +824,52 @@ RSpec.describe Domain, db: false do expect(domain.delete_at).to eq(Time.zone.parse('08.07.2010 10:30')) end end + + describe '::outzone_candidates', db: true do + before :example do + travel_to Time.zone.parse('05.07.2010 00:00') + + Fabricate(:zonefile_setting, origin: 'ee') + + Fabricate.create(:domain, id: 1, outzone_time: Time.zone.parse('04.07.2010 23:59')) + Fabricate.create(:domain, id: 2, outzone_time: Time.zone.parse('05.07.2010 00:00')) + Fabricate.create(:domain, id: 3, outzone_time: Time.zone.parse('05.07.2010 00:01')) + end + + it 'returns domains with outzone time in the past' do + expect(described_class.outzone_candidates.ids).to eq([1]) + end + end + + describe '::delete_candidates', db: true do + before :example do + travel_to Time.zone.parse('05.07.2010 00:00') + + Fabricate(:zonefile_setting, origin: 'ee') + + Fabricate.create(:domain, id: 1, delete_time: Time.zone.parse('04.07.2010 23:59')) + Fabricate.create(:domain, id: 2, delete_time: Time.zone.parse('05.07.2010 00:00')) + Fabricate.create(:domain, id: 3, delete_time: Time.zone.parse('05.07.2010 00:01')) + end + + it 'returns domains with delete time in the past' do + expect(described_class.delete_candidates.ids).to eq([1]) + end + end + + describe '#new_registrant_email' do + let(:domain) { described_class.new(pending_json: { new_registrant_email: 'test@test.com' }) } + + it 'returns new registrant\'s email' do + expect(domain.new_registrant_email).to eq('test@test.com') + end + end + + describe '#new_registrant_id' do + let(:domain) { described_class.new(pending_json: { new_registrant_id: 1 }) } + + it 'returns new registrant\'s id' do + expect(domain.new_registrant_id).to eq(1) + end + end end diff --git a/spec/models/domain_transfer_spec.rb b/spec/models/domain_transfer_spec.rb index e46b46aca..3609b2f7d 100644 --- a/spec/models/domain_transfer_spec.rb +++ b/spec/models/domain_transfer_spec.rb @@ -2,6 +2,25 @@ require 'rails_helper' describe DomainTransfer do before :example do + Setting.ds_algorithm = 2 + Setting.ds_data_allowed = true + Setting.ds_data_with_key_allowed = true + Setting.key_data_allowed = true + + Setting.dnskeys_min_count = 0 + Setting.dnskeys_max_count = 9 + Setting.ns_min_count = 2 + Setting.ns_max_count = 11 + + Setting.transfer_wait_time = 0 + + Setting.admin_contacts_min_count = 1 + Setting.admin_contacts_max_count = 10 + Setting.tech_contacts_min_count = 0 + Setting.tech_contacts_max_count = 10 + + Setting.client_side_status_editing_enabled = true + Fabricate(:zonefile_setting, origin: 'ee') end diff --git a/spec/models/epp_domain_spec.rb b/spec/models/epp_domain_spec.rb deleted file mode 100644 index 9dab00c8a..000000000 --- a/spec/models/epp_domain_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'rails_helper' - -describe Epp::Domain do - context 'with sufficient settings' do - let(:domain) { Fabricate(:epp_domain) } - end -end diff --git a/spec/models/keyrelay_spec.rb b/spec/models/keyrelay_spec.rb index 5243cbf6c..73e26a098 100644 --- a/spec/models/keyrelay_spec.rb +++ b/spec/models/keyrelay_spec.rb @@ -2,6 +2,25 @@ require 'rails_helper' describe Keyrelay do before :example do + Setting.ds_algorithm = 2 + Setting.ds_data_allowed = true + Setting.ds_data_with_key_allowed = true + Setting.key_data_allowed = true + + Setting.dnskeys_min_count = 0 + Setting.dnskeys_max_count = 9 + Setting.ns_min_count = 2 + Setting.ns_max_count = 11 + + Setting.transfer_wait_time = 0 + + Setting.admin_contacts_min_count = 1 + Setting.admin_contacts_max_count = 10 + Setting.tech_contacts_min_count = 0 + Setting.tech_contacts_max_count = 10 + + Setting.client_side_status_editing_enabled = true + Fabricate(:zonefile_setting, origin: 'ee') end diff --git a/spec/models/nameserver_spec.rb b/spec/models/nameserver_spec.rb index 586f83390..1844bc0f9 100644 --- a/spec/models/nameserver_spec.rb +++ b/spec/models/nameserver_spec.rb @@ -2,6 +2,25 @@ require 'rails_helper' describe Nameserver do before :example do + Setting.ds_algorithm = 2 + Setting.ds_data_allowed = true + Setting.ds_data_with_key_allowed = true + Setting.key_data_allowed = true + + Setting.dnskeys_min_count = 0 + Setting.dnskeys_max_count = 9 + Setting.ns_min_count = 2 + Setting.ns_max_count = 11 + + Setting.transfer_wait_time = 0 + + Setting.admin_contacts_min_count = 1 + Setting.admin_contacts_max_count = 10 + Setting.tech_contacts_min_count = 0 + Setting.tech_contacts_max_count = 10 + + Setting.client_side_status_editing_enabled = true + Fabricate(:zonefile_setting, origin: 'ee') end @@ -92,3 +111,15 @@ describe Nameserver do end end end + +RSpec.describe Nameserver do + describe '::hostnames', db: false do + before :example do + expect(described_class).to receive(:pluck).with(:hostname).and_return('hostnames') + end + + it 'returns names' do + expect(described_class.hostnames).to eq('hostnames') + end + end +end diff --git a/spec/models/registrant_verification_spec.rb b/spec/models/registrant_verification_spec.rb index fc9b8ab82..5997797c7 100644 --- a/spec/models/registrant_verification_spec.rb +++ b/spec/models/registrant_verification_spec.rb @@ -2,6 +2,25 @@ require 'rails_helper' describe RegistrantVerification do before :example do + Setting.ds_algorithm = 2 + Setting.ds_data_allowed = true + Setting.ds_data_with_key_allowed = true + Setting.key_data_allowed = true + + Setting.dnskeys_min_count = 0 + Setting.dnskeys_max_count = 9 + Setting.ns_min_count = 2 + Setting.ns_max_count = 11 + + Setting.transfer_wait_time = 0 + + Setting.admin_contacts_min_count = 1 + Setting.admin_contacts_max_count = 10 + Setting.tech_contacts_min_count = 0 + Setting.tech_contacts_max_count = 10 + + Setting.client_side_status_editing_enabled = true + Fabricate(:zonefile_setting, origin: 'ee') end context 'with invalid attribute' do diff --git a/spec/models/zonefile_setting_spec.rb b/spec/models/zonefile_setting_spec.rb new file mode 100644 index 000000000..d1cd61119 --- /dev/null +++ b/spec/models/zonefile_setting_spec.rb @@ -0,0 +1,17 @@ +require 'rails_helper' + +RSpec.describe ZonefileSetting, db: false do + it 'has versions' do + expect(described_class.new.versions).to eq([]) + end + + describe '::origins' do + before :example do + expect(described_class).to receive(:pluck).with(:origin).and_return('origins') + end + + it 'returns origins' do + expect(described_class.origins).to eq('origins') + end + end +end diff --git a/spec/presenters/domain_presenter_spec.rb b/spec/presenters/domain_presenter_spec.rb new file mode 100644 index 000000000..79adcc68f --- /dev/null +++ b/spec/presenters/domain_presenter_spec.rb @@ -0,0 +1,115 @@ +require 'rails_helper' + +RSpec.describe DomainPresenter do + let(:presenter) { described_class.new(domain: domain, view: view) } + + describe '#on_hold_date' do + subject(:on_hold_date) { presenter.on_hold_date } + + context 'when present' do + let(:domain) { instance_double(Domain, on_hold_time: '05.07.2010') } + + it 'returns localized date' do + expect(view).to receive(:l).with('05.07.2010', format: :date).and_return('on hold date') + expect(on_hold_date).to eq('on hold date') + end + end + + context 'when absent' do + let(:domain) { instance_double(Domain, on_hold_time: nil) } + + specify { expect(on_hold_date).to be_nil } + end + end + + describe '#delete_date' do + subject(:delete_date) { presenter.delete_date } + + context 'when present' do + let(:domain) { instance_double(Domain, delete_time: '05.07.2010') } + + it 'returns localized date' do + expect(view).to receive(:l).with('05.07.2010', format: :date).and_return('delete date') + expect(delete_date).to eq('delete date') + end + end + + context 'when absent' do + let(:domain) { instance_double(Domain, delete_time: nil) } + + specify { expect(delete_date).to be_nil } + end + end + + describe '#force_delete_date' do + subject(:force_delete_date) { presenter.force_delete_date } + + context 'when present' do + let(:domain) { instance_double(Domain, force_delete_time: '05.07.2010') } + + it 'returns localized date' do + expect(view).to receive(:l).with('05.07.2010', format: :date).and_return('delete date') + expect(force_delete_date).to eq('delete date') + end + end + + context 'when absent' do + let(:domain) { instance_double(Domain, force_delete_time: nil) } + + specify { expect(force_delete_date).to be_nil } + end + end + + describe '#admin_contact_names' do + let(:domain) { instance_double(Domain) } + + before :example do + expect(domain).to receive(:admin_contact_names).and_return(%w(test1 test2 test3)) + end + + it 'returns admin contact names' do + expect(presenter.admin_contact_names).to eq('test1, test2, test3') + end + end + + describe '#tech_contact_names' do + let(:domain) { instance_double(Domain) } + + before :example do + expect(domain).to receive(:tech_contact_names).and_return(%w(test1 test2 test3)) + end + + it 'returns technical contact names' do + expect(presenter.tech_contact_names).to eq('test1, test2, test3') + end + end + + describe '#nameserver_names' do + let(:domain) { instance_double(Domain) } + + before :example do + expect(domain).to receive(:nameserver_hostnames).and_return(%w(test1 test2 test3)) + end + + it 'returns nameserver names' do + expect(presenter.nameserver_names).to eq('test1, test2, test3') + end + end + + + domain_delegatable_attributes = %i( + name + registrant_name + ) + + domain_delegatable_attributes.each do |attribute_name| + describe "##{attribute_name}" do + let(:domain) { instance_spy(Domain) } + + it 'delegates to domain' do + presenter.send(attribute_name) + expect(domain).to have_received(attribute_name) + end + end + end +end diff --git a/spec/presenters/registrant_presenter_spec.rb b/spec/presenters/registrant_presenter_spec.rb new file mode 100644 index 000000000..894dd40d5 --- /dev/null +++ b/spec/presenters/registrant_presenter_spec.rb @@ -0,0 +1,30 @@ +require 'rails_helper' + +RSpec.describe RegistrantPresenter do + let(:registrant) { instance_double(Registrant) } + let(:presenter) { described_class.new(registrant: registrant, view: view) } + + registrant_delegate_attributes = %i( + name + ident + email + priv? + street + city + ) + + registrant_delegate_attributes.each do |attribute_name| + describe "##{attribute_name}" do + it 'delegetes to registrant' do + expect(registrant).to receive(attribute_name).and_return('test') + expect(presenter.send(attribute_name)).to eq('test') + end + end + end + + describe '#country' do + it 'returns country name' do + expect(presenter.country).to be_nil + end + end +end diff --git a/spec/presenters/registrar_presenter_spec.rb b/spec/presenters/registrar_presenter_spec.rb new file mode 100644 index 000000000..8223341a8 --- /dev/null +++ b/spec/presenters/registrar_presenter_spec.rb @@ -0,0 +1,34 @@ +require 'rails_helper' + +RSpec.describe RegistrarPresenter do + let(:registrar) { instance_double(Registrar) } + let(:presenter) { described_class.new(registrar: registrar, view: view) } + + describe '#name' do + it 'returns name' do + expect(registrar).to receive(:name).and_return('test name') + expect(presenter.name).to eq('test name') + end + end + + describe '#email' do + it 'returns email' do + expect(registrar).to receive(:email).and_return('test email') + expect(presenter.email).to eq('test email') + end + end + + describe '#phone' do + it 'returns phone' do + expect(registrar).to receive(:phone).and_return('test phone') + expect(presenter.phone).to eq('test phone') + end + end + + describe '#url' do + it 'returns url' do + expect(registrar).to receive(:url).and_return('test url') + expect(presenter.url).to eq('test url') + end + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 2e6927569..9411702f5 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -15,33 +15,11 @@ require 'support/matchers/alias_attribute' require 'support/matchers/active_job' require 'support/capybara' require 'support/database_cleaner' -require 'support/request' require 'support/paper_trail' +require 'support/settings' ActiveRecord::Migration.maintain_test_schema! -# create general settings -def create_settings - Setting.ds_algorithm = 2 - Setting.ds_data_allowed = true - Setting.ds_data_with_key_allowed = true - Setting.key_data_allowed = true - - Setting.dnskeys_min_count = 0 - Setting.dnskeys_max_count = 9 - Setting.ns_min_count = 2 - Setting.ns_max_count = 11 - - Setting.transfer_wait_time = 0 - - Setting.admin_contacts_min_count = 1 - Setting.admin_contacts_max_count = 10 - Setting.tech_contacts_min_count = 0 - Setting.tech_contacts_max_count = 10 - - Setting.client_side_status_editing_enabled = true -end - RSpec.configure do |config| config.include ActionView::TestCase::Behavior, type: :presenter config.include ActiveSupport::Testing::TimeHelpers @@ -52,27 +30,6 @@ RSpec.configure do |config| end config.use_transactional_fixtures = false - - config.before(:all) do - create_settings - end - - config.before(:all, epp: true) do - create_settings - end - - config.before(:each, js: true) do - create_settings - end - - config.before(:each, type: :request) do - create_settings - end - - config.before(:each, type: :model) do - create_settings - end - config.infer_spec_type_from_file_location! config.expect_with :rspec do |c| diff --git a/spec/routing/registrant/domain_delete_confirms_routing_spec.rb b/spec/routing/registrant/domain_delete_confirms_routing_spec.rb new file mode 100644 index 000000000..cf7691bb4 --- /dev/null +++ b/spec/routing/registrant/domain_delete_confirms_routing_spec.rb @@ -0,0 +1,9 @@ +require 'rails_helper' + +RSpec.describe Registrant::DomainDeleteConfirmsController do + describe 'routing' do + it 'routes to #show' do + expect(get: '/registrant/domain_delete_confirms/1').to route_to('registrant/domain_delete_confirms#show', id: '1') + end + end +end diff --git a/spec/routing/registrant/domain_update_confirms_routing_spec.rb b/spec/routing/registrant/domain_update_confirms_routing_spec.rb new file mode 100644 index 000000000..9bc98c391 --- /dev/null +++ b/spec/routing/registrant/domain_update_confirms_routing_spec.rb @@ -0,0 +1,9 @@ +require 'rails_helper' + +RSpec.describe Registrant::DomainUpdateConfirmsController do + describe 'routing' do + it 'routes to #show' do + expect(get: '/registrant/domain_update_confirms/1').to route_to('registrant/domain_update_confirms#show', id: '1') + end + end +end diff --git a/spec/support/request.rb b/spec/support/request.rb deleted file mode 100644 index fedf1ae04..000000000 --- a/spec/support/request.rb +++ /dev/null @@ -1,104 +0,0 @@ -module Request - def get_with_auth(path, params, epp_user) - get path, params, env_with_auth(epp_user) - end - - def delete_with_auth(path, epp_user) - delete path, params, env_with_auth(epp_user) - end - - def post_with_auth(path, params, epp_user) - post path, params, env_with_auth(epp_user) - end - - def patch_with_auth(path, params, epp_user) - patch path, params, env_with_auth(epp_user) - end - - def env - { - 'Accept' => 'application/json', - 'Content-Type' => 'application/json' - } - end - - def env_with_auth(epp_user) - env.merge({ - 'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials( - epp_user.username, epp_user.password - ) - }) - end -end - -module Autodoc - class Document - def route_info_doc - return unless example.metadata[:route_info_doc] - route = request.env["rack.routing_args"][:route_info] - return unless route.route_params.is_a?(Hash) - return if route.route_params.empty? - - rows = [ - "| Field name | Required | Type | Allowed values | Description |", - "| ---------- | -------- | ---- | -------------- | ----------- |" - ] - - route.route_params.each do |name, desc| - details = [] - details << "| #{name} " - details << "| #{desc[:required]} " - details << "| #{desc[:type]} " - details << "| #{ranges_from_array(desc[:values])} " - details << "| #{desc[:desc]} |" - rows << details.join - end - - pretty_table(rows).join("\n") - end - - def pretty_table(rows) - # longest_in_col = 0 - matrix_array = [] - rows.each do |x| - matrix_array << x.split('|') + [''] # [''] is because split loses last | - end - - new_arr = [] - matrix_array.transpose.each do |col| - new_col = [] - longest = col.max_by(&:size).size - - col.each do |r| - new_col << r.center(longest) - end - new_arr << new_col - end - - matrix_array = [] - new_arr.transpose.each do |x| - matrix_array << x.join('|') - end - - matrix_array - end - - def ranges_from_array(a) - return unless a - ranges = a.sort.uniq.reduce([]) do |spans, n| - return a if n.is_a?(String) - if spans.empty? || spans.last.last != n - 1 - spans + [n..n] - else - spans[0..-2] + [spans.last.first..n] - end - end - - ranges - end - end -end - -RSpec.configure do |c| - c.include Request, type: :request -end diff --git a/spec/support/settings.rb b/spec/support/settings.rb new file mode 100644 index 000000000..7a5aebf3b --- /dev/null +++ b/spec/support/settings.rb @@ -0,0 +1,26 @@ +RSpec.configure do |config| + config.before :example do |example| + if example.metadata[:db] + Fabricate(:zonefile_setting, origin: 'com') + + Setting.ds_algorithm = 2 + Setting.ds_data_allowed = true + Setting.ds_data_with_key_allowed = true + Setting.key_data_allowed = true + + Setting.dnskeys_min_count = 0 + Setting.dnskeys_max_count = 9 + Setting.ns_min_count = 2 + Setting.ns_max_count = 11 + + Setting.transfer_wait_time = 0 + + Setting.admin_contacts_min_count = 1 + Setting.admin_contacts_max_count = 10 + Setting.tech_contacts_min_count = 0 + Setting.tech_contacts_max_count = 10 + + Setting.client_side_status_editing_enabled = true + end + end +end diff --git a/spec/views/mailers/domain_delete_mailer/confirm.html.erb_spec.rb b/spec/views/mailers/domain_delete_mailer/confirm.html.erb_spec.rb new file mode 100644 index 000000000..7d7776d0a --- /dev/null +++ b/spec/views/mailers/domain_delete_mailer/confirm.html.erb_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' +require_relative 'confirm_shared' + +RSpec.describe 'mailers/domain_delete_mailer/confirm.html.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english' + end + + include_examples 'domain delete mailer confirm' +end diff --git a/spec/views/mailers/domain_delete_mailer/confirm.text.erb_spec.rb b/spec/views/mailers/domain_delete_mailer/confirm.text.erb_spec.rb new file mode 100644 index 000000000..b5f257b86 --- /dev/null +++ b/spec/views/mailers/domain_delete_mailer/confirm.text.erb_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' +require_relative 'confirm_shared' + +RSpec.describe 'mailers/domain_delete_mailer/confirm.text.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english' + end + + include_examples 'domain delete mailer confirm' +end diff --git a/spec/views/mailers/domain_delete_mailer/confirm_shared.rb b/spec/views/mailers/domain_delete_mailer/confirm_shared.rb new file mode 100644 index 000000000..960e5cf42 --- /dev/null +++ b/spec/views/mailers/domain_delete_mailer/confirm_shared.rb @@ -0,0 +1,35 @@ +require 'rails_helper' + +RSpec.shared_examples 'domain delete mailer confirm' do + let(:domain) { instance_spy(DomainPresenter) } + let(:lang_count) { 2 } + + before :example do + assign(:domain, domain) + assign(:registrar, nil) + assign(:confirm_url, 'test confirm url') + end + + it 'has registrar info in estonian' do + render + expect(rendered).to have_text('test registrar estonian') + end + + it 'has registrar info in english' do + render + expect(rendered).to have_text('test registrar english') + end + + it 'has domain name' do + mention_count = 1 * lang_count + expect(domain).to receive(:name).exactly(mention_count).times.and_return('test domain name') + render + expect(rendered).to have_text('test domain name', count: mention_count) + end + + it 'has confirm url' do + mention_count = 1 * lang_count + render + expect(rendered).to have_text('test confirm url', count: mention_count) + end +end diff --git a/spec/views/mailers/domain_delete_mailer/forced.html.erb_spec.rb b/spec/views/mailers/domain_delete_mailer/forced.html.erb_spec.rb new file mode 100644 index 000000000..4f38b7743 --- /dev/null +++ b/spec/views/mailers/domain_delete_mailer/forced.html.erb_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' +require_relative 'forced_shared' + +RSpec.describe 'mailers/domain_delete_mailer/forced.html.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english' + stub_template 'mailers/shared/registrar/_registrar.ru.html' => 'test registrar russian' + end + + include_examples 'domain delete mailer forced' +end diff --git a/spec/views/mailers/domain_delete_mailer/forced.text.erb_spec.rb b/spec/views/mailers/domain_delete_mailer/forced.text.erb_spec.rb new file mode 100644 index 000000000..a53c5beca --- /dev/null +++ b/spec/views/mailers/domain_delete_mailer/forced.text.erb_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' +require_relative 'forced_shared' + +RSpec.describe 'mailers/domain_delete_mailer/forced.text.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english' + stub_template 'mailers/shared/registrar/_registrar.ru.text' => 'test registrar russian' + end + + include_examples 'domain delete mailer forced' +end diff --git a/spec/views/mailers/domain_delete_mailer/forced_shared.rb b/spec/views/mailers/domain_delete_mailer/forced_shared.rb new file mode 100644 index 000000000..b8e696b81 --- /dev/null +++ b/spec/views/mailers/domain_delete_mailer/forced_shared.rb @@ -0,0 +1,43 @@ +require 'rails_helper' + +RSpec.shared_examples 'domain delete mailer forced' do + let(:domain) { instance_spy(DomainPresenter) } + let(:registrar) { instance_spy(RegistrarPresenter) } + let(:registrant) { instance_spy(RegistrantPresenter) } + let(:lang_count) { 3 } + + before :example do + assign(:domain, domain) + assign(:registrar, registrar) + assign(:registrant, registrant) + end + + it 'has registrar info in estonian' do + render + expect(rendered).to have_text('test registrar estonian') + end + + it 'has registrar info in english' do + render + expect(rendered).to have_text('test registrar english') + end + + it 'has registrar info in russian' do + render + expect(rendered).to have_text('test registrar russian') + end + + it 'has domain name' do + mention_count = 5 * lang_count + expect(domain).to receive(:name).exactly(mention_count).times.and_return('test domain name') + render + expect(rendered).to have_text('test domain name', count: mention_count) + end + + it 'has domain force delete date' do + mention_count = 1 * lang_count + expect(domain).to receive(:force_delete_date).exactly(mention_count).times.and_return('test domain force delete date') + render + expect(rendered).to have_text('test domain force delete date', count: mention_count) + end +end diff --git a/spec/views/mailers/domain_expire_mailer/expired.html.erb_spec.rb b/spec/views/mailers/domain_expire_mailer/expired.html.erb_spec.rb new file mode 100644 index 000000000..9e7fb077b --- /dev/null +++ b/spec/views/mailers/domain_expire_mailer/expired.html.erb_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' +require_relative 'expired_shared' + +RSpec.describe 'mailers/domain_expire_mailer/expired.html.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english' + stub_template 'mailers/shared/registrar/_registrar.ru.html' => 'test registrar russian' + end + + include_examples 'domain expire mailer expired' +end diff --git a/spec/views/mailers/domain_expire_mailer/expired.text.erb_spec.rb b/spec/views/mailers/domain_expire_mailer/expired.text.erb_spec.rb new file mode 100644 index 000000000..c842acf15 --- /dev/null +++ b/spec/views/mailers/domain_expire_mailer/expired.text.erb_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' +require_relative 'expired_shared' + +RSpec.describe 'mailers/domain_expire_mailer/expired.text.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english' + stub_template 'mailers/shared/registrar/_registrar.ru.text' => 'test registrar russian' + end + + include_examples 'domain expire mailer expired' +end diff --git a/spec/views/mailers/domain_expire_mailer/expired_shared.rb b/spec/views/mailers/domain_expire_mailer/expired_shared.rb new file mode 100644 index 000000000..0db36548f --- /dev/null +++ b/spec/views/mailers/domain_expire_mailer/expired_shared.rb @@ -0,0 +1,53 @@ +require 'rails_helper' + +RSpec.shared_examples 'domain expire mailer expired' do + let(:domain) { instance_spy(DomainPresenter) } + let(:registrar) { instance_spy(RegistrarPresenter) } + let(:registrant) { instance_spy(RegistrantPresenter) } + let(:lang_count) { 3 } + + before :example do + assign(:domain, domain) + assign(:registrar, registrar) + assign(:registrant, registrant) + end + + it 'has registrar info in estonian' do + render + expect(rendered).to have_text('test registrar estonian') + end + + it 'has registrar info in english' do + render + expect(rendered).to have_text('test registrar english') + end + + it 'has registrar info in russian' do + render + expect(rendered).to have_text('test registrar russian') + end + + it 'has domain name' do + mention_count = 4 * lang_count + expect(domain).to receive(:name).exactly(mention_count).times.and_return('test domain name') + render + expect(rendered).to have_text('test domain name', count: mention_count) + end + + domain_attributes = %i( + on_hold_date + delete_date + registrant_name + admin_contact_names + tech_contact_names + nameserver_names + ) + + domain_attributes.each do |attr_name| + it "has domain #{attr_name}" do + expect(domain).to receive(attr_name).exactly(lang_count).times.and_return("test domain #{attr_name}") + render + expect(rendered).to have_text("test domain #{attr_name}", count: lang_count) + end + end +end diff --git a/spec/views/mailers/registrant_change_mailer/confirm.html.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/confirm.html.erb_spec.rb new file mode 100644 index 000000000..e8aa20326 --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/confirm.html.erb_spec.rb @@ -0,0 +1,13 @@ +require 'rails_helper' +require_relative 'confirm_shared' + +RSpec.describe 'mailers/registrant_change_mailer/confirm.html.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english' + stub_template 'mailers/shared/registrant/_registrant.et.html' => 'test new registrant estonian' + stub_template 'mailers/shared/registrant/_registrant.en.html' => 'test new registrant english' + end + + include_examples 'registrant change mailer confirm' +end diff --git a/spec/views/mailers/registrant_change_mailer/confirm.text.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/confirm.text.erb_spec.rb new file mode 100644 index 000000000..f98f4ec32 --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/confirm.text.erb_spec.rb @@ -0,0 +1,13 @@ +require 'rails_helper' +require_relative 'confirm_shared' + +RSpec.describe 'mailers/registrant_change_mailer/confirm.text.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english' + stub_template 'mailers/shared/registrant/_registrant.et.text' => 'test new registrant estonian' + stub_template 'mailers/shared/registrant/_registrant.en.text' => 'test new registrant english' + end + + include_examples 'registrant change mailer confirm' +end diff --git a/spec/views/mailers/registrant_change_mailer/confirm_shared.rb b/spec/views/mailers/registrant_change_mailer/confirm_shared.rb new file mode 100644 index 000000000..8949b5070 --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/confirm_shared.rb @@ -0,0 +1,51 @@ +require 'rails_helper' + +RSpec.shared_examples 'registrant change mailer confirm' do + let(:domain) { instance_spy(DomainPresenter) } + let(:lang_count) { 2 } + + before :example do + assign(:domain, domain) + assign(:registrar, nil) + assign(:new_registrant, nil) + assign(:confirm_url, 'test confirm url') + end + + it 'has registrar info in estonian' do + render + expect(rendered).to have_text('test registrar estonian') + end + + it 'has registrar info in english' do + render + expect(rendered).to have_text('test registrar english') + end + + it 'has new registrant info in estonian' do + render + expect(rendered).to have_text('test new registrant estonian') + end + + it 'has new registrant info in english' do + render + expect(rendered).to have_text('test new registrant english') + end + + it 'has confirm url' do + mention_count = 1 * lang_count + render + expect(rendered).to have_text('test confirm url', count: mention_count) + end + + domain_attributes = %i( + name + ) + + domain_attributes.each do |attr_name| + it "has domain #{attr_name}" do + expect(domain).to receive(attr_name).exactly(lang_count).times.and_return(attr_name.to_s) + render + expect(rendered).to have_text(attr_name.to_s, count: lang_count) + end + end +end diff --git a/spec/views/mailers/registrant_change_mailer/expired.html.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/expired.html.erb_spec.rb new file mode 100644 index 000000000..581fae654 --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/expired.html.erb_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' +require_relative 'expired_shared' + +RSpec.describe 'mailers/registrant_change_mailer/expired.html.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english' + end + + include_examples 'registrant change mailer expired' +end diff --git a/spec/views/mailers/registrant_change_mailer/expired.text.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/expired.text.erb_spec.rb new file mode 100644 index 000000000..6f02fd795 --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/expired.text.erb_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' +require_relative 'expired_shared' + +RSpec.describe 'mailers/registrant_change_mailer/expired.text.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english' + end + + include_examples 'registrant change mailer expired' +end diff --git a/spec/views/mailers/registrant_change_mailer/expired_shared.rb b/spec/views/mailers/registrant_change_mailer/expired_shared.rb new file mode 100644 index 000000000..bcb82f008 --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/expired_shared.rb @@ -0,0 +1,50 @@ +require 'rails_helper' + +RSpec.shared_examples 'registrant change mailer expired' do + let(:domain) { instance_spy(DomainPresenter) } + let(:registrar) { instance_spy(RegistrarPresenter) } + let(:registrant) { instance_spy(RegistrantPresenter) } + let(:lang_count) { 2 } + + before :example do + assign(:domain, domain) + assign(:registrar, registrar) + assign(:registrant, registrant) + end + + it 'has registrar info in estonian' do + render + expect(rendered).to have_text('test registrar estonian') + end + + it 'has registrar info in english' do + render + expect(rendered).to have_text('test registrar english') + end + + domain_attributes = %i( + name + ) + + domain_attributes.each do |attr_name| + it "has domain #{attr_name}" do + mention_count = 3 + expect(domain).to receive(attr_name).exactly(mention_count).times.and_return("test domain #{attr_name}") + render + expect(rendered).to have_text("test domain #{attr_name}", count: mention_count) + end + end + + registrant_attributes = %i( + name + ) + + registrant_attributes.each do |attr_name| + it "has registrant #{attr_name}" do + mention_count = 1 + expect(registrant).to receive(attr_name).exactly(mention_count).times.and_return("test registrant #{attr_name}") + render + expect(rendered).to have_text("test registrant #{attr_name}", count: mention_count) + end + end +end diff --git a/spec/views/mailers/registrant_change_mailer/notice.html.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/notice.html.erb_spec.rb new file mode 100644 index 000000000..c5d4f2974 --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/notice.html.erb_spec.rb @@ -0,0 +1,13 @@ +require 'rails_helper' +require_relative 'notice_shared' + +RSpec.describe 'mailers/registrant_change_mailer/notice.html.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english' + stub_template 'mailers/shared/registrant/_registrant.et.html' => 'test new registrant estonian' + stub_template 'mailers/shared/registrant/_registrant.en.html' => 'test new registrant english' + end + + include_examples 'registrant change mailer notice' +end diff --git a/spec/views/mailers/registrant_change_mailer/notice.text.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/notice.text.erb_spec.rb new file mode 100644 index 000000000..ab685b12f --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/notice.text.erb_spec.rb @@ -0,0 +1,13 @@ +require 'rails_helper' +require_relative 'notice_shared' + +RSpec.describe 'mailers/registrant_change_mailer/notice.text.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english' + stub_template 'mailers/shared/registrant/_registrant.et.text' => 'test new registrant estonian' + stub_template 'mailers/shared/registrant/_registrant.en.text' => 'test new registrant english' + end + + include_examples 'registrant change mailer notice' +end diff --git a/spec/views/mailers/registrant_change_mailer/notice_shared.rb b/spec/views/mailers/registrant_change_mailer/notice_shared.rb new file mode 100644 index 000000000..40d42cd1c --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/notice_shared.rb @@ -0,0 +1,47 @@ +require 'rails_helper' + +RSpec.shared_examples 'registrant change mailer notice' do + let(:domain) { instance_spy(DomainPresenter) } + let(:registrar) { instance_spy(RegistrarPresenter) } + let(:registrant) { instance_spy(RegistrantPresenter) } + let(:lang_count) { 2 } + + before :example do + assign(:domain, domain) + assign(:registrar, registrar) + assign(:current_registrant, registrant) + assign(:new_registrant, registrant) + end + + it 'has registrar info in estonian' do + render + expect(rendered).to have_text('test registrar estonian') + end + + it 'has registrar info in english' do + render + expect(rendered).to have_text('test registrar english') + end + + it 'has new registrant info in estonian' do + render + expect(rendered).to have_text('test new registrant estonian') + end + + it 'has new registrant info in english' do + render + expect(rendered).to have_text('test new registrant english') + end + + domain_attributes = %i( + name + ) + + domain_attributes.each do |attr_name| + it "has domain #{attr_name}" do + expect(domain).to receive(attr_name).exactly(lang_count).times.and_return("test domain #{attr_name}") + render + expect(rendered).to have_text("test domain #{attr_name}", count: lang_count) + end + end +end diff --git a/spec/views/mailers/registrant_change_mailer/rejected.html.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/rejected.html.erb_spec.rb new file mode 100644 index 000000000..be37545c6 --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/rejected.html.erb_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' +require_relative 'rejected_shared' + +RSpec.describe 'mailers/registrant_change_mailer/rejected.html.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english' + end + + include_examples 'registrant change mailer rejected' +end diff --git a/spec/views/mailers/registrant_change_mailer/rejected.text.erb_spec.rb b/spec/views/mailers/registrant_change_mailer/rejected.text.erb_spec.rb new file mode 100644 index 000000000..af9d78a69 --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/rejected.text.erb_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' +require_relative 'rejected_shared' + +RSpec.describe 'mailers/registrant_change_mailer/rejected.text.erb' do + before :example do + stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian' + stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english' + end + + include_examples 'registrant change mailer rejected' +end diff --git a/spec/views/mailers/registrant_change_mailer/rejected_shared.rb b/spec/views/mailers/registrant_change_mailer/rejected_shared.rb new file mode 100644 index 000000000..f6e21d57a --- /dev/null +++ b/spec/views/mailers/registrant_change_mailer/rejected_shared.rb @@ -0,0 +1,48 @@ +require 'rails_helper' + +RSpec.shared_examples 'registrant change mailer rejected' do + let(:domain) { instance_spy(DomainPresenter) } + let(:registrar) { instance_spy(RegistrarPresenter) } + let(:registrant) { instance_spy(RegistrantPresenter) } + let(:lang_count) { 2 } + + before :example do + assign(:domain, domain) + assign(:registrar, registrar) + assign(:registrant, registrant) + end + + it 'has registrar info in estonian' do + render + expect(rendered).to have_text('test registrar estonian') + end + + it 'has registrar info in english' do + render + expect(rendered).to have_text('test registrar english') + end + + domain_attributes = %i( + name + ) + + domain_attributes.each do |attr_name| + it "has domain #{attr_name}" do + expect(domain).to receive(attr_name).exactly(lang_count).times.and_return("test domain #{attr_name}") + render + expect(rendered).to have_text("test domain #{attr_name}", count: lang_count) + end + end + + registrant_attributes = %i( + name + ) + + registrant_attributes.each do |attr_name| + it "has registrant #{attr_name}" do + expect(registrant).to receive(attr_name).exactly(lang_count).times.and_return("test registrant #{attr_name}") + render + expect(rendered).to have_text("test registrant #{attr_name}", count: lang_count) + end + end +end diff --git a/spec/views/mailers/shared/registrant/_registrant.en.html.erb_spec.rb b/spec/views/mailers/shared/registrant/_registrant.en.html.erb_spec.rb new file mode 100644 index 000000000..a5e0d353b --- /dev/null +++ b/spec/views/mailers/shared/registrant/_registrant.en.html.erb_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' +require_relative 'registrant_shared' + +RSpec.describe 'mailers/shared/registrant/_registrant.en.html.erb' do + include_examples 'domain mailer registrant info' +end diff --git a/spec/views/mailers/shared/registrant/_registrant.en.text.erb_spec.rb b/spec/views/mailers/shared/registrant/_registrant.en.text.erb_spec.rb new file mode 100644 index 000000000..fcfb85657 --- /dev/null +++ b/spec/views/mailers/shared/registrant/_registrant.en.text.erb_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' +require_relative 'registrant_shared' + +RSpec.describe 'mailers/shared/registrant/_registrant.en.text.erb' do + include_examples 'domain mailer registrant info' +end diff --git a/spec/views/mailers/shared/registrant/_registrant.et.html.erb_spec.rb b/spec/views/mailers/shared/registrant/_registrant.et.html.erb_spec.rb new file mode 100644 index 000000000..ec4d134a8 --- /dev/null +++ b/spec/views/mailers/shared/registrant/_registrant.et.html.erb_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' +require_relative 'registrant_shared' + +RSpec.describe 'mailers/shared/registrant/_registrant.et.html.erb' do + include_examples 'domain mailer registrant info' +end diff --git a/spec/views/mailers/shared/registrant/_registrant.et.text.erb_spec.rb b/spec/views/mailers/shared/registrant/_registrant.et.text.erb_spec.rb new file mode 100644 index 000000000..41b4c52eb --- /dev/null +++ b/spec/views/mailers/shared/registrant/_registrant.et.text.erb_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' +require_relative 'registrant_shared' + +RSpec.describe 'mailers/shared/registrant/_registrant.et.text.erb' do + include_examples 'domain mailer registrant info' +end diff --git a/spec/views/mailers/shared/registrant/registrant_shared.rb b/spec/views/mailers/shared/registrant/registrant_shared.rb new file mode 100644 index 000000000..07fcc3b1e --- /dev/null +++ b/spec/views/mailers/shared/registrant/registrant_shared.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +RSpec.shared_examples 'domain mailer registrant info' do + let(:registrant) { instance_spy(RegistrantPresenter) } + + before :example do + allow(view).to receive(:registrant).and_return(registrant) + end + + attributes = %i( + name + ident + street + city + country + ) + + attributes.each do |attr_name| + it "has #{attr_name}" do + expect(registrant).to receive(attr_name).and_return("test #{attr_name}") + render + expect(rendered).to have_text("test #{attr_name}") + end + end +end diff --git a/spec/views/mailers/shared/registrar/_registrar.en.html.erb_spec.rb b/spec/views/mailers/shared/registrar/_registrar.en.html.erb_spec.rb new file mode 100644 index 000000000..eddb968dc --- /dev/null +++ b/spec/views/mailers/shared/registrar/_registrar.en.html.erb_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' +require_relative 'registrar_shared' + +RSpec.describe 'mailers/shared/registrar/_registrar.en.html.erb' do + include_examples 'domain mailer registrar info' +end diff --git a/spec/views/mailers/shared/registrar/_registrar.en.text.erb_spec.rb b/spec/views/mailers/shared/registrar/_registrar.en.text.erb_spec.rb new file mode 100644 index 000000000..cea5d1d65 --- /dev/null +++ b/spec/views/mailers/shared/registrar/_registrar.en.text.erb_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' +require_relative 'registrar_shared' + +RSpec.describe 'mailers/shared/registrar/_registrar.en.text.erb' do + include_examples 'domain mailer registrar info' +end diff --git a/spec/views/mailers/shared/registrar/_registrar.et.html.erb_spec.rb b/spec/views/mailers/shared/registrar/_registrar.et.html.erb_spec.rb new file mode 100644 index 000000000..d68203306 --- /dev/null +++ b/spec/views/mailers/shared/registrar/_registrar.et.html.erb_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' +require_relative 'registrar_shared' + +RSpec.describe 'mailers/shared/registrar/_registrar.et.html.erb' do + include_examples 'domain mailer registrar info' +end diff --git a/spec/views/mailers/shared/registrar/_registrar.et.text.erb_spec.rb b/spec/views/mailers/shared/registrar/_registrar.et.text.erb_spec.rb new file mode 100644 index 000000000..230750db3 --- /dev/null +++ b/spec/views/mailers/shared/registrar/_registrar.et.text.erb_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' +require_relative 'registrar_shared' + +RSpec.describe 'mailers/shared/registrar/_registrar.et.text.erb' do + include_examples 'domain mailer registrar info' +end diff --git a/spec/views/mailers/shared/registrar/_registrar.ru.html.erb_spec.rb b/spec/views/mailers/shared/registrar/_registrar.ru.html.erb_spec.rb new file mode 100644 index 000000000..4cb251ca2 --- /dev/null +++ b/spec/views/mailers/shared/registrar/_registrar.ru.html.erb_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' +require_relative 'registrar_shared' + +RSpec.describe 'mailers/shared/registrar/_registrar.ru.html.erb' do + include_examples 'domain mailer registrar info' +end diff --git a/spec/views/mailers/shared/registrar/_registrar.ru.text.erb_spec.rb b/spec/views/mailers/shared/registrar/_registrar.ru.text.erb_spec.rb new file mode 100644 index 000000000..e51aba95b --- /dev/null +++ b/spec/views/mailers/shared/registrar/_registrar.ru.text.erb_spec.rb @@ -0,0 +1,6 @@ +require 'rails_helper' +require_relative 'registrar_shared' + +RSpec.describe 'mailers/shared/registrar/_registrar.ru.text.erb' do + include_examples 'domain mailer registrar info' +end diff --git a/spec/views/mailers/shared/registrar/registrar_shared.rb b/spec/views/mailers/shared/registrar/registrar_shared.rb new file mode 100644 index 000000000..f9c98c94a --- /dev/null +++ b/spec/views/mailers/shared/registrar/registrar_shared.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.shared_examples 'domain mailer registrar info' do + let(:registrar) { instance_spy(RegistrarPresenter) } + + before :example do + allow(view).to receive(:registrar).and_return(registrar) + end + + attributes = %i( + name + email + phone + url + ) + + attributes.each do |attr_name| + it "has #{attr_name}" do + expect(registrar).to receive(attr_name).and_return("test #{attr_name}") + render + expect(rendered).to have_text("test #{attr_name}") + end + end +end