diff --git a/.gitignore b/.gitignore index 733375212..be64af3ba 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ capybara-*.html **.orig config/initializers/secret_token.rb config/deploy.rb -config/secrets.yml config/database.yml config/application.yml config/environments/development.rb diff --git a/.rubocop-guard.yml b/.rubocop-guard.yml deleted file mode 100644 index 0ee03be6b..000000000 --- a/.rubocop-guard.yml +++ /dev/null @@ -1,10 +0,0 @@ -inherit_from: .rubocop.yml - -# -# Turn off during guard runs -# - -# turn off comment intention check during development -# because NerdCommenter honors commented code intentions -Style/CommentIndentation: - Enabled: false diff --git a/.travis.yml b/.travis.yml index 275a12af1..bca20c340 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ before_script: - "psql -c 'create database registry_whois_test;' -U postgres" - "psql -c 'create database registry_api_log_test;' -U postgres" - "cp config/application-example.yml config/application.yml" - - "cp config/secrets-example.yml config/secrets.yml" - "cp config/database-travis.yml config/database.yml" - "RAILS_ENV=test bundle exec rake db:setup:all" script: diff --git a/Gemfile b/Gemfile index cfde3779e..cad46d3e8 100644 --- a/Gemfile +++ b/Gemfile @@ -114,12 +114,8 @@ gem 'jquery-ui-rails', '5.0.5' group :development do - gem 'guard', '2.12.9' # run tests automatically gem 'spring', '1.3.6' gem 'spring-commands-rspec', '1.0.4' - gem 'guard-rails', '0.7.1' # run EPP server automatically - gem 'guard-rspec', '4.5.2' - gem 'guard-rubocop', '1.2.0' gem 'rubocop', '0.48.1' # deploy @@ -129,7 +125,7 @@ end group :development, :test do gem 'capybara' - gem 'rspec-rails', '~> 3.5' + gem 'rspec-rails', '~> 3.6' gem 'fabrication', '2.13.2' # Replacement for fixtures gem 'phantomjs-binaries' gem 'phantomjs' diff --git a/Gemfile.lock b/Gemfile.lock index dd9d7d8bc..ea08f79a2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -193,7 +193,6 @@ GEM ffi (1.9.18) figaro (1.1.1) thor (~> 0.14) - formatador (0.2.5) globalid (0.3.7) activesupport (>= 4.1.0) grape (0.12.0) @@ -206,26 +205,6 @@ GEM rack-accept rack-mount virtus (>= 1.0.0) - guard (2.12.9) - formatador (>= 0.2.4) - listen (>= 2.7, <= 4.0) - lumberjack (~> 1.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-rails (0.7.1) - guard (~> 2.11) - guard-compat (~> 1.0) - guard-rspec (4.5.2) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) - guard-rubocop (1.2.0) - guard (~> 2.0) - rubocop (~> 0.20) gyoku (1.3.1) builder (>= 2.1.2) haml (4.0.7) @@ -279,13 +258,8 @@ GEM libv8 (3.16.14.19) libxml-ruby (3.0.0) liquid (3.0.6) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) loofah (2.0.3) nokogiri (>= 1.5.9) - lumberjack (1.0.11) mail (2.6.5) mime-types (>= 1.16, < 4) method_source (0.8.2) @@ -296,7 +270,7 @@ GEM open4 (~> 1.3.4) rake mini_portile2 (2.1.0) - minitest (5.10.1) + minitest (5.10.2) monetize (1.6.0) money (~> 6.8) money (6.8.3) @@ -309,14 +283,10 @@ GEM railties (>= 3.0) multi_json (1.12.1) multi_xml (0.6.0) - nenv (0.3.0) netrc (0.11.0) nokogiri (1.7.1) mini_portile2 (~> 2.1.0) nori (2.6.0) - notiffany (0.1.1) - nenv (~> 0.1) - shellany (~> 0.0) nprogress-rails (0.1.6.7) open4 (1.3.4) orm_adapter (0.5.0) @@ -345,7 +315,7 @@ GEM erubis que (~> 0.8) sinatra - rack (1.6.5) + rack (1.6.8) rack-accept (0.4.5) rack (>= 0.4) rack-mount (0.8.3) @@ -389,9 +359,6 @@ GEM activesupport (>= 3.0) i18n polyamorous (~> 1.1) - rb-fsevent (0.9.8) - rb-inotify (0.9.8) - ffi (>= 0.5.0) rdoc (4.3.0) ref (2.0.0) request_store (1.1.0) @@ -401,27 +368,27 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rspec (3.5.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) - rspec-core (3.5.4) - rspec-support (~> 3.5.0) - rspec-expectations (3.5.0) + rspec (3.6.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-mocks (3.5.0) + rspec-support (~> 3.6.0) + rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-rails (3.5.2) + rspec-support (~> 3.6.0) + rspec-rails (3.6.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) - rspec-support (~> 3.5.0) - rspec-support (3.5.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) rubocop (0.48.1) parser (>= 2.3.3.1, < 3.0) powerpack (~> 0.1) @@ -429,7 +396,6 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.8.1) - ruby_dep (1.5.0) ruby_parser (3.8.4) sexp_processor (~> 4.1) safe_yaml (1.0.4) @@ -455,7 +421,6 @@ GEM thor (~> 0.14) selectize-rails (0.12.1) sexp_processor (4.8.0) - shellany (0.0.1) simplecov (0.10.0) docile (~> 1.1.0) json (~> 1.8) @@ -556,10 +521,6 @@ DEPENDENCIES factory_girl_rails figaro (= 1.1.1) grape (= 0.12.0) - guard (= 2.12.9) - guard-rails (= 0.7.1) - guard-rspec (= 4.5.2) - guard-rubocop (= 1.2.0) haml-rails (= 0.9.0) hashie-forbidden_attributes (= 0.1.1) html2haml (= 2.1.0) @@ -593,7 +554,7 @@ DEPENDENCIES rails-settings-cached (= 0.4.1) ransack (= 1.5.1) rest-client - rspec-rails (~> 3.5) + rspec-rails (~> 3.6) rubocop (= 0.48.1) sass-rails (= 5.0.6) sdoc (= 0.4.1) diff --git a/Guardfile b/Guardfile deleted file mode 100644 index ab7619ed7..000000000 --- a/Guardfile +++ /dev/null @@ -1,52 +0,0 @@ -group :red_green_refactor, halt_on_fail: true do - # start test EPP server automatically on port 8989, - # be sure you have apache2 configured to - # accept EPP request on port 701, what proxy to 8989. - # port and environment is just for correct notification, all is overwritten by CLI - # guard :rails, port: 8989, environment: 'test' do - # # guard :rails, port: 8989, environment: 'test', CLI: 'RAILS_ENV=test unicorn -p 8989' do - # watch('Gemfile.lock') - # watch(%r{^(config|lib)/.*}) - # end - - # guard :rspec, cmd: 'spring rspec --fail-fast', notification: false do - guard :rspec, cmd: 'spring rspec', notification: false do - watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { "spec" } - - # Rails example - watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } - watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } - watch(%r{^app/controllers/epp/(.+)_(controller)\.rb$}) { |m| ["spec/epp/#{m[1].sub(/s$/,'')}_spec.rb"] } - watch(%r{^app/models/epp/(.+)\.rb$}) { |m| "spec/epp/#{m[1]}_spec.rb" } - watch(%r{^spec/support/(.+)\.rb$}) { "spec" } - watch('config/routes.rb') { "spec/routing" } - watch('app/controllers/application_controller.rb') { "spec/controllers" } - watch('spec/rails_helper.rb') { "spec" } - - # epp tests - watch('app/helpers/epp/contacts_helper.rb') { 'spec/epp/contact_spec.rb' } - watch('app/helpers/epp/domains_helper.rb') { 'spec/epp/domain_spec.rb' } - # Capybara features specs - watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } - - # Turnip features and steps - watch(%r{^spec/acceptance/(.+)\.feature$}) - watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } - end - - # Martin does not want rubocop - unless Socket.gethostname == 'martin' - guard :rubocop, - all_on_start: false, - cli: '--display-cop-names -c .rubocop-guard.yml -f fuubar', - notification: false do - - watch(%r{.+\.rb$}) - watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } - watch(%r{(?:.+/)?\.rubocop-guard\.yml$}) { |m| File.dirname(m[0]) } - end - end -end diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 7d4fc488f..b4d2a9f57 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -7,6 +7,7 @@ class DomainUpdateConfirmJob < Que::Job domain.is_admin = true case action when RegistrantVerification::CONFIRMED + old_registrant = domain.registrant domain.poll_message!(:poll_pending_update_confirmed_by_registrant) raise_errors!(domain) @@ -15,6 +16,7 @@ class DomainUpdateConfirmJob < Que::Job domain.clean_pendings! raise_errors!(domain) + RegistrantChange.new(domain: domain, old_registrant: old_registrant).confirm when RegistrantVerification::REJECTED RegistrantChangeMailer.rejected(domain: domain, registrar: domain.registrar, diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb index bbfecfca6..308bdd827 100644 --- a/app/mailers/contact_mailer.rb +++ b/app/mailers/contact_mailer.rb @@ -1,5 +1,6 @@ class ContactMailer < ApplicationMailer include Que::Mailer + helper_method :address_processing def email_updated(old_email, email, contact_id, should_deliver) @contact = Contact.find_by(id: contact_id) @@ -32,4 +33,10 @@ class ContactMailer < ApplicationMailer logger.info "EMAIL SENDING FAILED: #{email}: #{e}" end end + + private + + def address_processing + Contact.address_processing? + end end diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 8c8c2d556..f14f4b4a7 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -1,37 +1,6 @@ class DomainMailer < ApplicationMailer include Que::Mailer - 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 - return if delivery_off?(@domain, should_deliver) - - @old_registrant = Registrant.find(old_registrant_id) - @new_registrant = Registrant.find(new_registrant_id) - @address_processing = Contact.address_processing? - - return if whitelist_blocked?(@new_registrant.email) - mail(to: format(@new_registrant.email), - subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject, - name: @domain.name)} [#{@domain.name}]") - end - - - def registrant_updated_notification_for_old_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver) - @domain = Domain.find_by(id: domain_id) - return unless @domain - return if delivery_off?(@domain, should_deliver) - - @old_registrant = Registrant.find(old_registrant_id) - @new_registrant = Registrant.find(new_registrant_id) - @address_processing = Contact.address_processing? - - return if whitelist_blocked?(@old_registrant.email) - mail(to: format(@old_registrant.email), - subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_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 diff --git a/app/mailers/registrant_change_mailer.rb b/app/mailers/registrant_change_mailer.rb index 4523834e0..92ee0bd4d 100644 --- a/app/mailers/registrant_change_mailer.rb +++ b/app/mailers/registrant_change_mailer.rb @@ -1,4 +1,6 @@ class RegistrantChangeMailer < ApplicationMailer + helper_method :address_processing + def confirm(domain:, registrar:, current_registrant:, new_registrant:) @domain = DomainPresenter.new(domain: domain, view: view_context) @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context) @@ -19,6 +21,14 @@ class RegistrantChangeMailer < ApplicationMailer mail(to: new_registrant.email, subject: subject) end + def confirmed(domain:, old_registrant:) + @domain = domain + recipients = [domain.registrant_email, old_registrant.email] + subject = default_i18n_subject(domain_name: domain.name) + + mail(to: recipients, subject: subject) + end + def rejected(domain:, registrar:, registrant:) @domain = DomainPresenter.new(domain: domain, view: view_context) @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context) @@ -42,4 +52,8 @@ class RegistrantChangeMailer < ApplicationMailer def confirm_url(domain) registrant_domain_update_confirm_url(domain, token: domain.registrant_verification_token) end + + def address_processing + Contact.address_processing? + end end diff --git a/app/models/address.rb b/app/models/address.rb deleted file mode 100644 index a26b0bd28..000000000 --- a/app/models/address.rb +++ /dev/null @@ -1,72 +0,0 @@ -class Address < ActiveRecord::Base - include Versions # version/address_version.rb - - LOCAL_TYPE_SHORT = 'loc' - INTERNATIONAL_TYPE_SHORT = 'int' - LOCAL_TYPE = 'LocalAddress' - TYPES = [ - LOCAL_TYPE_SHORT, - INTERNATIONAL_TYPE_SHORT - ] - - belongs_to :contact - - def country - Country.new(country_code) - end - - class << self - # def validate_postal_info_types(parsed_frame) - # errors, used = [], [] - # parsed_frame.css('postalInfo').each do |pi| - # attr = pi.attributes['type'].try(:value) - # errors << { - # code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type') - # } and next unless attr - # unless TYPES.include?(attr) - # errors << { - # code: 2005, - # msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr } - # } - # next - # end - # errors << { - # code: 2005, - # msg: I18n.t('errors.messages.repeating_postal_info') - # } and next if used.include?(attr) - # used << attr - # end; errors - # end - - def extract_attributes(ah) - address_hash = {} - ah = ah.first if ah.is_a?(Array) - address_hash[:address_attributes] = addr_hash_from_params(ah) - address_hash - end - - private - - # def local?(postal_info) - # return :local_address_attributes if postal_info[:type] == LOCAL_TYPE_SHORT - # :international_address_attributes - # end - - def addr_hash_from_params(addr) - return {} if addr.nil? - return {} unless addr[:addr].is_a?(Hash) - { country_code: Country.new(addr[:addr][:cc]).try(:alpha2), - city: addr[:addr][:city], - street: pretty_street(addr[:addr][:street]), # [0], - # street2: addr[:addr][:street][1], - # street3: addr[:addr][:street][2], - zip: addr[:addr][:pc] - }.delete_if { |_k, v| v.nil? } - end - - def pretty_street(param_street) - return param_street.join(',') if param_street.is_a?(Array) - param_street - end - end -end diff --git a/app/models/contact.rb b/app/models/contact.rb index 5115a9ec9..1c723161d 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -3,11 +3,11 @@ class Contact < ActiveRecord::Base include EppErrors include UserEvents - belongs_to :registrar + belongs_to :registrar, required: true has_many :domain_contacts has_many :domains, through: :domain_contacts has_many :legal_documents, as: :documentable - has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id' # when contant is registrant + has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id' # TODO: remove later has_many :depricated_statuses, class_name: 'DepricatedContactStatus', dependent: :destroy @@ -19,7 +19,7 @@ class Contact < ActiveRecord::Base accepts_nested_attributes_for :legal_documents - validates :name, :phone, :email, :ident, :ident_type, :registrar, presence: true + validates :name, :phone, :email, :ident, :ident_type, presence: true validates :street, :city, :zip, :country_code, presence: true, if: 'self.class.address_processing?' validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/, phone: true @@ -429,6 +429,8 @@ class Contact < ActiveRecord::Base end def related_domain_descriptions + ActiveSupport::Deprecation.warn('Use #domain_names_with_roles') + @desc = {} registrant_domains.each do |dom| @@ -594,4 +596,28 @@ class Contact < ActiveRecord::Base return unless priv? ident end + + def ident_country + Country.new(ident_country_code) + end + + def used? + registrant_domains.any? || domain_contacts.any? + end + + def domain_names_with_roles + domain_names = {} + + registrant_domains.pluck(:name).each do |domain_name| + domain_names[domain_name] ||= Set.new + domain_names[domain_name] << Registrant.name.underscore.to_sym + end + + domain_contacts.each do |domain_contact| + domain_names[domain_contact.domain.name] ||= Set.new + domain_names[domain_contact.domain.name] << domain_contact.type.underscore.to_sym + end + + domain_names + end end diff --git a/app/models/domain.rb b/app/models/domain.rb index 172ab2039..6d16d617f 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -19,8 +19,8 @@ class Domain < ActiveRecord::Base # 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? - belongs_to :registrar - belongs_to :registrant + belongs_to :registrar, required: true + belongs_to :registrant, required: true # TODO: should we user validates_associated :registrant here? has_many :admin_domain_contacts @@ -104,8 +104,7 @@ class Domain < ActiveRecord::Base validates :name_dirty, domain_name: true, uniqueness: true validates :puny_label, length: { maximum: 63 } - validates :period, numericality: { only_integer: true } - validates :registrant, :registrar, presence: true + validates :period, presence: true, numericality: { only_integer: true } validate :validate_reservation def validate_reservation diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index f16ad7fc3..997c77fc5 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -521,9 +521,7 @@ class Epp::Domain < Domain preclean_pendings user = ApiUser.find(pending_json['current_user_id']) frame = Nokogiri::XML(pending_json['frame']) - old_registrant_id = registrant_id - self.deliver_emails = true # turn on email delivery self.statuses.delete(DomainStatus::PENDING_UPDATE) self.upid = user.registrar.id if user.registrar self.up_date = Time.zone.now @@ -531,11 +529,9 @@ class Epp::Domain < Domain return unless update(frame, user, false) clean_pendings! - save! # for notification if everything fails + save! WhoisRecord.find_by(domain_id: id).save # need to reload model - DomainMailer.registrant_updated_notification_for_old_registrant(id, old_registrant_id, registrant_id, true).deliver - DomainMailer.registrant_updated_notification_for_new_registrant(id, old_registrant_id, registrant_id, true).deliver true end diff --git a/app/models/soap/arireg.rb b/app/models/soap/arireg.rb index 422a72dd9..98810eeda 100644 --- a/app/models/soap/arireg.rb +++ b/app/models/soap/arireg.rb @@ -61,18 +61,8 @@ module Soap def initialize if self.class.username.nil? - if Rails.application.secrets.key?(:arireg) - arireg = Rails.application.secrets[:arireg].with_indifferent_access - self.class.username = arireg[:username] - self.class.password = arireg[:password] - if self.class.wsdl.nil? # no override of config/environments/* ? - self.class.wsdl = arireg[:wsdl] - self.class.host = arireg[:host] - end - else - self.class.username = ENV['arireg_username'] - self.class.password = ENV['arireg_password'] - end + self.class.username = ENV['arireg_username'] + self.class.password = ENV['arireg_password'] end if self.class.wsdl.nil? self.class.wsdl = ENV['arireg_wsdl'] diff --git a/app/models/version/address_version.rb b/app/models/version/address_version.rb deleted file mode 100644 index 736307c74..000000000 --- a/app/models/version/address_version.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddressVersion < PaperTrail::Version - include VersionSession - self.table_name = :log_addresses - self.sequence_name = :log_addresses_id_seq -end diff --git a/app/presenters/registrant_presenter.rb b/app/presenters/registrant_presenter.rb index d18fd7cb6..148c5d219 100644 --- a/app/presenters/registrant_presenter.rb +++ b/app/presenters/registrant_presenter.rb @@ -1,13 +1,38 @@ class RegistrantPresenter - delegate :name, :ident, :email, :priv?, :street, :city, :id_code, :reg_no, to: :registrant + delegate :name, + :ident, + :phone, + :email, + :priv?, + :id_code, + :reg_no, + :street, :city, :state, :zip, :country, + :ident_country, + :used?, + to: :registrant def initialize(registrant:, view:) @registrant = registrant @view = view end - def country + def country(locale: I18n.locale) + registrant.country.translation(locale) + end + def ident_country(locale: I18n.locale) + registrant.ident_country.translation(locale) + end + + def domain_names_with_roles(locale: I18n.locale, line_break: "\n") + lines = [] + + registrant.domain_names_with_roles.each do |domain_name, roles| + lines << "#{domain_name} (#{roles.map { |role| role.to_s.classify.constantize.model_name.human(locale: locale) } + .join(', ')})" + end + + lines.join(line_break).html_safe end private diff --git a/app/services/registrant_change.rb b/app/services/registrant_change.rb new file mode 100644 index 000000000..a820dbe8d --- /dev/null +++ b/app/services/registrant_change.rb @@ -0,0 +1,19 @@ +class RegistrantChange + def initialize(domain:, old_registrant:) + @domain = domain + @old_registrant = old_registrant + end + + def confirm + notify_registrant + end + + private + + def notify_registrant + RegistrantChangeMailer.confirmed(domain: domain, old_registrant: old_registrant).deliver_now + end + + attr_reader :domain + attr_reader :old_registrant +end diff --git a/app/views/admin/domain_versions/archive.haml b/app/views/admin/domain_versions/archive.haml index b519272d5..2a22284e9 100644 --- a/app/views/admin/domain_versions/archive.haml +++ b/app/views/admin/domain_versions/archive.haml @@ -11,11 +11,11 @@ .col-md-3 .form-group = label_tag :registrant - = f.search_field :registrant, value: params[:q][:registrant], class: 'form-control', placeholder: t(:registrant) + = f.search_field :registrant, value: params[:q][:registrant], class: 'form-control', placeholder: t('.registrant_placeholder') .col-md-3 .form-group = label_tag t(:registrar_name) - = f.search_field :registrar, value: params[:q][:registrar], class: 'form-control', placeholder: t(:registrant) + = f.search_field :registrar, value: params[:q][:registrar], class: 'form-control', placeholder: t('.registrant') .col-md-3 .form-group = label_tag :action @@ -45,7 +45,7 @@ %th{class: 'col-xs-2'} = t(:name) %th{class: 'col-xs-2'} - = t(:registrant) + = t('.registrant') %th{class: 'col-xs-2'} = t(:registrar_name) %th{class: 'col-xs-2'} diff --git a/app/views/admin/domain_versions/show.haml b/app/views/admin/domain_versions/show.haml index 4382b13ab..d0863eed5 100644 --- a/app/views/admin/domain_versions/show.haml +++ b/app/views/admin/domain_versions/show.haml @@ -30,11 +30,11 @@ - domain_name = domain.name %dd= link_to(domain_name, admin_domain_path(@version.item_id)) - %dt= t(:created) + %dt= t('.created') %dd = l(domain.created_at, format: :short) - %dt= t(:updated) + %dt= t('.updated') %dd = l(domain.updated_at, format: :short) @@ -46,7 +46,7 @@ - domain.statuses.each do |s| = s - %dt= t(:registrant) + %dt= t('.registrant') %dd{class: changing_css_class(@version,"registrant_id")} - registrant.each do |r| - link = r.version_loader ? admin_contact_version_path(r.version_loader.try(:id)) : admin_contact_path(r.id) @@ -57,7 +57,7 @@ = r[:code] %br - %dt= t(:admin_contacts) + %dt= t('.admin_contacts') %dd - admin_contacts.each do |r| - link = r.version_loader ? admin_contact_version_path(r.version_loader.try(:id)) : admin_contact_path(r.id) @@ -68,7 +68,7 @@ = r[:code] %br - %dt= t(:tech_contacts) + %dt= t('.tech_contacts') %dd - tech_contacts.each do |r| - link = r.version_loader ? admin_contact_version_path(r.version_loader.try(:id)) : admin_contact_path(r.id) diff --git a/app/views/admin/domains/index.haml b/app/views/admin/domains/index.haml index 7c3be9032..f72ce8ff8 100644 --- a/app/views/admin/domains/index.haml +++ b/app/views/admin/domains/index.haml @@ -58,7 +58,7 @@ %th{class: 'col-xs-2'} = sort_link(@q, 'name') %th{class: 'col-xs-2'} - = sort_link(@q, 'registrant_name', t(:registrant)) + = sort_link(@q, 'registrant_name', t('.registrant')) %th{class: 'col-xs-2'} = sort_link(@q, 'valid_to', t(:valid_to)) %th{class: 'col-xs-2'} diff --git a/app/views/admin/domains/partials/_admin_contacts.haml b/app/views/admin/domains/partials/_admin_contacts.haml index 0db8f6e32..bf14bf1bb 100644 --- a/app/views/admin/domains/partials/_admin_contacts.haml +++ b/app/views/admin/domains/partials/_admin_contacts.haml @@ -1,7 +1,7 @@ - panel_class = @domain.errors.messages[:admin_contacts] ? 'panel-danger' : 'panel-default' .panel{class: panel_class} .panel-heading.clearfix - = t(:admin_contacts) + = t('.title') .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead diff --git a/app/views/admin/domains/partials/_owner.haml b/app/views/admin/domains/partials/_owner.haml index 7f499f86b..c08170650 100644 --- a/app/views/admin/domains/partials/_owner.haml +++ b/app/views/admin/domains/partials/_owner.haml @@ -1,6 +1,6 @@ .panel.panel-default .panel-heading - %h3.panel-title= t(:registrant) + %h3.panel-title= t('.title') .panel-body %dl.dl-horizontal %dt= t(:name) diff --git a/app/views/admin/domains/partials/_tech_contacts.haml b/app/views/admin/domains/partials/_tech_contacts.haml index 20badbea8..c3109bc57 100644 --- a/app/views/admin/domains/partials/_tech_contacts.haml +++ b/app/views/admin/domains/partials/_tech_contacts.haml @@ -1,7 +1,7 @@ - panel_class = @domain.errors.messages[:tech_contacts] ? 'panel-danger' : 'panel-default' #tech_contacts.panel{class: panel_class} .panel-heading.clearfix - = t(:tech_contacts) + = t('.title') .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead diff --git a/app/views/admin/domains/versions.haml b/app/views/admin/domains/versions.haml index 408ef9a67..7447ab6f8 100644 --- a/app/views/admin/domains/versions.haml +++ b/app/views/admin/domains/versions.haml @@ -11,9 +11,9 @@ %th{class: 'col-xs-1'}= t('.time') %th{class: 'col-xs-2'}= t(:statuses) %th{class: 'col-xs-1'}= t(:period) - %th{class: 'col-xs-2'}= t(:registrant) + %th{class: 'col-xs-2'}= t('.registrant') %th{class: 'col-xs-2'}= t('.admin_contact') - %th{class: 'col-xs-2'}= t(:tech) + %th{class: 'col-xs-2'}= t('.tech_contact') %th{class: 'col-xs-2'}= t(:nameservers) %th{class: 'col-xs-2'}= t(:dnskeys) %th{class: 'col-xs-2'}= t(:registrar_name) diff --git a/app/views/mailers/contact_mailer/email_updated.html.erb b/app/views/mailers/contact_mailer/email_updated.html.erb index 6c88f5009..a4f6d8583 100644 --- a/app/views/mailers/contact_mailer/email_updated.html.erb +++ b/app/views/mailers/contact_mailer/email_updated.html.erb @@ -1,55 +1,49 @@ -Tere <%= @contact.name %> +<% + contact = RegistrantPresenter.new(registrant: @contact, view: self) + registrar = RegistrarPresenter.new(registrar: @contact.registrar, view: self) +%> +Tere <%= contact.name %>

