Merge branch 'master' into registry-887-revoke-certificate-before-removing-it

This commit is contained in:
Maciej Szlosarczyk 2018-09-20 16:08:18 +03:00
commit 24b87d8592
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
70 changed files with 611 additions and 449 deletions

View file

@ -19,6 +19,7 @@ plugins:
enabled: true
rubocop:
enabled: true
channel: rubocop-0-58
exclude_patterns:
- "bin/"
- "config/"

View file

@ -217,7 +217,8 @@ GEM
httpi (2.4.2)
rack
socksify
i18n (0.8.6)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
i18n_data (0.7.0)
ice_nine (0.11.2)
isikukood (0.1.2)
@ -252,15 +253,14 @@ GEM
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
monetize (1.6.0)
money (~> 6.8)
money (6.8.3)
i18n (>= 0.6.4, < 0.9)
sixarm_ruby_unaccent (>= 1.1.1, < 2)
money-rails (1.8.0)
monetize (1.9.0)
money (~> 6.12)
money (6.12.0)
i18n (>= 0.6.4, < 1.1)
money-rails (1.12.0)
activesupport (>= 3.0)
monetize (~> 1.6.0)
money (~> 6.8.1)
monetize (~> 1.9.0)
money (~> 6.12.0)
railties (>= 3.0)
multi_json (1.13.1)
mustermann (1.0.2)
@ -360,7 +360,7 @@ GEM
rspec-support (3.6.0)
ruby_parser (3.8.4)
sexp_processor (~> 4.1)
rubyzip (1.2.1)
rubyzip (1.2.2)
safe_yaml (1.0.4)
sass (3.4.23)
sass-rails (5.0.6)
@ -397,7 +397,7 @@ GEM
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
sixarm_ruby_unaccent (1.1.1)
sixarm_ruby_unaccent (1.2.0)
slop (3.6.0)
socksify (1.7.1)
sprockets (3.7.2)
@ -508,4 +508,4 @@ DEPENDENCIES
whenever (= 0.9.4)
BUNDLED WITH
1.16.2
1.16.4

View file

@ -1,6 +1,7 @@
html
position: relative
min-height: 100%
overflow-y: scroll
body
padding-bottom: 130px
@ -30,9 +31,6 @@ h1, h2, h3, h4
color: white !important
background-size: 100%
.semifooter
padding: 42px 0 80px 0
.confirmation
padding: 40px 0 20px 0
.column-keys

View file