-Kontakti <%= @contact.name %> e-posti aadress on muudetud
+Kontakti <%= contact.name %> e-posti aadress on muudetud
endine aadress: <%= @old_email %>
-uus aadress: <%= @contact.email %> +uus aadress: <%= contact.email %>

-E-posti aadressile saadetakse domeeni toimingutega seotud infot, sealhulgas kinnitustaotlused omanikuvahetuse ja domeeni kustutamise korral. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja <%= @contact.registrar.name %> poole. +E-posti aadressile saadetakse domeeni toimingutega seotud infot, sealhulgas kinnitustaotlused omanikuvahetuse ja domeeni kustutamise korral.

-<% if @contact.related_domain_descriptions.present? %> -Muudatusega seotud domeenid:
-<% @contact.related_domain_descriptions.each do |domain, desc| %> - <%= domain %> (<%= desc.map { |d| t(d, locale: :et) }.join(', ') %>)
+<% if contact.used? %> + Muudatusega seotud domeenid:
+ <%= contact.domain_names_with_roles(locale: :et, line_break: '
') %> <% end %> -<% end %> -
+

Kontaktandmed:
-Nimi: <%= @contact.name %>
-Isikukood: <%= @contact.ident %>
-E-post: <%= @contact.email %>
-Tel: <%= @contact.phone %>
-Tänav: <%= @contact.street %>
-Linn: <%= @contact.city %>
-Riik: <%= @contact.country %> +<%= render 'mailers/shared/registrant/registrant.et.html', registrant: contact, with_phone: true %> +

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

Lugupidamisega
Eesti Interneti Sihtasutus




-Hi <%= @contact.name %> +Hi <%= contact.name %>

-E-mail address of <%= @contact.name %> has been changed
+E-mail address of <%= contact.name %> has been changed
previous address: <%= @old_email %>
-new address: <%= @contact.email %> +new address: <%= contact.email %>

-E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @contact.registrar.name %> +E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct.

-<% if @contact.related_domain_descriptions.present? %> -Domains affected by this update:
-<% @contact.related_domain_descriptions.each do |domain, desc| %> - <%= domain %> (<%= desc.map { |d| t(d, locale: :en) }.join(', ') %>)
+<% if contact.used? %> + Domains affected by this update:
+ <%= contact.domain_names_with_roles(line_break: '
') %> <% end %> -<% end %> -
+

Contact information:
-Name: <%= @contact.name %>
-Identity Code: <%= @contact.ident %>
-E-mail: <%= @contact.email %>
-Tel: <%= @contact.phone %>
-Street: <%= @contact.street %>
-City: <%= @contact.city %>
-Country: <%= @contact.country %> +<%= render 'mailers/shared/registrant/registrant.en.html', registrant: contact, with_phone: true %> +

+In case of problems please turn to your registrar: +<%= render 'mailers/shared/registrar/registrar.en.html', registrar: registrar %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/contact_mailer/email_updated.text.erb b/app/views/mailers/contact_mailer/email_updated.text.erb index 56cb319bc..97e46a5eb 100644 --- a/app/views/mailers/contact_mailer/email_updated.text.erb +++ b/app/views/mailers/contact_mailer/email_updated.text.erb @@ -1,55 +1,49 @@ -Tere <%= @contact.name %> +<% + contact = RegistrantPresenter.new(registrant: @contact, view: self) + registrar = RegistrarPresenter.new(registrar: @contact.registrar, view: self) +%> +Tere <%= contact.name %> -Kontakti <%= @contact.name %> e-posti aadress on muudetud +Kontakti <%= contact.name %> e-posti aadress on muudetud endine aadress: <%= @old_email %> -uus aadress: <%= @contact.email %> +uus aadress: <%= contact.email %> -E-posti aadressile saadetakse domeeni toimingutega seotud infot, sealhulgas kinnitustaotlused omanikuvahetuse ja domeeni kustutamise korral. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja <%= @contact.registrar.name %> poole. +E-posti aadressile saadetakse domeeni toimingutega seotud infot, sealhulgas kinnitustaotlused omanikuvahetuse ja domeeni kustutamise korral. -<% if @contact.related_domain_descriptions.present? %> -Muudatusega seotud domeenid: - <% @contact.related_domain_descriptions.each do |domain, desc| %> - <%= domain %> (<%= desc.map { |d| t(d, locale: :et) }.join(', ') %>) - <% end %> +<% if contact.used? %> + Muudatusega seotud domeenid: + <%= contact.domain_names_with_roles(locale: :et) %> <% end %> Kontaktandmed: -Nimi: <%= @contact.name %> -Isikukood: <%= @contact.ident %> -E-post: <%= @contact.email %> -Tel: <%= @contact.phone %> -Tänav: <%= @contact.street %> -Linn: <%= @contact.city %> -Riik: <%= @contact.country %> +<%= render 'mailers/shared/registrant/registrant.et.text', registrant: contact, with_phone: true %> + +Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: +<%= render 'mailers/shared/registrar/registrar.et.text', registrar: registrar %> Lugupidamisega Eesti Interneti Sihtasutus ---------------------------------------------------------------------------------- -Hi <%= @contact.name %> +Hi <%= contact.name %> -E-mail address of <%= @contact.name %> has been changed +E-mail address of <%= contact.name %> has been changed previous address: <%= @old_email %> -new address: <%= @contact.email %> +new address: <%= contact.email %> -E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @contact.registrar.name %> +E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. -<% if @contact.related_domain_descriptions.present? %> -Domains affected by this update: - <% @contact.related_domain_descriptions.each do |domain, desc| %> - <%= domain %> (<%= desc.map { |d| t(d, locale: :en) }.join(', ') %>) - <% end %> +<% if contact.used? %> + Domains affected by this update: + <%= contact.domain_names_with_roles %> <% end %> Contact information: -Name: <%= @contact.name %> -Identity Code: <%= @contact.ident %> -E-mail: <%= @contact.email %> -Tel: <%= @contact.phone %> -Street: <%= @contact.street %> -City: <%= @contact.city %> -Country: <%= @contact.country %> +<%= render 'mailers/shared/registrant/registrant.en.text', registrant: contact, with_phone: true %> + +In case of problems please turn to your registrar: +<%= render 'mailers/shared/registrar/registrar.en.text', registrar: registrar %> Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb deleted file mode 100644 index 9797b18b3..000000000 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb +++ /dev/null @@ -1,43 +0,0 @@ -Tere -

-Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. -

-Uue registreerija andmed:
-Nimi: <%= @new_registrant.name %>
-<% if @new_registrant.priv? %> - Isikukood: <%= @new_registrant.ident %>
-<% else %> - Äriregistrikood: <%= @new_registrant.ident %>
-<% end %> -Epost: <%= @new_registrant.email %>
-<% if @address_processing -%> -Tänav: <%= @new_registrant.street %>
-Linn: <%= @new_registrant.city %>
-Riik: <%= @new_registrant.country.name %> -<% end -%> -

-Lugupidamisega
-Eesti Interneti Sihtasutus -

-
-

-Hi, -

-Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. -

-New registrant:
-Name: <%= @new_registrant.name %>
-<% if @new_registrant.priv? %> - Personal code: <%= @new_registrant.ident %>
-<% else %> - Business Registry code: <%= @new_registrant.ident %>
-<% end %> -E-mail: <%= @new_registrant.email %>
-<% if @address_processing -%> -Street: <%= @new_registrant.street %>
-City: <%= @new_registrant.city %>
-Country: <%= @new_registrant.country.name %> -<% end -%> -

-Best Regards,
-Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb deleted file mode 100644 index fec027aaa..000000000 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb +++ /dev/null @@ -1,45 +0,0 @@ -Tere - -Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. - -Uue registreerija andmed: -Nimi: <%= @new_registrant.name %> - -<% if @new_registrant.priv? %> - Isikukood: <%= @new_registrant.ident %> -<% else %> - Äriregistrikood: <%= @new_registrant.ident %> -<% end %> -Epost: <%= @new_registrant.email %> -<% if @address_processing -%> -Tänav: <%= @new_registrant.street %> -Linn: <%= @new_registrant.city %> -Riik: <%= @new_registrant.country.name %> -<% end -%> - -Lugupidamisega -Eesti Interneti Sihtasutus - --------------------------------------- - -Hi, - -Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. - -New registrant: -Name: <%= @new_registrant.name %> - -<% if @new_registrant.priv? %> - Personal code: <%= @new_registrant.ident %> -<% else %> - Business Registry code: <%= @new_registrant.ident %> -<% end %> -E-mail: <%= @new_registrant.email %> -<% if @address_processing -%> -Street: <%= @new_registrant.street %> -City: <%= @new_registrant.city %> -Country: <%= @new_registrant.country.name %> -<% end -%> - -Best Regards, -Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb deleted file mode 100644 index b1cf2ff7b..000000000 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ /dev/null @@ -1,43 +0,0 @@ -Tere -

-Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. -

-Uue registreerija andmed:
-Nimi: <%= @new_registrant.name %>
-<% if @new_registrant.priv? %> -Isikukood: <%= @new_registrant.ident %>
-<% else %> -Äriregistrikood: <%= @new_registrant.ident %>
-<% end %> -Epost: <%= @new_registrant.email %>
-<% if @address_processing -%> -Tänav: <%= @new_registrant.street %>
-Linn: <%= @new_registrant.city %>
-Riik: <%= @new_registrant.country.name %> -<% end -%> -

-Lugupidamisega
-Eesti Interneti Sihtasutus -

-
-

-Hi, -

-Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. -

-New registrant:
-Name: <%= @new_registrant.name %>
-<% if @new_registrant.priv? %> -Personal code: <%= @new_registrant.ident %>
-<% else %> -Business Registry code: <%= @new_registrant.ident %>
-<% end %> -E-mail: <%= @new_registrant.email %>
-<% if @address_processing -%> -Street: <%= @new_registrant.street %>
-City: <%= @new_registrant.city %>
-Country: <%= @new_registrant.country.name %> -<% end -%> -

-Best Regards,
-Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb deleted file mode 100644 index 5a333e662..000000000 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb +++ /dev/null @@ -1,45 +0,0 @@ -Tere - -Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. - -Uue registreerija andmed: -Nimi: <%= @new_registrant.name %> - -<% if @new_registrant.priv? %> -Isikukood: <%= @new_registrant.ident %> -<% else %> -Äriregistrikood: <%= @new_registrant.ident %> -<% end %> -Epost: <%= @new_registrant.email %> -<% if @address_processing -%> -Tänav: <%= @new_registrant.street %> -Linn: <%= @new_registrant.city %> -Riik: <%= @new_registrant.country.name %> -<% end -%> - -Lugupidamisega -Eesti Interneti Sihtasutus - --------------------------------------- - -Hi, - -Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. - -New registrant: -Name: <%= @new_registrant.name %> - -<% if @new_registrant.priv? %> -Personal code: <%= @new_registrant.ident %> -<% else %> -Business Registry code: <%= @new_registrant.ident %> -<% end %> -E-mail: <%= @new_registrant.email %> -<% if @address_processing -%> -Street: <%= @new_registrant.street %> -City: <%= @new_registrant.city %> -Country: <%= @new_registrant.country.name %> -<% end -%> - -Best Regards, -Estonian Internet Foundation diff --git a/app/views/mailers/registrant_change_mailer/confirmed.html.erb b/app/views/mailers/registrant_change_mailer/confirmed.html.erb new file mode 100644 index 000000000..b56aae53c --- /dev/null +++ b/app/views/mailers/registrant_change_mailer/confirmed.html.erb @@ -0,0 +1,25 @@ +<% + domain = DomainPresenter.new(domain: @domain, view: self) + new_registrant = RegistrantPresenter.new(registrant: @domain.registrant, view: self) +%> +Tere +

+Domeeni <%= domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +

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

+Lugupidamisega
+Eesti Interneti Sihtasutus +

+
+

+Hi, +

+Process for changing registrant of the domain <%= domain.name %> has been approved and the data in the registry is updated. +

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

+Best Regards,
+Estonian Internet Foundation diff --git a/app/views/mailers/registrant_change_mailer/confirmed.text.erb b/app/views/mailers/registrant_change_mailer/confirmed.text.erb new file mode 100644 index 000000000..2bab1f4c2 --- /dev/null +++ b/app/views/mailers/registrant_change_mailer/confirmed.text.erb @@ -0,0 +1,25 @@ +<% + domain = DomainPresenter.new(domain: @domain, view: self) + new_registrant = RegistrantPresenter.new(registrant: @domain.registrant, view: self) +%> +Tere + +Domeeni <%= domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. + +Uue registreerija andmed: +<%= render 'mailers/shared/registrant/registrant.et.text', registrant: new_registrant %> + +Lugupidamisega +Eesti Interneti Sihtasutus + +-------------------------------------- + +Hi, + +Process for changing registrant of the domain <%= domain.name %> has been approved and the data in the registry is updated. + +New registrant: +<%= render 'mailers/shared/registrant/registrant.en.text', registrant: new_registrant %> + +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 index 300157c83..1626b12ff 100644 --- a/app/views/mailers/shared/registrant/_registrant.en.html.erb +++ b/app/views/mailers/shared/registrant/_registrant.en.html.erb @@ -4,6 +4,15 @@ Name: <%= registrant.name %>
<% else %> Business Registry code: <%= registrant.ident %>
<% end %> -Street: <%= registrant.street %>
-City: <%= registrant.city %>
-Country: <%= registrant.country %> +<% if local_assigns[:with_phone] -%> + Phone: <%= registrant.phone %>
+<% end -%> +<% if address_processing -%> + Street: <%= registrant.street %>
+ City: <%= registrant.city %>
+ State: <%= registrant.state %>
+ Zip-code: <%= registrant.zip %>
+ Country: <%= registrant.country %> +<% else %> + Country: <%= registrant.ident_country %> +<% end -%> diff --git a/app/views/mailers/shared/registrant/_registrant.en.text.erb b/app/views/mailers/shared/registrant/_registrant.en.text.erb index 649e2c452..4f6482be7 100644 --- a/app/views/mailers/shared/registrant/_registrant.en.text.erb +++ b/app/views/mailers/shared/registrant/_registrant.en.text.erb @@ -4,6 +4,15 @@ Name: <%= registrant.name %> <% else %> Business Registry code: <%= registrant.ident %> <% end %> -Street: <%= registrant.street %> -City: <%= registrant.city %> -Country: <%= registrant.country %> +<% if local_assigns[:with_phone] -%> + Phone: <%= registrant.phone %> +<% end -%> +<% if address_processing -%> + Street: <%= registrant.street %> + City: <%= registrant.city %> + State: <%= registrant.state %> + Zip-code: <%= registrant.zip %> + Country: <%= registrant.country %> +<% else %> + Country: <%= registrant.ident_country %> +<% end -%> diff --git a/app/views/mailers/shared/registrant/_registrant.et.html.erb b/app/views/mailers/shared/registrant/_registrant.et.html.erb index 789b88490..b396c3428 100644 --- a/app/views/mailers/shared/registrant/_registrant.et.html.erb +++ b/app/views/mailers/shared/registrant/_registrant.et.html.erb @@ -4,6 +4,15 @@ Nimi: <%= registrant.name %>
<% else %> Äriregistrikood: <%= registrant.ident %>
<% end %> -Tänav: <%= registrant.street %>
-Linn: <%= registrant.city %>
-Riik: <%= registrant.country %> +<% if local_assigns[:with_phone] -%> + Telefon: <%= registrant.phone %>
+<% end -%> +<% if address_processing -%> + Tänav: <%= registrant.street %>
+ Linn: <%= registrant.city %>
+ Maakond: <%= registrant.state %>
+ Sihtnumber: <%= registrant.zip %>
+ Riik: <%= registrant.country(locale: :et) %> +<% else %> + Riik: <%= registrant.ident_country(locale: :et) %> +<% end -%> diff --git a/app/views/mailers/shared/registrant/_registrant.et.text.erb b/app/views/mailers/shared/registrant/_registrant.et.text.erb index 01ece5e67..0ff02d51d 100644 --- a/app/views/mailers/shared/registrant/_registrant.et.text.erb +++ b/app/views/mailers/shared/registrant/_registrant.et.text.erb @@ -4,6 +4,15 @@ Nimi: <%= registrant.name %> <% else %> Äriregistrikood: <%= registrant.ident %> <% end %> -Tänav: <%= registrant.street %> -Linn: <%= registrant.city %> -Riik: <%= registrant.country %> +<% if local_assigns[:with_phone] -%> + Telefon: <%= registrant.phone %> +<% end -%> +<% if address_processing -%> + Tänav: <%= registrant.street %> + Linn: <%= registrant.city %> + Maakond: <%= registrant.state %> + Sihtnumber: <%= registrant.zip %> + Riik: <%= registrant.country(locale: :et) %> +<% else %> + Riik: <%= registrant.ident_country(locale: :et) %> +<% end -%> diff --git a/app/views/registrant/domain_delete_confirms/show.haml b/app/views/registrant/domain_delete_confirms/show.haml index fca337844..e2b42b56d 100644 --- a/app/views/registrant/domain_delete_confirms/show.haml +++ b/app/views/registrant/domain_delete_confirms/show.haml @@ -26,7 +26,7 @@ .col-md-12.text-center.confirmation .column-keys %p= t(:domain_name) + ':' - %p= t(:registrant) + ':' + %p= t('.registrant') + ':' .column-values %p= @domain.name %p= "#{@domain.registrant_name} (#{@domain.registrant.ident})" diff --git a/app/views/registrant/domains/download_list.haml b/app/views/registrant/domains/download_list.haml index 481324e62..f0af344cd 100644 --- a/app/views/registrant/domains/download_list.haml +++ b/app/views/registrant/domains/download_list.haml @@ -12,7 +12,7 @@ %th{class: 'col-xs-2'} =t(:name) %th{class: 'col-xs-2'} - =t(:registrant) + =t('.registrant') %th{class: 'col-xs-2'} =t(:valid_to) %th{class: 'col-xs-2'} diff --git a/app/views/registrant/domains/index.haml b/app/views/registrant/domains/index.haml index 319ff7688..b902229d0 100644 --- a/app/views/registrant/domains/index.haml +++ b/app/views/registrant/domains/index.haml @@ -57,7 +57,7 @@ %th{class: 'col-xs-2'} = sort_link(@q, 'name') %th{class: 'col-xs-2'} - = sort_link(@q, 'registrant_name', t(:registrant)) + = sort_link(@q, 'registrant_name', t('.registrant')) %th{class: 'col-xs-2'} = sort_link(@q, 'valid_to', t(:valid_to)) %th{class: 'col-xs-2'} diff --git a/app/views/registrant/domains/partials/_admin_contacts.haml b/app/views/registrant/domains/partials/_admin_contacts.haml index 5e49d3fbc..5ee50c31d 100644 --- a/app/views/registrant/domains/partials/_admin_contacts.haml +++ b/app/views/registrant/domains/partials/_admin_contacts.haml @@ -1,7 +1,7 @@ - panel_class = @domain.errors.messages[:admin_contacts] ? 'panel-danger' : 'panel-default' .panel{class: panel_class} .panel-heading.clearfix - = t(:admin_contacts) + = t('.title') .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead diff --git a/app/views/registrant/domains/partials/_owner.haml b/app/views/registrant/domains/partials/_owner.haml index 812b97924..01bfa9ea9 100644 --- a/app/views/registrant/domains/partials/_owner.haml +++ b/app/views/registrant/domains/partials/_owner.haml @@ -1,6 +1,6 @@ .panel.panel-default .panel-heading - %h3.panel-title= t(:registrant) + %h3.panel-title= t('.title') .panel-body %dl.dl-horizontal %dt= t(:name) diff --git a/app/views/registrant/domains/partials/_tech_contacts.haml b/app/views/registrant/domains/partials/_tech_contacts.haml index 12844a41e..c1177ae4b 100644 --- a/app/views/registrant/domains/partials/_tech_contacts.haml +++ b/app/views/registrant/domains/partials/_tech_contacts.haml @@ -1,7 +1,7 @@ - panel_class = @domain.errors.messages[:tech_contacts] ? 'panel-danger' : 'panel-default' #tech_contacts.panel{class: panel_class} .panel-heading.clearfix - = t(:tech_contacts) + = t('.title') .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead diff --git a/app/views/registrar/domains/form/_general.haml b/app/views/registrar/domains/form/_general.haml index 91ae7462f..0a729a262 100644 --- a/app/views/registrar/domains/form/_general.haml +++ b/app/views/registrar/domains/form/_general.haml @@ -18,7 +18,7 @@ .form-group .col-md-3.control-label - = label_tag :domain_registrant, t(:registrant), class: 'required' + = label_tag :domain_registrant, t('.registrant'), class: 'required' .col-md-7 = text_field_tag 'domain[registrant]', @domain_params[:registrant], class: "hidden" = text_field_tag 'domain[registrant_helper]', contacts.find_by(code: @domain_params[:registrant]).try(:search_name), diff --git a/app/views/registrar/domains/index.haml b/app/views/registrar/domains/index.haml index 609e4f3a8..29c88d39c 100644 --- a/app/views/registrar/domains/index.haml +++ b/app/views/registrar/domains/index.haml @@ -67,7 +67,7 @@ %th{class: 'col-xs-2'} = sort_link(@q, 'name') %th{class: 'col-xs-2'} - = sort_link(@q, 'registrant_name', t(:registrant)) + = sort_link(@q, 'registrant_name', t('.registrant')) %th{class: 'col-xs-2'} = sort_link(@q, 'valid_to', t(:valid_to)) %th{class: 'col-xs-2'}= t('actions') diff --git a/app/views/registrar/domains/partials/_general.haml b/app/views/registrar/domains/partials/_general.haml index ca3dd9992..db06b3376 100644 --- a/app/views/registrar/domains/partials/_general.haml +++ b/app/views/registrar/domains/partials/_general.haml @@ -11,7 +11,7 @@ %dd= @data.css('clID').text - registrant = Contact.find_by_code(@data.css('registrant').text) - %dt= t(:registrant) + %dt= t('.registrant') %dd= "#{registrant.name} (#{@data.css('registrant').text})" %dt= t('.registered') diff --git a/config/application-example.yml b/config/application-example.yml index 20b9370e1..9d68e44e8 100644 --- a/config/application-example.yml +++ b/config/application-example.yml @@ -92,7 +92,6 @@ restful_whois_url: 'https://restful-whois.example.com' # # Estonian Business Registry # -# config/secrets.yml --- arireg: {username, password} arireg_username: 'kasutaja' arireg_password: 'parool' # config/environments/production.rb --- Soap::Arireg.wsdl, Soap::Arireg.host diff --git a/config/application.rb b/config/application.rb index e946f5d11..a0c67526e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -80,6 +80,7 @@ module Registry } config.action_view.default_form_builder = 'DefaultFormBuilder' + config.secret_key_base = Figaro.env.secret_key_base end end diff --git a/config/initializers/set_secret.rb b/config/initializers/set_secret.rb deleted file mode 100644 index ed1dbae7f..000000000 --- a/config/initializers/set_secret.rb +++ /dev/null @@ -1 +0,0 @@ -Registry::Application.config.secret_token = ENV['secret_key_base'] diff --git a/config/locales/admin/domain_versions.en.yml b/config/locales/admin/domain_versions.en.yml index a1f4f5a46..93111757c 100644 --- a/config/locales/admin/domain_versions.en.yml +++ b/config/locales/admin/domain_versions.en.yml @@ -3,3 +3,12 @@ en: domain_versions: archive: reset_btn: Reset + registrant_placeholder: Registrant + registrant: Registrant + + show: + created: Created + updated: Updated + registrant: Registrant + admin_contacts: Admin. contacts + tech_contacts: Tech. contacts diff --git a/config/locales/admin/domains.en.yml b/config/locales/admin/domains.en.yml index ae0626ffb..26b85c9bb 100644 --- a/config/locales/admin/domains.en.yml +++ b/config/locales/admin/domains.en.yml @@ -3,6 +3,7 @@ en: domains: index: reset_btn: Reset + registrant: Registrant edit: add_new_status_btn: Add new status @@ -22,7 +23,9 @@ en: versions: time: Time - admin_contact: Admin contact + registrant: Registrant + admin_contact: Admin. contact + tech_contact: Tech. contact partials: general: @@ -30,6 +33,15 @@ en: delete_time: Delete time force_delete_time: Force delete time + admin_contacts: + title: Admin. contacts + + tech_contacts: + title: Tech. contacts + + owner: + title: Registrant + force_delete_toggle_btn: schedule: Schedule force delete cancel: Cancel force delete diff --git a/config/locales/contacts.en.yml b/config/locales/contacts.en.yml index 7936bd4b6..2061d2abd 100644 --- a/config/locales/contacts.en.yml +++ b/config/locales/contacts.en.yml @@ -1,5 +1,10 @@ en: activerecord: + models: + # Used in ContactMailer + registrant: Registrant + admin_domain_contact: Administrative contact + tech_domain_contact: Technical contact errors: models: contact: diff --git a/config/locales/contacts.et.yml b/config/locales/contacts.et.yml new file mode 100644 index 000000000..5cbaeb06a --- /dev/null +++ b/config/locales/contacts.et.yml @@ -0,0 +1,7 @@ +et: + activerecord: + models: + # Used in ContactMailer + registrant: Registreerija + admin_domain_contact: Halduskontakt + tech_domain_contact: Tehniline kontakt diff --git a/config/locales/en.yml b/config/locales/en.yml index 29a9ee5f4..3f70d8828 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -285,8 +285,6 @@ en: valid_from: 'Valid from' general: 'General' contacts: 'Contacts' - tech_contacts: 'Technical contacts' - admin_contacts: 'Admin contacts' identity_code: 'Identity code' nameservers: 'Nameservers' hostname: 'Hostname' @@ -319,7 +317,6 @@ en: failed_to_update_status: 'Failed to update status!' status_deleted: 'Status deleted!' failed_to_delete_status: 'Failed to delete status!' - tech_contact: 'Tech contact' new_domain_contact: 'New contact' domain_status_prohibits_deleting: 'Domain status prohibits deleting' domain_deleted: 'Domain deleted!' @@ -553,11 +550,9 @@ en: info: 'Info' register: 'Register' send_epp_request: 'Send EPP Request' - registrant: 'Registrant' created_at: 'Created at' valid_to: 'Valid to' updated_at: 'Updated at' - tech_contacts: 'Tech contacts' name: 'Name' type: 'Type' code: 'Code' @@ -760,8 +755,6 @@ 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' - 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.' 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" diff --git a/config/locales/et.yml b/config/locales/et.yml index 6f8a51040..37e1e9dea 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -2,6 +2,3 @@ et: username: 'Kasutajanimi' password: 'Parool' log_in: 'Logi sisse' - registrant: registreerija - tech: tehniline kontakt - admin: halduskontakt diff --git a/config/locales/mailers/registrant_change.en.yml b/config/locales/mailers/registrant_change.en.yml index 9cd95f648..87a7cc492 100644 --- a/config/locales/mailers/registrant_change.en.yml +++ b/config/locales/mailers/registrant_change.en.yml @@ -6,5 +6,9 @@ en: 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 + confirmed: + subject: >- + Domeeni %{domain_name} registreerija vahetus teostatud + / Registrant change of %{domain_name} has been finished expired: subject: Domeeni %{domain_name} registreerija vahetuse taotlus on tühistatud / %{domain_name} registrant change cancelled diff --git a/config/locales/registrant/domain_delete_confirms.en.yml b/config/locales/registrant/domain_delete_confirms.en.yml new file mode 100644 index 000000000..a53d23f1c --- /dev/null +++ b/config/locales/registrant/domain_delete_confirms.en.yml @@ -0,0 +1,5 @@ +en: + registrant: + domain_delete_confirms: + show: + registrant: Registrant diff --git a/config/locales/registrant/domains.en.yml b/config/locales/registrant/domains.en.yml new file mode 100644 index 000000000..efbe514e5 --- /dev/null +++ b/config/locales/registrant/domains.en.yml @@ -0,0 +1,17 @@ +en: + registrant: + domains: + index: + registrant: Registrant + + download_list: + registrant: Registrant + partials: + owner: + title: Registrant + + admin_contacts: + title: Admin. contacts + + tech_contacts: + title: Tech. contacts diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index 287704d29..61d5001ad 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -2,6 +2,7 @@ en: registrar: domains: index: + registrant: Registrant download_btn: Download csv: domain_name: Domain @@ -15,8 +16,12 @@ en: flags: Flags alg: Algorithm + general: + registrant: Registrant + partials: general: + registrant: Registrant registered: Registered created: Created updated: Updated diff --git a/config/secrets-example.yml b/config/secrets-example.yml deleted file mode 100644 index d5a826251..000000000 --- a/config/secrets-example.yml +++ /dev/null @@ -1,14 +0,0 @@ -development: - secret_key_base: generate-your-secret-key-by-rake-secret - -test: - secret_key_base: generate-your-secret-key-by-rake-secret - -alpha: - secret_key_base: generate-your-secret-key-by-rake-secret - -staging: - secret_key_base: generate-your-secret-key-by-rake-secret - -production: - secret_key_base: generate-your-secret-key-by-rake-secret diff --git a/db/migrate/20170509215614_remove_addresses_with_versions.rb b/db/migrate/20170509215614_remove_addresses_with_versions.rb new file mode 100644 index 000000000..8b0dd9f9d --- /dev/null +++ b/db/migrate/20170509215614_remove_addresses_with_versions.rb @@ -0,0 +1,6 @@ +class RemoveAddressesWithVersions < ActiveRecord::Migration + def change + drop_table :addresses + drop_table :log_addresses + end +end diff --git a/db/migrate/20170606133501_add_foreign_key_constraints_to_domains.rb b/db/migrate/20170606133501_add_foreign_key_constraints_to_domains.rb new file mode 100644 index 000000000..5494d77ab --- /dev/null +++ b/db/migrate/20170606133501_add_foreign_key_constraints_to_domains.rb @@ -0,0 +1,6 @@ +class AddForeignKeyConstraintsToDomains < ActiveRecord::Migration + def change + add_foreign_key :domains, :registrars, name: 'domains_registrar_id_fk' + add_foreign_key :domains, :contacts, column: :registrant_id, name: 'domains_registrant_id_fk' + end +end diff --git a/db/migrate/20170606150352_change_domain_registrar_and_registrant_to_not_null.rb b/db/migrate/20170606150352_change_domain_registrar_and_registrant_to_not_null.rb new file mode 100644 index 000000000..d2cdfa114 --- /dev/null +++ b/db/migrate/20170606150352_change_domain_registrar_and_registrant_to_not_null.rb @@ -0,0 +1,6 @@ +class ChangeDomainRegistrarAndRegistrantToNotNull < ActiveRecord::Migration + def change + change_column :domains, :registrar_id, :integer, null: false + change_column :domains, :registrant_id, :integer, null: false + end +end diff --git a/db/migrate/20170606202859_improve_contact_registrar_id.rb b/db/migrate/20170606202859_improve_contact_registrar_id.rb new file mode 100644 index 000000000..fb5fc562e --- /dev/null +++ b/db/migrate/20170606202859_improve_contact_registrar_id.rb @@ -0,0 +1,6 @@ +class ImproveContactRegistrarId < ActiveRecord::Migration + def change + add_foreign_key :contacts, :registrars, name: 'contacts_registrar_id_fk' + change_column :contacts, :registrar_id, :integer, null: false + end +end diff --git a/db/structure.sql b/db/structure.sql index 2b4890030..e01885fa8 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -357,47 +357,6 @@ CREATE SEQUENCE accounts_id_seq ALTER SEQUENCE accounts_id_seq OWNED BY accounts.id; --- --- Name: addresses; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE addresses ( - id integer NOT NULL, - contact_id integer, - city character varying, - street character varying, - zip character varying, - created_at timestamp without time zone, - updated_at timestamp without time zone, - street2 character varying, - street3 character varying, - creator_str character varying, - updator_str character varying, - country_code character varying, - state character varying, - legacy_contact_id integer -); - - --- --- Name: addresses_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE addresses_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: addresses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE addresses_id_seq OWNED BY addresses.id; - - -- -- Name: api_users; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -734,7 +693,7 @@ CREATE TABLE contacts ( auth_info character varying, name character varying, org_name character varying, - registrar_id integer, + registrar_id integer NOT NULL, creator_str character varying, updator_str character varying, ident_country_code character varying, @@ -1074,12 +1033,12 @@ ALTER SEQUENCE domain_transfers_id_seq OWNED BY domain_transfers.id; CREATE TABLE domains ( id integer NOT NULL, name character varying, - registrar_id integer, + registrar_id integer NOT NULL, registered_at timestamp without time zone, status character varying, valid_from timestamp without time zone, valid_to timestamp without time zone, - registrant_id integer, + registrant_id integer NOT NULL, auth_info character varying, created_at timestamp without time zone, updated_at timestamp without time zone, @@ -1421,44 +1380,6 @@ CREATE SEQUENCE log_accounts_id_seq ALTER SEQUENCE log_accounts_id_seq OWNED BY log_accounts.id; --- --- Name: log_addresses; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE log_addresses ( - 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_addresses_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE log_addresses_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: log_addresses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE log_addresses_id_seq OWNED BY log_addresses.id; - - -- -- Name: log_api_users; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -2985,13 +2906,6 @@ ALTER TABLE ONLY account_activities ALTER COLUMN id SET DEFAULT nextval('account ALTER TABLE ONLY accounts ALTER COLUMN id SET DEFAULT nextval('accounts_id_seq'::regclass); --- --- Name: id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY addresses ALTER COLUMN id SET DEFAULT nextval('addresses_id_seq'::regclass); - - -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3167,13 +3081,6 @@ ALTER TABLE ONLY log_account_activities ALTER COLUMN id SET DEFAULT nextval('log ALTER TABLE ONLY log_accounts ALTER COLUMN id SET DEFAULT nextval('log_accounts_id_seq'::regclass); --- --- Name: id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY log_addresses ALTER COLUMN id SET DEFAULT nextval('log_addresses_id_seq'::regclass); - - -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3463,14 +3370,6 @@ ALTER TABLE ONLY accounts ADD CONSTRAINT accounts_pkey PRIMARY KEY (id); --- --- Name: addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: --- - -ALTER TABLE ONLY addresses - ADD CONSTRAINT addresses_pkey PRIMARY KEY (id); - - -- -- Name: api_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -3671,14 +3570,6 @@ ALTER TABLE ONLY log_accounts ADD CONSTRAINT log_accounts_pkey PRIMARY KEY (id); --- --- Name: log_addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: --- - -ALTER TABLE ONLY log_addresses - ADD CONSTRAINT log_addresses_pkey PRIMARY KEY (id); - - -- -- Name: log_api_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -4307,20 +4198,6 @@ CREATE INDEX index_log_accounts_on_item_type_and_item_id ON log_accounts USING b CREATE INDEX index_log_accounts_on_whodunnit ON log_accounts USING btree (whodunnit); --- --- Name: index_log_addresses_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_addresses_on_item_type_and_item_id ON log_addresses USING btree (item_type, item_id); - - --- --- Name: index_log_addresses_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_addresses_on_whodunnit ON log_addresses USING btree (whodunnit); - - -- -- Name: index_log_api_users_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4769,6 +4646,30 @@ CREATE UNIQUE INDEX unique_data_migrations ON data_migrations USING btree (versi CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version); +-- +-- Name: contacts_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY contacts + ADD CONSTRAINT contacts_registrar_id_fk FOREIGN KEY (registrar_id) REFERENCES registrars(id); + + +-- +-- Name: domains_registrant_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY domains + ADD CONSTRAINT domains_registrant_id_fk FOREIGN KEY (registrant_id) REFERENCES contacts(id); + + +-- +-- Name: domains_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY domains + ADD CONSTRAINT domains_registrar_id_fk FOREIGN KEY (registrar_id) REFERENCES registrars(id); + + -- -- Name: fk_rails_78c376257f; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -5257,3 +5158,11 @@ INSERT INTO schema_migrations (version) VALUES ('20170423225333'); INSERT INTO schema_migrations (version) VALUES ('20170424115801'); +INSERT INTO schema_migrations (version) VALUES ('20170509215614'); + +INSERT INTO schema_migrations (version) VALUES ('20170606133501'); + +INSERT INTO schema_migrations (version) VALUES ('20170606150352'); + +INSERT INTO schema_migrations (version) VALUES ('20170606202859'); + diff --git a/doc/models_brief.svg b/doc/models_brief.svg index e7e51b56d..a99210ea9 100644 --- a/doc/models_brief.svg +++ b/doc/models_brief.svg @@ -216,17 +216,6 @@ - -AddressVersion - -AddressVersion - - -AddressVersion->VersionAssociation - - - - BankStatementVersion @@ -1442,18 +1431,6 @@ versions - -Address - -Address - - -Address->AddressVersion - - - -versions - LegalDocument->LegalDocumentVersion diff --git a/doc/models_complete.svg b/doc/models_complete.svg index d7150a9e8..8a1d39a65 100644 --- a/doc/models_complete.svg +++ b/doc/models_complete.svg @@ -423,28 +423,6 @@ - -AddressVersion - -AddressVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -AddressVersion->VersionAssociation - - - - BankStatementVersion @@ -2276,33 +2254,6 @@ versions - -Address - -Address - -id :integer -contact_id :integer -city :string -street :string -zip :string -created_at :datetime -updated_at :datetime -street2 :string -street3 :string -creator_str :string -updator_str :string -country_code :string -state :string -legacy_contact_id :integer - - -Address->AddressVersion - - - -versions - LegalDocument->LegalDocumentVersion diff --git a/spec/fabricators/address_fabricator.rb b/spec/fabricators/address_fabricator.rb deleted file mode 100644 index ecdb50f58..000000000 --- a/spec/fabricators/address_fabricator.rb +++ /dev/null @@ -1,6 +0,0 @@ -Fabricator(:address) do - city 'test city' - street 'test street' - street2 'test street' - zip 12345 -end diff --git a/spec/jobs/domain_update_confirm_job_spec.rb b/spec/jobs/domain_update_confirm_job_spec.rb new file mode 100644 index 000000000..4748ca021 --- /dev/null +++ b/spec/jobs/domain_update_confirm_job_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe DomainUpdateConfirmJob do + let(:domain) { instance_spy(Epp::Domain, registrant: registrant, errors: []) } + let(:registrant) { instance_double(Registrant) } + let(:registrant_change) { instance_spy(RegistrantChange) } + + it 'confirms registrant change' do + expect(Epp::Domain).to receive(:find).and_return(domain) + expect(RegistrantChange).to receive(:new) + .with(domain: domain, old_registrant: registrant) + .and_return(registrant_change) + + described_class.enqueue(domain_id = nil, action = RegistrantVerification::CONFIRMED) + + expect(registrant_change).to have_received(:confirm) + end +end diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb deleted file mode 100644 index e05c5ad38..000000000 --- a/spec/mailers/domain_mailer_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'rails_helper' - -RSpec.describe DomainMailer do - describe '#registrant_updated_notification_for_new_registrant', db: true do - subject(:message) { described_class.registrant_updated_notification_for_new_registrant(55, 55, 55, true) } - - context 'when contact address processing is enabled' do - before :example do - allow(Contact).to receive(:address_processing?).and_return(true) - create(:domain, id: 55) - create(:registrant_with_address, id: 55) - end - - it 'sends message' do - expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1) - end - end - - context 'when contact address processing is disabled' do - before :example do - allow(Contact).to receive(:address_processing?).and_return(false) - create(:domain, id: 55) - create(:registrant_without_address, id: 55) - end - - it 'sends message' do - expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1) - end - end - end - - describe '#registrant_updated_notification_for_old_registrant', db: true do - subject(:message) { described_class.registrant_updated_notification_for_old_registrant(55, 55, 55, true) } - - context 'when contact address processing is enabled' do - before :example do - allow(Contact).to receive(:address_processing?).and_return(true) - create(:domain, id: 55) - create(:registrant_with_address, id: 55) - end - - it 'sends message' do - expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1) - end - end - - context 'when contact address processing is disabled' do - before :example do - allow(Contact).to receive(:address_processing?).and_return(false) - create(:domain, id: 55) - create(:registrant_without_address, id: 55) - end - - it 'sends message' do - expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1) - end - end - end -end diff --git a/spec/mailers/registrant_change_mailer_spec.rb b/spec/mailers/registrant_change_mailer_spec.rb index be1e7d105..e38cde83d 100644 --- a/spec/mailers/registrant_change_mailer_spec.rb +++ b/spec/mailers/registrant_change_mailer_spec.rb @@ -94,6 +94,40 @@ RSpec.describe RegistrantChangeMailer do end end + describe '#confirmed' do + let(:domain) { instance_spy(Domain, registrant_email: 'new.registrant@test.com') } + let(:old_registrant) { instance_spy(Registrant, email: 'old.registrant@test.com') } + let(:registrant_presenter) { instance_spy(RegistrantPresenter) } + let(:domain_presenter) { instance_spy(DomainPresenter) } + subject(:message) { described_class.confirmed(domain: domain, old_registrant: old_registrant) } + + before :example do + allow(RegistrantPresenter).to receive(:new).and_return(registrant_presenter) + allow(DomainPresenter).to receive(:new).and_return(domain_presenter) + end + + it 'has sender' do + expect(message.from).to eq(['noreply@internet.ee']) + end + + it 'has new registrant email as a recipient' do + expect(message.to).to include('new.registrant@test.com') + end + + it 'has old registrant email as a recipient' do + expect(message.to).to include('old.registrant@test.com') + end + + it 'has subject' do + allow(domain).to receive(:name).and_return('test.com') + expect(message.subject).to eq(t('registrant_change_mailer.confirmed.subject', domain_name: 'test.com')) + 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) } diff --git a/spec/models/address_spec.rb b/spec/models/address_spec.rb deleted file mode 100644 index fe63fb38f..000000000 --- a/spec/models/address_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'rails_helper' - -describe Address do - context 'about class' do - it 'should have versioning enabled?' do - Address.paper_trail_enabled_for_model?.should == true - end - - it 'should have custom log prexied table name for versions table' do - AddressVersion.table_name.should == 'log_addresses' - end - end - - context 'with invalid attribute' do - before :all do - @address = Address.new - end - - it 'should not be valid' do - @address.valid? - @address.errors.full_messages.should match_array([ - ]) - end - - it 'should not have any versions' do - @address.versions.should == [] - end - end - - context 'with valid attributes' do - before :all do - @address = Fabricate(:address) - end - - it 'should be valid' do - @address.valid? - @address.errors.full_messages.should match_array([]) - end - - it 'should be valid twice' do - @address = Fabricate(:address) - @address.valid? - @address.errors.full_messages.should match_array([]) - end - - it 'should have one version' do - with_versioning do - @address.versions.should == [] - @address.zip = 'New zip' - @address.save - @address.errors.full_messages.should match_array([]) - @address.versions.size.should == 1 - end - end - end -end - -# TODO: country issue -# describe Address, '.extract_params' do - # it 'returns params hash' do - # Fabricate(:country, iso: 'EE') - # ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: 'street1' } } } - # expect(Address.extract_attributes(ph[:postalInfo])).to eq({ - # address_attributes: { - # country_id: Country.find_by(iso: 'EE').id, - # city: 'Village', - # street: 'street1' - # } - # }) - # end -# end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 8c93d3545..c7cd38719 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -354,7 +354,7 @@ describe Contact, '.destroy_orphans' do end end -RSpec.describe Contact, db: false do +RSpec.describe Contact do it { is_expected.to alias_attribute(:kind, :ident_type) } describe '::names' do @@ -400,6 +400,16 @@ RSpec.describe Contact, db: false do end end + describe 'registrar validation', db: false do + let(:contact) { described_class.new } + + it 'rejects absent' do + contact.registrar = nil + contact.validate + expect(contact.errors).to have_key(:registrar) + end + end + describe 'address validation', db: false do let(:contact) { described_class.new } subject(:errors) { contact.errors } @@ -523,4 +533,66 @@ RSpec.describe Contact, db: false do specify { expect(contact.id_code).to be_nil } end end + + describe '#ident_country' do + let(:contact) { described_class.new(ident_country_code: 'US') } + + it 'returns ident country' do + expect(contact.ident_country).to eq(Country.new('US')) + end + end + + describe '#used?' do + context 'when used as registrant' do + let(:registrant) { create(:registrant) } + + before :example do + create(:domain, registrant: registrant) + registrant.reload + end + + specify { expect(registrant).to be_used } + end + + context 'when used as contact' do + let(:contact) { create(:contact) } + + before :example do + domain = create(:domain) + domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact) + contact.reload + end + + specify { expect(contact).to be_used } + end + + context 'when not used' do + let(:contact) { create(:contact) } + specify { expect(contact).to_not be_used } + end + end + + describe '#domain_names_with_roles' do + let(:contact) { create(:registrant) } + subject(:domain_names) { contact.domain_names_with_roles } + + it 'returns associated domains with roles' do + domain = create(:domain, registrant: contact, name: 'test.com') + domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact) + domain.tech_domain_contacts << create(:tech_domain_contact, contact: contact) + + contact.reload + + expect(domain_names).to eq({ 'test.com' => %i[registrant admin_domain_contact tech_domain_contact].to_set }) + end + + it 'returns unique roles' do + domain = create(:domain, name: 'test.com') + 2.times { domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact) } + + contact.reload + + expect(domain_names).to eq({ 'test.com' => %i[admin_domain_contact].to_set }) + end + end end diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 10898793f..9cb27a751 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -33,16 +33,6 @@ RSpec.describe Domain do @domain = Domain.new end - it 'should not be valid' do - @domain.valid? - @domain.errors.full_messages.should match_array([ - "Admin domain contacts Admin contacts count must be between 1-10", - "Period Period is not a number", - "Registrant Registrant is missing", - "Registrar Registrar is missing" - ]) - end - it 'should not have any versions' do @domain.versions.should == [] end @@ -599,10 +589,84 @@ RSpec.describe Domain do end end -RSpec.describe Domain, db: false do +RSpec.describe Domain do it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) } it { is_expected.to alias_attribute(:outzone_time, :outzone_at) } + describe 'registrar validation', db: false do + let(:domain) { described_class.new } + + it 'rejects absent' do + domain.registrar = nil + domain.validate + expect(domain.errors).to have_key(:registrar) + end + end + + describe 'registrant validation', db: false do + let(:domain) { described_class.new } + + it 'rejects absent' do + domain.registrant = nil + domain.validate + expect(domain.errors).to have_key(:registrant) + end + end + + describe 'period validation', db: false do + let(:domain) { described_class.new } + + it 'rejects absent' do + domain.period = nil + domain.validate + expect(domain.errors).to have_key(:period) + end + + it 'rejects fractional' do + domain.period = 1.1 + domain.validate + expect(domain.errors).to have_key(:period) + end + + it 'accepts integer' do + domain.period = 1 + domain.validate + expect(domain.errors).to_not have_key(:period) + end + end + + describe 'admin contact count validation' do + let(:domain) { described_class.new } + + before :example do + Setting.admin_contacts_min_count = 1 + Setting.admin_contacts_max_count = 2 + end + + it 'rejects less than min' do + domain.validate + expect(domain.errors).to have_key(:admin_domain_contacts) + end + + it 'rejects more than max' do + (Setting.admin_contacts_max_count + 1).times { domain.admin_domain_contacts << build(:admin_domain_contact) } + domain.validate + expect(domain.errors).to have_key(:admin_domain_contacts) + end + + it 'accepts min' do + Setting.admin_contacts_min_count.times { domain.admin_domain_contacts << build(:admin_domain_contact) } + domain.validate + expect(domain.errors).to_not have_key(:admin_domain_contacts) + end + + it 'accepts max' do + Setting.admin_contacts_max_count.times { domain.admin_domain_contacts << build(:admin_domain_contact) } + domain.validate + expect(domain.errors).to_not have_key(:admin_domain_contacts) + end + end + describe 'nameserver validation', db: true do let(:domain) { described_class.new } diff --git a/spec/presenters/registrant_presenter_spec.rb b/spec/presenters/registrant_presenter_spec.rb index 73b28986e..f9d112f1a 100644 --- a/spec/presenters/registrant_presenter_spec.rb +++ b/spec/presenters/registrant_presenter_spec.rb @@ -4,29 +4,78 @@ RSpec.describe RegistrantPresenter do let(:registrant) { instance_double(Registrant) } let(:presenter) { described_class.new(registrant: registrant, view: view) } - registrant_delegate_attributes = %i( + describe '#country' do + let(:country) { instance_double(Country) } + + before :example do + allow(registrant).to receive(:country).and_return(country) + end + + it 'returns country name in current locale by default' do + expect(country).to receive(:translation).with(I18n.locale).and_return('test country') + expect(presenter.country).to eq('test country') + end + + it 'returns country name in given locale' do + expect(country).to receive(:translation).with(:de).and_return('test country') + expect(presenter.country(locale: :de)).to eq('test country') + end + end + + describe '#ident_country' do + let(:ident_country) { instance_double(Country) } + + before :example do + allow(registrant).to receive(:ident_country).and_return(ident_country) + end + + it 'returns country name in current locale by default' do + expect(ident_country).to receive(:translation).with(I18n.locale).and_return('test country') + expect(presenter.ident_country).to eq('test country') + end + + it 'returns country name in given locale' do + expect(ident_country).to receive(:translation).with(:de).and_return('test country') + expect(presenter.ident_country(locale: :de)).to eq('test country') + end + end + + describe '#domain_names_with_roles' do + before :example do + roles = %i[registrant admin_domain_contact tech_domain_contact] + allow(registrant).to receive(:domain_names_with_roles) + .and_return({ 'test.com' => roles, + 'test.org' => %i[registrant] }) + end + + it 'returns domain names with unique roles in current locale by default' do + text = "test.com (Registrant, Administrative contact, Technical contact)" \ + "\ntest.org (Registrant)" + expect(presenter.domain_names_with_roles).to eq(text) + end + end + + registrant_delegatable_attributes = %i( name ident + phone email priv? street city + state + zip id_code reg_no + used? ) - 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') + registrant_delegatable_attributes.each do |attr_name| + describe "##{attr_name}" do + it 'delegates to registrant' do + expect(registrant).to receive(attr_name).and_return('test') + expect(presenter.send(attr_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/rails_helper.rb b/spec/rails_helper.rb index 771052f4b..cd242967b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -9,7 +9,6 @@ require 'support/requests/session_helpers' require 'support/requests/epp_helpers' require 'support/features/session_helpers' require 'support/matchers/alias_attribute' -require 'support/matchers/active_job' require 'support/matchers/epp/code' require 'support/capybara' @@ -28,6 +27,7 @@ RSpec.configure do |config| config.include Features::SessionHelpers, type: :feature config.include AbstractController::Translation, type: :request config.include AbstractController::Translation, type: :feature + config.include AbstractController::Translation, type: :mailer config.include Requests::EPPHelpers, type: :request config.define_derived_metadata(file_path: %r[/spec/features/]) do |metadata| diff --git a/spec/services/registrant_change_spec.rb b/spec/services/registrant_change_spec.rb new file mode 100644 index 000000000..fb1762557 --- /dev/null +++ b/spec/services/registrant_change_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe RegistrantChange do + describe '#confirm' do + let(:domain) { instance_double(Domain) } + let(:old_registrant) { instance_double(Registrant) } + let(:message) { instance_spy(ActionMailer::MessageDelivery) } + + before :example do + allow(RegistrantChangeMailer).to receive(:confirmed) + .with(domain: domain, old_registrant: old_registrant) + .and_return(message) + described_class.new(domain: domain, old_registrant: old_registrant).confirm + end + + it 'notifies registrant' do + expect(message).to have_received(:deliver_now) + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e5e131454..03ebbc9b3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,17 +6,7 @@ if ENV['TRAVIS'] SimpleCov.start end - RSpec.configure do |config| - # https://github.com/rspec/rspec-rails/issues/1076 - config.around :each, type: :view do |example| - config.mock_with :rspec do |mocks| - mocks.verify_partial_doubles = false - example.run - mocks.verify_partial_doubles = true - end - end - # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer. diff --git a/spec/support/matchers/active_job.rb b/spec/support/matchers/active_job.rb deleted file mode 100644 index 1a3f70a7a..000000000 --- a/spec/support/matchers/active_job.rb +++ /dev/null @@ -1,252 +0,0 @@ -require "active_job/base" -require "active_job/arguments" - -# This matcher is needed because it is absent it rspec-rails 3.3.2 - -module RSpec - module Rails - module Matchers - # Namespace for various implementations of ActiveJob features - # - # @api private - module ActiveJob - # rubocop: disable Style/ClassLength - # @private - class Base < RSpec::Matchers::BuiltIn::BaseMatcher - def initialize - @args = [] - @queue = nil - @at = nil - @block = Proc.new {} - set_expected_number(:exactly, 1) - end - - def with(*args, &block) - @args = args - @block = block if block.present? - self - end - - def on_queue(queue) - @queue = queue - self - end - - def at(date) - @at = date - self - end - - def exactly(count) - set_expected_number(:exactly, count) - self - end - - def at_least(count) - set_expected_number(:at_least, count) - self - end - - def at_most(count) - set_expected_number(:at_most, count) - self - end - - def times - self - end - - def once - exactly(:once) - end - - def twice - exactly(:twice) - end - - def thrice - exactly(:thrice) - end - - def failure_message - "expected to enqueue #{base_message}" - end - - def failure_message_when_negated - "expected not to enqueue #{base_message}" - end - - def message_expectation_modifier - case @expectation_type - when :exactly then "exactly" - when :at_most then "at most" - when :at_least then "at least" - end - end - - def supports_block_expectations? - true - end - - private - - def check(jobs) - @matching_jobs_count = jobs.count do |job| - if serialized_attributes.all? { |key, value| value == job[key] } - args = ::ActiveJob::Arguments.deserialize(job[:args]) - @block.call(*args) - true - else - false - end - end - - case @expectation_type - when :exactly then @expected_number == @matching_jobs_count - when :at_most then @expected_number >= @matching_jobs_count - when :at_least then @expected_number <= @matching_jobs_count - end - end - - def base_message - "#{message_expectation_modifier} #{@expected_number} jobs,".tap do |msg| - msg << " with #{@args}," if @args.any? - msg << " on queue #{@queue}," if @queue - msg << " at #{@at}," if @at - msg << " but enqueued #{@matching_jobs_count}" - end - end - - def serialized_attributes - {}.tap do |attributes| - attributes[:args] = ::ActiveJob::Arguments.serialize(@args) if @args.any? - attributes[:at] = @at.to_f if @at - attributes[:queue] = @queue if @queue - attributes[:job] = @job if @job - end - end - - def set_expected_number(relativity, count) - @expectation_type = relativity - @expected_number = case count - when :once then 1 - when :twice then 2 - when :thrice then 3 - else Integer(count) - end - end - - def queue_adapter - ::ActiveJob::Base.queue_adapter - end - end - # rubocop: enable Style/ClassLength - - # @private - class HaveEnqueuedJob < Base - def initialize(job) - super() - @job = job - end - - def matches?(proc) - raise ArgumentError, "have_enqueued_job and enqueue_job only support block expectations" unless Proc === proc - - original_enqueued_jobs_count = queue_adapter.enqueued_jobs.count - proc.call - in_block_jobs = queue_adapter.enqueued_jobs.drop(original_enqueued_jobs_count) - - check(in_block_jobs) - end - end - - # @private - class HaveBeenEnqueued < Base - def matches?(job) - @job = job - check(queue_adapter.enqueued_jobs) - end - end - end - - # @api public - # Passes if a job has been enqueued inside block. May chain at_least, at_most or exactly to specify a number of times. - # - # @example - # expect { - # HeavyLiftingJob.perform_later - # }.to have_enqueued_job - # - # # Using alias - # expect { - # HeavyLiftingJob.perform_later - # }.to enqueue_job - # - # expect { - # HelloJob.perform_later - # HeavyLiftingJob.perform_later - # }.to have_enqueued_job(HelloJob).exactly(:once) - # - # expect { - # 3.times { HelloJob.perform_later } - # }.to have_enqueued_job(HelloJob).at_least(2).times - # - # expect { - # HelloJob.perform_later - # }.to have_enqueued_job(HelloJob).at_most(:twice) - # - # expect { - # HelloJob.perform_later - # HeavyLiftingJob.perform_later - # }.to have_enqueued_job(HelloJob).and have_enqueued_job(HeavyLiftingJob) - # - # expect { - # HelloJob.set(wait_until: Date.tomorrow.noon, queue: "low").perform_later(42) - # }.to have_enqueued_job.with(42).on_queue("low").at(Date.tomorrow.noon) - def have_enqueued_job(job = nil) - check_active_job_adapter - ActiveJob::HaveEnqueuedJob.new(job) - end - alias_method :enqueue_job, :have_enqueued_job - - # @api public - # Passes if a job has been enqueued. May chain at_least, at_most or exactly to specify a number of times. - # - # @example - # before { ActiveJob::Base.queue_adapter.enqueued_jobs.clear } - # - # HeavyLiftingJob.perform_later - # expect(HeavyLiftingJob).to have_been_enqueued - # - # HelloJob.perform_later - # HeavyLiftingJob.perform_later - # expect(HeavyLiftingJob).to have_been_enqueued.exactly(:once) - # - # 3.times { HelloJob.perform_later } - # expect(HelloJob).to have_been_enqueued.at_least(2).times - # - # HelloJob.perform_later - # expect(HelloJob).to enqueue_job(HelloJob).at_most(:twice) - # - # HelloJob.perform_later - # HeavyLiftingJob.perform_later - # expect(HelloJob).to have_been_enqueued - # expect(HeavyLiftingJob).to have_been_enqueued - # - # HelloJob.set(wait_until: Date.tomorrow.noon, queue: "low").perform_later(42) - # expect(HelloJob).to have_been_enqueued.with(42).on_queue("low").at(Date.tomorrow.noon) - def have_been_enqueued - check_active_job_adapter - ActiveJob::HaveBeenEnqueued.new - end - - private - - # @private - def check_active_job_adapter - return if ::ActiveJob::QueueAdapters::TestAdapter === ::ActiveJob::Base.queue_adapter - raise StandardError, "To use ActiveJob matchers set `ActiveJob::Base.queue_adapter = :test`" - end - end - end -end diff --git a/spec/views/admin/billing/prices/_form.html.erb_spec.rb b/spec/views/admin/billing/prices/_form.html.erb_spec.rb index ff7c55dcb..9f4ba785c 100644 --- a/spec/views/admin/billing/prices/_form.html.erb_spec.rb +++ b/spec/views/admin/billing/prices/_form.html.erb_spec.rb @@ -5,10 +5,13 @@ RSpec.describe 'admin/billing/prices/_form' do let(:price) { build_stubbed(:price) } before :example do - allow(view).to receive(:price).and_return(price) - allow(view).to receive(:zones).and_return([]) - allow(view).to receive(:operation_categories).and_return([]) - allow(view).to receive(:durations).and_return([]) + without_partial_double_verification do + allow(view).to receive(:price).and_return(price) + allow(view).to receive(:zones).and_return([]) + allow(view).to receive(:operation_categories).and_return([]) + allow(view).to receive(:durations).and_return([]) + end + stub_template '_form_errors' => '' end diff --git a/spec/views/admin/domains/edit.html.erb_spec.rb b/spec/views/admin/domains/edit.html.erb_spec.rb index b3cc5d834..212b8091b 100644 --- a/spec/views/admin/domains/edit.html.erb_spec.rb +++ b/spec/views/admin/domains/edit.html.erb_spec.rb @@ -6,7 +6,10 @@ RSpec.describe 'admin/domains/edit' do before :example do allow(DomainPresenter).to receive(:new).and_return(domain_presenter) - allow(view).to receive(:force_delete_templates) + + without_partial_double_verification do + allow(view).to receive(:force_delete_templates) + end assign(:domain, domain) diff --git a/spec/views/mailers/contact_mailer/email_updated.html.erb_spec.rb b/spec/views/mailers/contact_mailer/email_updated.html.erb_spec.rb new file mode 100644 index 000000000..47887c30d --- /dev/null +++ b/spec/views/mailers/contact_mailer/email_updated.html.erb_spec.rb @@ -0,0 +1,32 @@ +require 'rails_helper' + +RSpec.describe 'mailers/contact_mailer/email_updated.html.erb' do + let(:contact) { instance_spy(Contact) } + let(:contact_presenter) { instance_spy(RegistrantPresenter) } + let(:registrar_presenter) { instance_spy(RegistrarPresenter) } + + before :example do + allow(RegistrantPresenter).to receive(:new).and_return(contact_presenter) + allow(RegistrarPresenter).to receive(:new).and_return(registrar_presenter) + + assign(:contact, contact) + assign(:old_email, 'test@test.com') + + stub_template 'mailers/shared/registrant/_registrant.et.html' => '' + stub_template 'mailers/shared/registrant/_registrant.en.html' => '' + stub_template 'mailers/shared/registrar/_registrar.et.html' => '' + stub_template 'mailers/shared/registrar/_registrar.en.html' => '' + end + + it 'has affected domain list in estonian' do + expect(contact_presenter).to receive(:domain_names_with_roles).with(locale: :et, line_break: '
').and_return('test domain list et') + render + expect(rendered).to have_text('test domain list et') + end + + it 'has affected domain list in english' do + expect(contact_presenter).to receive(:domain_names_with_roles).with(line_break: '
').and_return('test domain list en') + render + expect(rendered).to have_text('test domain list en') + end +end diff --git a/spec/views/mailers/contact_mailer/email_updated.text.erb_spec.rb b/spec/views/mailers/contact_mailer/email_updated.text.erb_spec.rb new file mode 100644 index 000000000..a74f16b28 --- /dev/null +++ b/spec/views/mailers/contact_mailer/email_updated.text.erb_spec.rb @@ -0,0 +1,32 @@ +require 'rails_helper' + +RSpec.describe 'mailers/contact_mailer/email_updated.text.erb' do + let(:contact) { instance_spy(Contact) } + let(:contact_presenter) { instance_spy(RegistrantPresenter) } + let(:registrar_presenter) { instance_spy(RegistrarPresenter) } + + before :example do + allow(RegistrantPresenter).to receive(:new).and_return(contact_presenter) + allow(RegistrarPresenter).to receive(:new).and_return(registrar_presenter) + + assign(:contact, contact) + assign(:old_email, 'test@test.com') + + stub_template 'mailers/shared/registrant/_registrant.et.text' => '' + stub_template 'mailers/shared/registrant/_registrant.en.text' => '' + stub_template 'mailers/shared/registrar/_registrar.et.text' => '' + stub_template 'mailers/shared/registrar/_registrar.en.text' => '' + end + + it 'has affected domain list in estonian' do + expect(contact_presenter).to receive(:domain_names_with_roles).with(locale: :et).and_return('test domain list et') + render + expect(rendered).to have_text('test domain list et') + end + + it 'has affected domain list in english' do + expect(contact_presenter).to receive(:domain_names_with_roles).and_return('test domain list en') + render + expect(rendered).to have_text('test domain list en') + 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 index a5e0d353b..54f4fef0e 100644 --- a/spec/views/mailers/shared/registrant/_registrant.en.html.erb_spec.rb +++ b/spec/views/mailers/shared/registrant/_registrant.en.html.erb_spec.rb @@ -2,5 +2,5 @@ require 'rails_helper' require_relative 'registrant_shared' RSpec.describe 'mailers/shared/registrant/_registrant.en.html.erb' do - include_examples 'domain mailer registrant info' + include_examples 'domain mailer registrant info', 'mailers/shared/registrant/_registrant.en.html.erb' 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 index fcfb85657..a66967bb7 100644 --- a/spec/views/mailers/shared/registrant/_registrant.en.text.erb_spec.rb +++ b/spec/views/mailers/shared/registrant/_registrant.en.text.erb_spec.rb @@ -2,5 +2,5 @@ require 'rails_helper' require_relative 'registrant_shared' RSpec.describe 'mailers/shared/registrant/_registrant.en.text.erb' do - include_examples 'domain mailer registrant info' + include_examples 'domain mailer registrant info', 'mailers/shared/registrant/_registrant.en.text.erb' 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 index ec4d134a8..f06c43ac3 100644 --- a/spec/views/mailers/shared/registrant/_registrant.et.html.erb_spec.rb +++ b/spec/views/mailers/shared/registrant/_registrant.et.html.erb_spec.rb @@ -2,5 +2,5 @@ require 'rails_helper' require_relative 'registrant_shared' RSpec.describe 'mailers/shared/registrant/_registrant.et.html.erb' do - include_examples 'domain mailer registrant info' + include_examples 'domain mailer registrant info', 'mailers/shared/registrant/_registrant.et.html.erb' 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 index 41b4c52eb..909c6f6be 100644 --- a/spec/views/mailers/shared/registrant/_registrant.et.text.erb_spec.rb +++ b/spec/views/mailers/shared/registrant/_registrant.et.text.erb_spec.rb @@ -2,5 +2,5 @@ require 'rails_helper' require_relative 'registrant_shared' RSpec.describe 'mailers/shared/registrant/_registrant.et.text.erb' do - include_examples 'domain mailer registrant info' + include_examples 'domain mailer registrant info', 'mailers/shared/registrant/_registrant.et.text.erb' end diff --git a/spec/views/mailers/shared/registrant/registrant_shared.rb b/spec/views/mailers/shared/registrant/registrant_shared.rb index 07fcc3b1e..ff90ceb7e 100644 --- a/spec/views/mailers/shared/registrant/registrant_shared.rb +++ b/spec/views/mailers/shared/registrant/registrant_shared.rb @@ -1,25 +1,87 @@ require 'rails_helper' -RSpec.shared_examples 'domain mailer registrant info' do +RSpec.shared_examples 'domain mailer registrant info' do |template_path| + let(:template_path) { template_path } let(:registrant) { instance_spy(RegistrantPresenter) } before :example do - allow(view).to receive(:registrant).and_return(registrant) + without_partial_double_verification do + allow(view).to receive(:registrant).and_return(registrant) + allow(view).to receive(:address_processing) + end end - attributes = %i( - name - ident - street - city - country - ) + it 'has name' do + allow(registrant).to receive(:name).and_return('test name') + render template: template_path + expect(rendered).to have_text('test name') + end - 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}") + it 'has ident' do + allow(registrant).to receive(:ident).and_return('test ident') + render template: template_path + expect(rendered).to have_text('test ident') + end + + context 'when :with_phone is true' do + it 'has phone' do + allow(registrant).to receive(:phone).and_return('test phone') + render template: template_path, locals: { with_phone: true } + expect(rendered).to have_text('test phone') + end + end + + context 'when :with_phone is false' do + it 'has no phone' do + allow(registrant).to receive(:phone).and_return('test phone') + render template: template_path, locals: { with_phone: false } + expect(rendered).to_not have_text('test phone') + end + end + + address_attributes = %i[street city state zip country] + + context 'when address processing is enabled' do + before :example do + without_partial_double_verification do + allow(view).to receive(:address_processing).and_return(true) + end + end + + address_attributes.each do |attr_name| + it "has #{attr_name}" do + allow(registrant).to receive(attr_name).and_return("test #{attr_name}") + render template: template_path + expect(rendered).to have_text("test #{attr_name}") + end + end + + it 'has no ident country' do + allow(registrant).to receive(:ident_country).and_return('test ident country') + render template: template_path + expect(rendered).to_not have_text('test ident country') + end + end + + context 'when address processing is disabled' do + before :example do + without_partial_double_verification do + allow(view).to receive(:address_processing).and_return(false) + end + end + + address_attributes.each do |attr_name| + it "has no #{attr_name}" do + allow(registrant).to receive(attr_name).and_return("test #{attr_name}") + render template: template_path + expect(rendered).to_not have_text("test #{attr_name}") + end + end + + it 'has ident country' do + allow(registrant).to receive(:ident_country).and_return('test ident country') + render template: template_path + expect(rendered).to have_text('test ident country') end end end diff --git a/spec/views/mailers/shared/registrar/registrar_shared.rb b/spec/views/mailers/shared/registrar/registrar_shared.rb index 2f8311545..93f228f97 100644 --- a/spec/views/mailers/shared/registrar/registrar_shared.rb +++ b/spec/views/mailers/shared/registrar/registrar_shared.rb @@ -4,7 +4,9 @@ RSpec.shared_examples 'domain mailer registrar info' do let(:registrar) { instance_spy(RegistrarPresenter) } before :example do - allow(view).to receive(:registrar).and_return(registrar) + without_partial_double_verification do + allow(view).to receive(:registrar).and_return(registrar) + end end attributes = %i( diff --git a/spec/views/registrar/contacts/_form.haml_spec.rb b/spec/views/registrar/contacts/_form.haml_spec.rb index b1ecdf0cf..c1588f0ec 100644 --- a/spec/views/registrar/contacts/_form.haml_spec.rb +++ b/spec/views/registrar/contacts/_form.haml_spec.rb @@ -4,7 +4,10 @@ RSpec.describe 'registrar/contacts/_form' do let(:contact) { instance_spy(Depp::Contact) } before :example do - allow(view).to receive(:f).and_return(ActionView::Helpers::FormBuilder.new(:contact, contact, view, {})) + without_partial_double_verification do + allow(view).to receive(:f).and_return(ActionView::Helpers::FormBuilder.new(:contact, contact, view, {})) + end + assign(:contact, contact) stub_template 'registrar/shared/_error_messages' => '' @@ -16,7 +19,9 @@ RSpec.describe 'registrar/contacts/_form' do context 'when address processing is enabled' do before do - allow(view).to receive(:address_processing?).and_return(true) + without_partial_double_verification do + allow(view).to receive(:address_processing?).and_return(true) + end end it 'has address' do @@ -27,7 +32,9 @@ RSpec.describe 'registrar/contacts/_form' do context 'when address processing is disabled' do before do - allow(view).to receive(:address_processing?).and_return(false) + without_partial_double_verification do + allow(view).to receive(:address_processing?).and_return(false) + end end it 'has no address' do diff --git a/spec/views/registrar/contacts/form/_legal_document.haml_spec.rb b/spec/views/registrar/contacts/form/_legal_document.haml_spec.rb index b5f428ca1..55ac79e9e 100644 --- a/spec/views/registrar/contacts/form/_legal_document.haml_spec.rb +++ b/spec/views/registrar/contacts/form/_legal_document.haml_spec.rb @@ -4,7 +4,10 @@ RSpec.describe 'registrar/contacts/form/_legal_document' do let(:contact) { instance_spy(Depp::Contact) } before :example do - allow(view).to receive(:f).and_return(DefaultFormBuilder.new(:depp_contact, contact, view, {})) + without_partial_double_verification do + allow(view).to receive(:f).and_return(DefaultFormBuilder.new(:depp_contact, contact, view, {})) + end + assign(:contact, contact) end diff --git a/spec/views/registrar/domains/_form.haml_spec.rb b/spec/views/registrar/domains/_form.haml_spec.rb index b7833f92a..f0e646fb8 100644 --- a/spec/views/registrar/domains/_form.haml_spec.rb +++ b/spec/views/registrar/domains/_form.haml_spec.rb @@ -4,7 +4,10 @@ RSpec.describe 'registrar/domains/_form' do let(:domain) { instance_spy(Depp::Domain) } before :example do - allow(view).to receive(:f).and_return(DefaultFormBuilder.new(:domain, domain, view, {})) + without_partial_double_verification do + allow(view).to receive(:f).and_return(DefaultFormBuilder.new(:domain, domain, view, {})) + end + assign(:domain, domain) stub_template 'registrar/domains/form/_general' => ''