@ -6,7 +6,8 @@ module Admin
domain.transaction do
domain.schedule_force_delete
domain.registrar.messages.create!(body: t('force_delete_set_on_domain', domain_name: domain.name))
domain.registrar.notifications.create!(text: t('force_delete_set_on_domain',
domain_name: domain.name))
if notify_by_email?
DomainDeleteMailer.forced(domain: domain,

View file

@ -9,12 +9,12 @@ class Epp::PollsController < EppController
private
def req_poll
@message = current_user.queued_messages.order('created_at DESC').take
@notification = current_user.unread_notifications.order('created_at DESC').take
render_epp_response 'epp/poll/poll_no_messages' and return unless @message
if @message.attached_obj_type && @message.attached_obj_id
render_epp_response 'epp/poll/poll_no_messages' and return unless @notification
if @notification.attached_obj_type && @notification.attached_obj_id
begin
@object = Object.const_get(@message.attached_obj_type).find(@message.attached_obj_id)
@object = Object.const_get(@notification.attached_obj_type).find(@notification.attached_obj_id)
rescue => problem
# the data model might be inconsistent; or ...
# this could happen if the registrar does not dequeue messages, and then the domain was deleted
@ -28,7 +28,7 @@ class Epp::PollsController < EppController
end
end
if @message.attached_obj_type == 'Keyrelay'
if @notification.attached_obj_type == 'Keyrelay'
render_epp_response 'epp/poll/poll_keyrelay'
else
render_epp_response 'epp/poll/poll_req'
@ -36,9 +36,9 @@ class Epp::PollsController < EppController
end
def ack_poll
@message = current_user.queued_messages.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
@notification = current_user.unread_notifications.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
unless @message
unless @notification
epp_errors << {
code: '2303',
msg: I18n.t('message_was_not_found'),
@ -47,7 +47,7 @@ class Epp::PollsController < EppController
handle_errors and return
end
handle_errors(@message) and return unless @message.dequeue
handle_errors(@notification) and return unless @notification.mark_as_read
render_epp_response 'epp/poll/poll_ack'
end
@ -56,6 +56,6 @@ class Epp::PollsController < EppController
end
def resource
@message
@notification
end
end

View file

@ -1,5 +1,6 @@
class Registrant::ContactsController < RegistrantController
helper_method :domain_ids
helper_method :domain
def show
@contact = Contact.where(id: contacts).find_by(id: params[:id])
@ -25,4 +26,19 @@ class Registrant::ContactsController < RegistrantController
BusinessRegistryCache.fetch_by_ident_and_cc(ident, ident_cc).associated_domain_ids
end
end
end
def domain
current_user_domains.find(params[:domain_id])
end
def current_user_domains
ident_cc, ident = current_registrant_user.registrant_ident.split '-'
begin
BusinessRegistryCache.fetch_associated_domains ident, ident_cc
rescue Soap::Arireg::NotAvailableError => error
flash[:notice] = I18n.t(error.json[:message])
Rails.logger.fatal("[EXCEPTION] #{error.to_s}")
current_registrant_user.domains
end
end
end

View file

@ -3,7 +3,8 @@ class Registrar
protect_from_forgery except: [:back, :callback]
skip_authorization_check # actually anyone can pay, no problems at all
skip_before_action :authenticate_user!, :check_ip_restriction, only: [:back, :callback]
skip_before_action :authenticate_registrar_user!, :check_ip_restriction,
only: [:back, :callback]
before_action :check_supported_payment_method
def pay

View file

@ -7,13 +7,13 @@ class DomainDeleteConfirmJob < Que::Job
case action
when RegistrantVerification::CONFIRMED
domain.poll_message!(:poll_pending_delete_confirmed_by_registrant)
domain.notify_registrar(:poll_pending_delete_confirmed_by_registrant)
domain.apply_pending_delete!
raise_errors!(domain)
when RegistrantVerification::REJECTED
domain.statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)
domain.poll_message!(:poll_pending_delete_rejected_by_registrant)
domain.notify_registrar(:poll_pending_delete_rejected_by_registrant)
domain.cancel_pending_delete
domain.save(validate: false)

View file

@ -8,8 +8,8 @@ class DomainDeleteJob < Que::Job
domain.destroy
bye_bye = domain.versions.last
domain.registrar.messages.create!(
body: "#{I18n.t(:domain_deleted)}: #{domain.name}",
domain.registrar.notifications.create!(
text: "#{I18n.t(:domain_deleted)}: #{domain.name}",
attached_obj_id: bye_bye.id,
attached_obj_type: bye_bye.class.to_s
)

View file

@ -8,7 +8,7 @@ class DomainUpdateConfirmJob < Que::Job
case action
when RegistrantVerification::CONFIRMED
old_registrant = domain.registrant
domain.poll_message!(:poll_pending_update_confirmed_by_registrant)
domain.notify_registrar(:poll_pending_update_confirmed_by_registrant)
raise_errors!(domain)
domain.apply_pending_update!
@ -22,7 +22,7 @@ class DomainUpdateConfirmJob < Que::Job
registrar: domain.registrar,
registrant: domain.registrant).deliver_now
domain.poll_message!(:poll_pending_update_rejected_by_registrant)
domain.notify_registrar(:poll_pending_update_rejected_by_registrant)
domain.preclean_pendings
domain.clean_pendings!

View file

@ -5,7 +5,7 @@ class InvoiceMailer < ApplicationMailer
@invoice = Invoice.find_by(id: invoice_id)
billing_email ||= @invoice.billing_email
return unless @invoice
return if whitelist_blocked?(@invoice.billing_email)
return if whitelist_blocked?(billing_email)
kit = PDFKit.new(html)
pdf = kit.to_pdf

View file

@ -1,5 +1,3 @@
require 'csv'
class AccountActivity < ActiveRecord::Base
include Versions
belongs_to :account, required: true

View file

@ -81,8 +81,8 @@ class ApiUser < User
username
end
def queued_messages
registrar.messages.queued
def unread_notifications
registrar.notifications.unread
end
def registrar_pki_ok?(crt, cn)

View file

@ -265,9 +265,9 @@ class Domain < ActiveRecord::Base
true
end
def poll_message!(message_key)
registrar.messages.create!(
body: "#{I18n.t(message_key)}: #{name}",
def notify_registrar(message_key)
registrar.notifications.create!(
text: "#{I18n.t(message_key)}: #{name}",
attached_obj_id: id,
attached_obj_type: self.class.to_s
)

View file

@ -73,8 +73,8 @@ class DomainTransfer < ActiveRecord::Base
old_contacts_codes = domain.contacts.pluck(:code).sort.uniq.join(', ')
old_registrant_code = domain.registrant.code
old_registrar.messages.create!(
body: I18n.t('messages.texts.domain_transfer',
old_registrar.notifications.create!(
text: I18n.t('notifications.texts.domain_transfer',
domain_name: domain.name,
old_contacts_codes: old_contacts_codes,
old_registrant_code: old_registrant_code),

View file

@ -625,8 +625,8 @@ class Epp::Domain < Domain
)
if dt.pending?
registrar.messages.create!(
body: I18n.t('transfer_requested'),
registrar.notifications.create!(
text: I18n.t('transfer_requested'),
attached_obj_id: dt.id,
attached_obj_type: dt.class.to_s
)
@ -727,8 +727,8 @@ class Epp::Domain < Domain
return false unless valid?
registrar.messages.create!(
body: 'Key Relay action completed successfully.',
registrar.notifications.create!(
text: 'Key Relay action completed successfully.',
attached_obj_type: kr.class.to_s,
attached_obj_id: kr.id
)

View file

@ -1,19 +0,0 @@
class Message < ActiveRecord::Base
include Versions # version/message_version.rb
belongs_to :registrar, required: true
before_create -> { self.queued = true }
scope :queued, -> { where(queued: true) }
validates :body, presence: true
def dequeue
self.queued = false
save
end
def name
"-"
end
end

View file

@ -0,0 +1,31 @@
class Notification < ActiveRecord::Base
include Versions # version/notification_version.rb
belongs_to :registrar
scope :unread, -> { where(read: false) }
validates :text, presence: true
after_initialize :set_defaults
def mark_as_read
raise 'Read notification cannot be marked as read again' if read?
self.read = true
save
end
def unread?
!read?
end
# Needed for EPP log
def name
"-"
end
private
def set_defaults
self.read = false if read.nil?
end
end

View file

@ -4,7 +4,7 @@ class Registrar < ActiveRecord::Base
has_many :domains, dependent: :restrict_with_error
has_many :contacts, dependent: :restrict_with_error
has_many :api_users, dependent: :restrict_with_error
has_many :messages
has_many :notifications
has_many :invoices, foreign_key: 'buyer_id'
has_many :accounts, dependent: :destroy
has_many :nameservers, through: :domains

View file

@ -1,5 +0,0 @@
class MessageVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_messages
self.sequence_name = :log_messages_id_seq
end

View file

@ -0,0 +1,5 @@
class NotificationVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_notifications
self.sequence_name = :log_notifications_id_seq
end

View file

@ -16,9 +16,6 @@
<dt><%= t(:contact_email) %></dt>
<dd><%= @registrar.email %></dd>
<dt><%= Registrar.human_attribute_name :billing_email %></dt>
<dd><%= @registrar.billing_email %></dd>
</dl>
</div>
</div>

View file

@ -1,4 +0,0 @@
builder.tag!('domain:delData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
builder.tag!('domain:name', bye_bye.object['name'])
builder.tag!('domain:exDate', bye_bye.created_at)
end

View file

@ -4,7 +4,7 @@ xml.epp_head do
xml.msg 'Command completed successfully'
end
xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id)
xml.tag!('msgQ', 'count' => current_user.unread_notifications.count, 'id' => @notification.id)
render('epp/shared/trID', builder: xml)
end

View file

@ -10,9 +10,9 @@ xml.epp(
xml.msg 'Command completed successfully; ack to dequeue'
end
xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id) do
xml.qDate @message.created_at.try(:iso8601)
xml.msg @message.body
xml.tag!('msgQ', 'count' => current_user.unread_notifications.count, 'id' => @notification.id) do
xml.qDate @notification.created_at.try(:iso8601)
xml.msg @notification.text
end
xml.resData do

View file

@ -4,12 +4,12 @@ xml.epp_head do
xml.msg 'Command completed successfully; ack to dequeue'
end
xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id) do
xml.qDate @message.created_at.utc.xmlschema
xml.msg @message.body
xml.tag!('msgQ', 'count' => current_user.unread_notifications.count, 'id' => @notification.id) do
xml.qDate @notification.created_at.utc.xmlschema
xml.msg @notification.text
end
if @message.attached_obj_type == 'DomainTransfer'
if @notification.attached_obj_type == 'DomainTransfer'
xml.resData do
xml << render('epp/domains/partials/transfer', builder: xml, dt: @object)
end if @object

View file

@ -1,3 +1,9 @@
<ol class="breadcrumb">
<li><%= link_to t('registrant.domains.index.header'), registrant_domains_path %></li>
<li><%= link_to domain, registrant_domain_path(domain) %></li>
<li><%= t 'registrant.contacts.contact_index' %></li>
</ol>
<div class="page-header">
<h1><%= @contact.name %></h1>
</div>

View file

@ -1,6 +1,9 @@
<tr>
<tr class="domain">
<td><%= link_to domain, registrant_domain_path(domain) %></td>
<td><%= link_to domain.registrant.name, registrant_contact_path(domain.registrant) %></td>
<td>
<%= link_to domain.registrant.name,
registrant_domain_contact_path(domain, domain.registrant) %>
</td>
<td><%= l domain.expire_time %></td>
<td><%= link_to domain.registrar, registrant_registrar_path(domain.registrar) %></td>
</tr>

View file

@ -76,7 +76,7 @@
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed">
<table class="table table-hover table-bordered table-condensed domains">
<thead>
<tr>
<th class="col-xs-2">

View file

@ -1,22 +0,0 @@
- panel_class = @domain.errors.messages[:admin_contacts] ? 'panel-danger' : 'panel-default'
.panel{class: panel_class}
.panel-heading.clearfix
= t('.title')
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-4'}= t(:name)
%th{class: 'col-xs-4'}= t(:id)
%th{class: 'col-xs-4'}= t(:email)
%tbody
- @domain.admin_contacts.each do |ac|
%tr
%td= link_to(ac, registrant_contact_path(ac))
%td= ac.code
%td= ac.email
- if @domain.errors.messages[:admin_contacts]
%tfoot
- @domain.errors.messages[:admin_contacts].each do |x|
%tr
%td{colspan: 4}= x

View file

@ -0,0 +1,7 @@
<% contact = domain_contact.contact %>
<tr class="<%= domain_contact.model_name.singular.dasherize %>">
<td><%= link_to contact, registrant_domain_contact_path(domain, contact) %></td>
<td><%= contact.code %></td>
<td><%= contact.email %></td>
</tr>

View file

@ -0,0 +1,24 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t ".header_#{domain_contacts.model_name.plural.underscore}" %>
</div>
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed
<%= domain_contacts.model_name.plural.dasherize %>">
<thead>
<tr>
<th class="col-xs-4"><%= Contact.human_attribute_name :name %></th>
<th class="col-xs-4"><%= Contact.human_attribute_name :code %></th>
<th class="col-xs-4"><%= Contact.human_attribute_name :email %></th>
</tr>
</thead>
<tbody>
<%= render partial: 'registrant/domains/partials/domain_contact',
collection: domain_contacts,
locals: { domain: domain } %>
</tbody>
</table>
</div>
</div>

View file

@ -13,7 +13,7 @@
<dt><%= t(:registered_at) %></dt>
<dd><%= l(@domain.registered_at) %></dd>
<dt><%= t(:registrar_name) %></dt>
<dt><%= Registrar.model_name.human %></dt>
<dd><%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %></dd>
<dt><%= Domain.human_attribute_name :transfer_code %></dt>

View file

@ -1,19 +0,0 @@
.panel.panel-default
.panel-heading
%h3.panel-title= t('.title')
.panel-body
%dl.dl-horizontal
%dt= t(:name)
%dd= link_to(@domain.registrant.name, registrant_contact_path(@domain.registrant))
%dt= t(:id)
%dd= @domain.registrant_code
%dt= t(:identity_code)
%dd= @domain.registrant_ident
%dt= t(:email)
%dd= @domain.registrant_email
%dt= t(:phone)
%dd= @domain.registrant_phone

View file

@ -0,0 +1,26 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt><%= Registrant.human_attribute_name :name %></dt>
<dd>
<%= link_to registrant.name, registrant_domain_contact_path(domain, registrant) %>
</dd>
<dt><%= Registrant.human_attribute_name :code %></dt>
<dd><%= registrant.code %></dd>
<dt><%= Registrant.human_attribute_name :ident %></dt>
<dd><%= registrant.ident %></dd>
<dt><%= Registrant.human_attribute_name :email %></dt>
<dd><%= registrant.email %></dd>
<dt><%= Registrant.human_attribute_name :phone %></dt>
<dd><%= registrant.phone %></dd>
</dl>
</div>
</div>

View file

@ -1,22 +0,0 @@
- panel_class = @domain.errors.messages[:tech_contacts] ? 'panel-danger' : 'panel-default'
#tech_contacts.panel{class: panel_class}
.panel-heading.clearfix
= t('.title')
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-4'}= t(:name)
%th{class: 'col-xs-4'}= t(:id)
%th{class: 'col-xs-4'}= t(:email)
%tbody
- @domain.tech_contacts.each do |tc|
%tr
%td= link_to(tc, registrant_contact_path(tc))
%td= tc.code
%td= tc.email
- if @domain.errors.messages[:tech_contacts]
%tfoot
- @domain.errors.messages[:tech_contacts].each do |x|
%tr
%td{colspan: 4}= x

View file

@ -1,23 +1,35 @@
<%= render 'shared/title', name: @domain.name %>
<ol class="breadcrumb">
<li><%= link_to t('registrant.domains.index.header'), registrant_domains_path %></li>
</ol>
<div class="page-header">
<h1><%= @domain %></h1>
</div>
<div class="row">
<div class="col-md-6">
<%= render 'registrant/domains/partials/general' %>
</div>
<div class="col-md-6">
<%= render 'registrant/domains/partials/owner' %>
<%= render partial: 'registrant/domains/partials/registrant',
locals: { registrant: @domain.registrant, domain: @domain } %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/tech_contacts' %>
<%= render 'registrant/domains/partials/domain_contacts',
domain: @domain,
domain_contacts: @domain.tech_domain_contacts %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/admin_contacts' %>
<%= render 'registrant/domains/partials/domain_contacts',
domain: @domain,
domain_contacts: @domain.admin_domain_contacts %>
</div>
</div>

View file

@ -173,7 +173,7 @@ Devise.setup do |config|
# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again. Default is 30 minutes.
# config.timeout_in = 30.minutes
config.timeout_in = ENV['user_session_timeout'].to_i.seconds if ENV['user_session_timeout']
# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.

View file

@ -1,69 +1,4 @@
# encoding : utf-8
MoneyRails.configure do |config|
# To set the default currency
#
# Wrapper for Money#default_currency with additional functionality
config.default_currency = :eur
# Set default bank object
#
# Example:
# config.default_bank = EuCentralBank.new
# Add exchange rates to current money bank object.
# (The conversion rate refers to one direction only)
#
# Example:
# config.add_rate "USD", "CAD", 1.24515
# config.add_rate "CAD", "USD", 0.803115
# To handle the inclusion of validations for monetized fields
# The default value is true
#
# config.include_validations = true
# Default ActiveRecord migration configuration values for columns:
#
# config.amount_column = { prefix: '', # column name prefix
# postfix: '_cents', # column name postfix
# column_name: nil, # full column name (overrides prefix, postfix and accessor name)
# type: :integer, # column type
# present: true, # column will be created
# null: false, # other options will be treated as column options
# default: 0
# }
#
# config.currency_column = { prefix: '',
# postfix: '_currency',
# column_name: nil,
# type: :string,
# present: true,
# null: false,
# default: 'USD'
# }
# Register a custom currency
#
# Example:
# config.register_currency = {
# :priority => 1,
# :iso_code => "EU4",
# :name => "Euro with subunit of 4 digits",
# :symbol => "€",
# :symbol_first => true,
# :subunit => "Subcent",
# :subunit_to_unit => 10000,
# :thousands_separator => ".",
# :decimal_mark => ","
# }
# Set default money format globally.
# Default value is nil meaning "ignore this option".
# Example:
#
# config.default_format = {
# :no_cents_if_whole => nil,
# :symbol => nil,
# :sign_before_symbol => nil
# }
end
end

View file

@ -474,7 +474,6 @@ en:
message: 'Message'
message_no: 'Message #%{id}'
queue_date: 'Queue date'
messages_in_queue: 'Messages in queue'
you_have_no_new_messages: 'You have no new messages'
message_id: 'Message ID'
trStatus: 'Status'

View file

@ -1,5 +1,5 @@
en:
messages:
notifications:
texts:
domain_transfer: >-
Transfer of domain %{domain_name} has been approved.

View file

@ -1,6 +1,8 @@
en:
registrant:
contacts:
contact_index: Contacts
show:
general:
header: General

View file

@ -8,12 +8,11 @@ en:
download_list:
registrant: Registrant
partials:
owner:
title: Registrant
registrant:
header: Registrant
admin_contacts:
title: Admin. contacts
tech_contacts:
title: Tech. contacts
domain_contacts:
header_admin_domain_contacts: Administrative contacts
header_tech_domain_contacts: Technical contacts

View file

@ -136,8 +136,9 @@ Rails.application.routes.draw do
end
resources :registrars, only: :show
resources :contacts, only: :show
resources :domains, only: %i[index show] do
resources :contacts, only: %i[show]
collection do
get :download_list
end

View file

@ -0,0 +1,5 @@
class RenameMessagesToNotifications < ActiveRecord::Migration
def change
rename_table :messages, :notifications
end
end

View file

@ -0,0 +1,5 @@
class RenameLogMessagesToLogNotifications < ActiveRecord::Migration
def change
rename_table :log_messages, :log_notifications
end
end

View file

@ -0,0 +1,5 @@
class RenameNotificationsBodyToText < ActiveRecord::Migration
def change
rename_column :notifications, :body, :text
end
end

View file

@ -0,0 +1,5 @@
class RenameNotificationsQueuedToRead < ActiveRecord::Migration
def change
rename_column :notifications, :queued, :read
end
end

View file

@ -0,0 +1,5 @@
class ChangeNotificationsReadToNotNull < ActiveRecord::Migration
def change
change_column_null :notifications, :read, false
end
end

View file

@ -1652,44 +1652,6 @@ CREATE SEQUENCE public.log_keyrelays_id_seq
ALTER SEQUENCE public.log_keyrelays_id_seq OWNED BY public.log_keyrelays.id;
--
-- Name: log_messages; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE public.log_messages (
id integer NOT NULL,
item_type character varying NOT NULL,
item_id integer NOT NULL,
event character varying NOT NULL,
whodunnit character varying,
object json,
object_changes json,
created_at timestamp without time zone,
session character varying,
children json,
uuid character varying
);
--
-- Name: log_messages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.log_messages_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: log_messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.log_messages_id_seq OWNED BY public.log_messages.id;
--
-- Name: log_nameservers; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@ -1728,6 +1690,44 @@ CREATE SEQUENCE public.log_nameservers_id_seq
ALTER SEQUENCE public.log_nameservers_id_seq OWNED BY public.log_nameservers.id;
--
-- Name: log_notifications; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE public.log_notifications (
id integer NOT NULL,
item_type character varying NOT NULL,
item_id integer NOT NULL,
event character varying NOT NULL,
whodunnit character varying,
object json,
object_changes json,
created_at timestamp without time zone,
session character varying,
children json,
uuid character varying
);
--
-- Name: log_notifications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.log_notifications_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: log_notifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.log_notifications_id_seq OWNED BY public.log_notifications.id;
--
-- Name: log_registrars; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@ -1955,43 +1955,6 @@ CREATE SEQUENCE public.mail_templates_id_seq
ALTER SEQUENCE public.mail_templates_id_seq OWNED BY public.mail_templates.id;
--
-- Name: messages; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE public.messages (
id integer NOT NULL,
registrar_id integer NOT NULL,
body character varying NOT NULL,
attached_obj_type character varying,
attached_obj_id integer,
queued boolean,
created_at timestamp without time zone,
updated_at timestamp without time zone,
creator_str character varying,
updator_str character varying
);
--
-- Name: messages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.messages_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.messages_id_seq OWNED BY public.messages.id;
--
-- Name: nameservers; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@ -2030,6 +1993,43 @@ CREATE SEQUENCE public.nameservers_id_seq
ALTER SEQUENCE public.nameservers_id_seq OWNED BY public.nameservers.id;
--
-- Name: notifications; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE public.notifications (
id integer NOT NULL,
registrar_id integer NOT NULL,
text character varying NOT NULL,
attached_obj_type character varying,
attached_obj_id integer,
read boolean NOT NULL,
created_at timestamp without time zone,
updated_at timestamp without time zone,
creator_str character varying,
updator_str character varying
);
--
-- Name: notifications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.notifications_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: notifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.notifications_id_seq OWNED BY public.notifications.id;
--
-- Name: prices; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@ -2715,14 +2715,14 @@ ALTER TABLE ONLY public.log_keyrelays ALTER COLUMN id SET DEFAULT nextval('publi
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.log_messages ALTER COLUMN id SET DEFAULT nextval('public.log_messages_id_seq'::regclass);
ALTER TABLE ONLY public.log_nameservers ALTER COLUMN id SET DEFAULT nextval('public.log_nameservers_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.log_nameservers ALTER COLUMN id SET DEFAULT nextval('public.log_nameservers_id_seq'::regclass);
ALTER TABLE ONLY public.log_notifications ALTER COLUMN id SET DEFAULT nextval('public.log_notifications_id_seq'::regclass);
--
@ -2771,14 +2771,14 @@ ALTER TABLE ONLY public.mail_templates ALTER COLUMN id SET DEFAULT nextval('publ
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.messages ALTER COLUMN id SET DEFAULT nextval('public.messages_id_seq'::regclass);
ALTER TABLE ONLY public.nameservers ALTER COLUMN id SET DEFAULT nextval('public.nameservers_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.nameservers ALTER COLUMN id SET DEFAULT nextval('public.nameservers_id_seq'::regclass);
ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('public.notifications_id_seq'::regclass);
--
@ -3130,14 +3130,6 @@ ALTER TABLE ONLY public.log_keyrelays
ADD CONSTRAINT log_keyrelays_pkey PRIMARY KEY (id);
--
-- Name: log_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY public.log_messages
ADD CONSTRAINT log_messages_pkey PRIMARY KEY (id);
--
-- Name: log_nameservers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@ -3146,6 +3138,14 @@ ALTER TABLE ONLY public.log_nameservers
ADD CONSTRAINT log_nameservers_pkey PRIMARY KEY (id);
--
-- Name: log_notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY public.log_notifications
ADD CONSTRAINT log_notifications_pkey PRIMARY KEY (id);
--
-- Name: log_registrars_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@ -3194,14 +3194,6 @@ ALTER TABLE ONLY public.mail_templates
ADD CONSTRAINT mail_templates_pkey PRIMARY KEY (id);
--
-- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY public.messages
ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
--
-- Name: nameservers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@ -3210,6 +3202,14 @@ ALTER TABLE ONLY public.nameservers
ADD CONSTRAINT nameservers_pkey PRIMARY KEY (id);
--
-- Name: notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY public.notifications
ADD CONSTRAINT notifications_pkey PRIMARY KEY (id);
--
-- Name: prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@ -3789,20 +3789,6 @@ CREATE INDEX index_log_keyrelays_on_item_type_and_item_id ON public.log_keyrelay
CREATE INDEX index_log_keyrelays_on_whodunnit ON public.log_keyrelays USING btree (whodunnit);
--
-- Name: index_log_messages_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_log_messages_on_item_type_and_item_id ON public.log_messages USING btree (item_type, item_id);
--
-- Name: index_log_messages_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_log_messages_on_whodunnit ON public.log_messages USING btree (whodunnit);
--
-- Name: index_log_nameservers_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@ -3817,6 +3803,20 @@ CREATE INDEX index_log_nameservers_on_item_type_and_item_id ON public.log_namese
CREATE INDEX index_log_nameservers_on_whodunnit ON public.log_nameservers USING btree (whodunnit);
--
-- Name: index_log_notifications_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_log_notifications_on_item_type_and_item_id ON public.log_notifications USING btree (item_type, item_id);
--
-- Name: index_log_notifications_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_log_notifications_on_whodunnit ON public.log_notifications USING btree (whodunnit);
--
-- Name: index_log_registrars_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@ -3873,13 +3873,6 @@ CREATE INDEX index_log_users_on_item_type_and_item_id ON public.log_users USING
CREATE INDEX index_log_users_on_whodunnit ON public.log_users USING btree (whodunnit);
--
-- Name: index_messages_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_messages_on_registrar_id ON public.messages USING btree (registrar_id);
--
-- Name: index_nameservers_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@ -3887,6 +3880,13 @@ CREATE INDEX index_messages_on_registrar_id ON public.messages USING btree (regi
CREATE INDEX index_nameservers_on_domain_id ON public.nameservers USING btree (domain_id);
--
-- Name: index_notifications_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_notifications_on_registrar_id ON public.notifications USING btree (registrar_id);
--
-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@ -4102,7 +4102,7 @@ ALTER TABLE ONLY public.account_activities
-- Name: messages_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.messages
ALTER TABLE ONLY public.notifications
ADD CONSTRAINT messages_registrar_id_fk FOREIGN KEY (registrar_id) REFERENCES public.registrars(id);
@ -4766,5 +4766,15 @@ INSERT INTO schema_migrations (version) VALUES ('20180808064402');
INSERT INTO schema_migrations (version) VALUES ('20180816123540');
INSERT INTO schema_migrations (version) VALUES ('20180823161237');
INSERT INTO schema_migrations (version) VALUES ('20180823163548');
INSERT INTO schema_migrations (version) VALUES ('20180823174331');
INSERT INTO schema_migrations (version) VALUES ('20180823212823');
INSERT INTO schema_migrations (version) VALUES ('20180824092855');
INSERT INTO schema_migrations (version) VALUES ('20180824102834');

View file

@ -251,10 +251,11 @@ RSpec.describe Domain do
@domain.statuses = DomainStatus::OK # restore
end
it 'should add poll message to registrar' do
it 'should notify registrar' do
text = 'Registrant confirmed domain update: testpollmessage123.ee'
domain = create(:domain, name: 'testpollmessage123.ee')
domain.poll_message!(:poll_pending_update_confirmed_by_registrant)
domain.registrar.messages.first.body.should == 'Registrant confirmed domain update: testpollmessage123.ee'
domain.notify_registrar(:poll_pending_update_confirmed_by_registrant)
domain.registrar.notifications.first.text.should == text
end
context 'about registrant update confirm' do

View file

@ -9,6 +9,8 @@ john:
code: john-001
auth_info: cacb5b
uuid: eb2f2766-b44c-4e14-9f16-32ab1a7cb957
created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
updated_at: <%= Time.zone.parse('2010-07-06').to_s(:db) %>
william: &william
name: William
@ -24,7 +26,7 @@ william: &william
street: Main Street
zip: 12345
city: New York
state: New York
state: New York State
country_code: US
statuses:
- ok

View file

@ -4,7 +4,11 @@ shop:
registrar: bestnames
registrant: john
transfer_code: 65078d5
valid_to: 2010-07-05
registered_at: <%= Time.zone.parse('2010-07-04').to_s(:db) %>
valid_to: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
outzone_at: <%= Time.zone.parse('2010-07-06').to_s(:db) %>
delete_at: <%= Time.zone.parse('2010-07-07').to_s(:db) %>
force_delete_at: <%= Time.zone.parse('2010-07-08').to_s(:db) %>
period: 1
period_unit: m
uuid: 1b3ee442-e8fe-4922-9492-8fcb9dccc69c

View file

@ -1,16 +1,16 @@
greeting:
body: Welcome!
queued: true
text: Welcome!
read: false
registrar: bestnames
created_at: <%= Time.zone.parse('2010-07-04') %>
domain_deleted:
body: Your domain has been deleted
queued: true
text: Your domain has been deleted
read: false
registrar: bestnames
created_at: <%= Time.zone.parse('2010-07-05') %>
farewell:
body: Good bye!
queued: true
text: Good bye!
read: false
registrar: goodnames

View file

@ -40,4 +40,5 @@ complete:
accounting_customer_code: US0001
language: en
vat_no: US12345
vat_rate: 0.05
vat_rate: 0.05
billing_email: billing@bestnames.test

View file

@ -47,7 +47,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
def test_notifies_old_registrar
@old_registrar = @domain.registrar
assert_difference -> { @old_registrar.messages.count } do
assert_difference -> { @old_registrar.notifications.count } do
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
end
end

View file

@ -48,7 +48,7 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
def test_notifies_old_registrar
@old_registrar = @domain.registrar
assert_difference -> { @old_registrar.messages.count } do
assert_difference -> { @old_registrar.notifications.count } do
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
end
end

View file

@ -1,9 +1,9 @@
require 'test_helper'
class EppPollTest < ApplicationIntegrationTest
# Deliberately does not conform to RFC5730, which requires the first message to be returned
def test_return_latest_message_when_queue_is_not_empty
message = messages(:domain_deleted)
# Deliberately does not conform to RFC5730, which requires the first notification to be returned
def test_return_latest_notification_when_queue_is_not_empty
notification = notifications(:domain_deleted)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -19,16 +19,15 @@ class EppPollTest < ApplicationIntegrationTest
assert_equal 1301.to_s, response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_equal 2.to_s, response_xml.at_css('msgQ')[:count]
assert_equal message.id.to_s, response_xml.at_css('msgQ')[:id]
assert_equal notification.id.to_s, response_xml.at_css('msgQ')[:id]
assert_equal Time.zone.parse('2010-07-05').utc.xmlschema, response_xml.at_css('msgQ qDate').text
assert_equal 'Your domain has been deleted', response_xml.at_css('msgQ msg').text
end
def test_no_messages_in_queue
registrars(:bestnames).messages.delete_all(:delete_all)
def test_no_notifications
registrars(:bestnames).notifications.delete_all(:delete_all)
request_xml =
<<-XML
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
@ -37,55 +36,55 @@ class EppPollTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
response_xml = Nokogiri::XML(response.body)
assert_equal 1300.to_s, response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
xml_doc = Nokogiri::XML(response.body)
assert_equal 1300.to_s, xml_doc.at_css('result')[:code]
assert_equal 1, xml_doc.css('result').size
end
def test_dequeue_message
message = messages(:greeting)
def test_mark_as_read
notification = notifications(:greeting)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<poll op="ack" msgID="#{message.id}"/>
<poll op="ack" msgID="#{notification.id}"/>
</command>
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
message.reload
response_xml = Nokogiri::XML(response.body)
notification.reload
assert_not message.queued?
assert_equal 1000.to_s, response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_equal 1.to_s, response_xml.at_css('msgQ')[:count]
assert_equal message.id.to_s, response_xml.at_css('msgQ')[:id]
xml_doc = Nokogiri::XML(response.body)
assert notification.read?
assert_equal 1000.to_s, xml_doc.at_css('result')[:code]
assert_equal 1, xml_doc.css('result').size
assert_equal 1.to_s, xml_doc.at_css('msgQ')[:count]
assert_equal notification.id.to_s, xml_doc.at_css('msgQ')[:id]
end
def test_message_of_other_registrars_cannot_be_dequeued
message = messages(:farewell)
def test_notification_of_other_registrars_cannot_be_marked_as_read
notification = notifications(:farewell)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<poll op="ack" msgID="#{message.id}"/>
<poll op="ack" msgID="#{notification.id}"/>
</command>
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
response_xml = Nokogiri::XML(response.body)
message.reload
notification.reload
assert message.queued?
assert_equal 2303.to_s, response_xml.at_css('result')[:code]
xml_doc = Nokogiri::XML(response.body)
assert notification.unread?
assert_equal 2303.to_s, xml_doc.at_css('result')[:code]
end
def test_message_not_found
def test_notification_not_found
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -95,8 +94,8 @@ class EppPollTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
response_xml = Nokogiri::XML(response.body)
assert_equal 2303.to_s, response_xml.at_css('result')[:code]
xml_doc = Nokogiri::XML(response.body)
assert_equal 2303.to_s, xml_doc.at_css('result')[:code]
end
end

View file

@ -18,19 +18,19 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
super
end
def test_rejected_registrant_verification_polls_a_message
def test_rejected_registrant_verification_notifies_registrar
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
last_registrar_message = @domain.registrar.messages.last
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
assert_equal(last_registrar_message.body, 'Registrant rejected domain deletion: shop.test')
last_registrar_notification = @domain.registrar.notifications.last
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
assert_equal(last_registrar_notification.text, 'Registrant rejected domain deletion: shop.test')
end
def test_accepted_registrant_verification_polls_a_message
def test_accepted_registrant_verification_notifies_registrar
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
last_registrar_message = @domain.registrar.messages.last
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
assert_equal(last_registrar_message.body, 'Registrant confirmed domain deletion: shop.test')
last_registrar_notification = @domain.registrar.notifications.last
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
assert_equal(last_registrar_notification.text, 'Registrant confirmed domain deletion: shop.test')
end
end

View file

@ -18,19 +18,19 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
super
end
def test_rejected_registrant_verification_polls_a_message
def test_rejected_registrant_verification_notifies_registrar
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
last_registrar_message = @domain.registrar.messages.last
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
assert_equal(last_registrar_message.body, 'Registrant rejected domain update: shop.test')
last_registrar_notification = @domain.registrar.notifications.last
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
assert_equal(last_registrar_notification.text, 'Registrant rejected domain update: shop.test')
end
def test_accepted_registrant_verification_polls_a_message
def test_accepted_registrant_verification_notifies_registrar
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
last_registrar_message = @domain.registrar.messages.last
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
assert_equal(last_registrar_message.body, 'Registrant confirmed domain update: shop.test')
last_registrar_notification = @domain.registrar.notifications.last
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
assert_equal(last_registrar_notification.text, 'Registrant confirmed domain update: shop.test')
end
end

View file

@ -0,0 +1,8 @@
require 'test_helper'
class MoneyLearningTest < ActiveSupport::TestCase
def test_default_currency_is_euro
money = Money.from_amount(1)
assert_equal Money::Currency.new(:eur), money.currency
end
end

View file

@ -14,19 +14,19 @@ class DomainTransferTest < ActiveSupport::TestCase
def test_notifies_old_registrar_on_approval
old_registrar = @domain_transfer.old_registrar
assert_difference -> { old_registrar.messages.count } do
assert_difference -> { old_registrar.notifications.count } do
@domain_transfer.approve
end
body = 'Transfer of domain shop.test has been approved.' \
text = 'Transfer of domain shop.test has been approved.' \
' It was associated with registrant john-001' \
' and contacts acme-ltd-001, jane-001, william-001.'
id = @domain_transfer.id
class_name = @domain_transfer.class.name
message = old_registrar.messages.last
assert_equal body, message.body
assert_equal id, message.attached_obj_id
assert_equal class_name, message.attached_obj_type
notification = old_registrar.notifications.last
assert_equal text, notification.text
assert_equal id, notification.attached_obj_id
assert_equal class_name, notification.attached_obj_type
end
end

View file

@ -1,27 +0,0 @@
require 'test_helper'
class MessageTest < ActiveSupport::TestCase
setup do
@message = messages(:greeting)
end
def test_valid
assert @message.valid?
end
def test_invalid_without_body
@message.body = nil
assert @message.invalid?
end
def test_invalid_without_registrar
@message.registrar = nil
assert @message.invalid?
end
def test_dequeue
@message.dequeue
@message.reload
assert_not @message.queued?
end
end

View file

@ -0,0 +1,42 @@
require 'test_helper'
class NotificationTest < ActiveSupport::TestCase
setup do
@notification = notifications(:greeting)
end
def test_valid
assert @notification.valid?
end
def test_invalid_without_text
@notification.text = ''
assert @notification.invalid?
end
def test_unread_by_default
notification = Notification.new(registrar: registrars(:bestnames), text: 'test')
assert notification.unread?
notification.save!
assert notification.unread?
end
def test_honor_given_read_state
notification = Notification.new(read: true)
assert notification.read?
end
def test_mark_as_read
@notification.mark_as_read
@notification.reload
assert @notification.read?
end
def test_read_notification_cannot_be_marked_as_read_again
@notification.mark_as_read
assert_raises do
@notification.mark_as_read
end
end
end

View file

@ -20,6 +20,6 @@ class AdminContactsTest < ApplicationSystemTestCase
visit admin_contact_path(@contact)
assert_text('Street Main Street City New York Postcode 12345 ' \
'State New York Country United States of America')
'State New York State Country United States of America')
end
end

View file

@ -22,7 +22,7 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
end
def test_notifies_registrar
assert_difference '@domain.registrar.messages.size' do
assert_difference '@domain.registrar.notifications.size' do
visit edit_admin_domain_url(@domain)
click_link_or_button 'Force delete domain'
end

View file

@ -14,5 +14,6 @@ class AdminAreaRegistrarDetailsTest < ApplicationSystemTestCase
assert_text 'VAT number US12345'
assert_text 'VAT rate 5.0%'
assert_text 'Language English'
assert_text 'billing@bestnames.test'
end
end

View file

@ -0,0 +1,35 @@
require 'test_helper'
class RegistrantAreaContactDetailsTest < ApplicationSystemTestCase
setup do
sign_in users(:registrant)
@contact = contacts(:john)
Setting.days_to_keep_business_registry_cache = 1
travel_to Time.zone.parse('2010-07-05')
end
def test_general_data
visit registrant_domain_contact_url(domains(:shop), @contact)
assert_text 'Code john-001'
assert_text 'Name John'
assert_text 'Auth info'
assert_css('[value="cacb5b"]')
assert_text 'Ident 1234'
assert_text 'Email john@inbox.test'
assert_text 'Phone +555.555'
assert_text "Created at #{l Time.zone.parse('2010-07-05')}"
assert_text "Updated at #{l Time.zone.parse('2010-07-06')}"
end
def test_registrant_user_cannot_access_contact_when_given_domain_belongs_to_another_user
suppress(ActionView::Template::Error) do
visit registrant_domain_contact_url(domains(:metro), @contact)
assert_response :not_found
assert_no_text 'Name John'
end
end
end

View file

@ -0,0 +1,65 @@
require 'test_helper'
class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase
setup do
sign_in users(:registrant)
@domain = domains(:shop)
Setting.days_to_keep_business_registry_cache = 1
travel_to Time.zone.parse('2010-07-05')
end
def test_general_data
visit registrant_domain_url(@domain)
assert_text 'Name shop.test'
assert_text "Registered at #{l Time.zone.parse('2010-07-04')}"
assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
assert_text 'Transfer code'
assert_css('[value="65078d5"]')
assert_text "Valid to #{l Time.zone.parse('2010-07-05')}"
assert_text "Outzone at #{l Time.zone.parse('2010-07-06')}"
assert_text "Delete at #{l Time.zone.parse('2010-07-07')}"
assert_text "Force delete at #{l Time.zone.parse('2010-07-08')}"
end
def test_registrant
visit registrant_domain_url(@domain)
assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant)
assert_text 'Code john-001'
assert_text 'Ident 1234'
assert_text 'Email john@inbox.test'
assert_text 'Phone +555.555'
end
def test_admin_contacts
visit registrant_domain_url(@domain)
within('.admin-domain-contacts') do
assert_link 'Jane', href: registrant_domain_contact_path(@domain, contacts(:jane))
assert_text 'jane-001'
assert_text 'jane@mail.test'
assert_css '.admin-domain-contact', count: 1
end
end
def test_tech_contacts
visit registrant_domain_url(@domain)
within('.tech-domain-contacts') do
assert_link 'William', href: registrant_domain_contact_path(@domain, contacts(:william))
assert_text 'william-001'
assert_text 'william@inbox.test'
assert_css '.tech-domain-contact', count: 2
end
end
def test_registrant_user_cannot_access_domains_of_other_users
suppress(ActiveRecord::RecordNotFound) do
visit registrant_domain_url(domains(:metro))
assert_response :not_found
assert_no_text 'metro.test'
end
end
end

View file

@ -0,0 +1,25 @@
require 'test_helper'
class RegistrantAreaDomainListTest < ApplicationSystemTestCase
setup do
sign_in users(:registrant)
@domain = domains(:shop)
Setting.days_to_keep_business_registry_cache = 1
travel_to Time.zone.parse('2010-07-05')
end
def test_show_domain_list
visit registrant_domains_url
assert_link 'shop.test', href: registrant_domain_path(@domain)
assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant)
assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
assert_text l(Time.zone.parse('2010-07-05'))
assert_css '.domains .domain', count: 4
end
def test_do_not_show_domains_of_other_registrant_users
visit registrant_domains_url
assert_no_text 'metro.test'
end
end