From ca033c22b8892ac1d636260d1917f43231116eaf Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 30 Apr 2015 11:45:50 +0300 Subject: [PATCH 1/5] Silence invoice pdf tests --- .../registrar/invoices_controller.rb | 10 +++---- app/models/invoice.rb | 30 +++++++++---------- .../invoice_mailer/invoice_email.text.erb | 4 +-- config/initializers/pdfkit.rb | 3 +- db/schema.rb | 4 +++ spec/models/invoice_spec.rb | 24 +++++++-------- 6 files changed, 39 insertions(+), 36 deletions(-) diff --git a/app/controllers/registrar/invoices_controller.rb b/app/controllers/registrar/invoices_controller.rb index 8d0a06831..3d8de5048 100644 --- a/app/controllers/registrar/invoices_controller.rb +++ b/app/controllers/registrar/invoices_controller.rb @@ -22,26 +22,24 @@ class Registrar::InvoicesController < RegistrarController @invoice.billing_email = params[:invoice][:billing_email] if @invoice.forward(render_to_string('pdf', layout: false)) - flash[:notice] = t('invoice_forwared') + flash[:notice] = t(:invoice_forwared) redirect_to([:registrar, @invoice]) else - flash.now[:alert] = t('failed_to_forward_invoice') + flash.now[:alert] = t(:failed_to_forward_invoice) end end def cancel if @invoice.cancel - flash[:notice] = t('record_updated') + flash[:notice] = t(:record_updated) redirect_to([:registrar, @invoice]) else - flash.now[:alert] = t('failed_to_update_record') + flash.now[:alert] = t(:failed_to_update_record) render :show end end def download_pdf - # render 'pdf', layout: false - pdf = @invoice.pdf(render_to_string('pdf', layout: false)) send_data pdf, filename: @invoice.pdf_name end diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 372d67a8c..aa5a8c430 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -34,6 +34,21 @@ class Invoice < ActiveRecord::Base before_save -> { self.sum_cache = sum } + class << self + def cancel_overdue_invoices + logger.info "#{Time.zone.now.utc} - Cancelling overdue invoices\n" + + cr_at = Time.zone.now - Setting.days_to_keep_overdue_invoices_active.days + invoices = Invoice.unbinded.where( + 'due_date < ? AND created_at < ? AND cancelled_at IS NULL', Time.zone.now, cr_at + ) + + count = invoices.update_all(cancelled_at: Time.zone.now) + + logger.info "#{Time.zone.now.utc} - Successfully cancelled #{count} overdue invoices\n" + end + end + def binded? account_activity.present? end @@ -113,19 +128,4 @@ class Invoice < ActiveRecord::Base def sum sum_without_vat + vat end - - class << self - def cancel_overdue_invoices - STDOUT << "#{Time.zone.now.utc} - Cancelling overdue invoices\n" - - cr_at = Time.zone.now - Setting.days_to_keep_overdue_invoices_active.days - invoices = Invoice.unbinded.where( - 'due_date < ? AND created_at < ? AND cancelled_at IS NULL', Time.zone.now, cr_at - ) - - count = invoices.update_all(cancelled_at: Time.zone.now) - - STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} overdue invoices\n" - end - end end diff --git a/app/views/invoice_mailer/invoice_email.text.erb b/app/views/invoice_mailer/invoice_email.text.erb index 2cf1d1197..ae65fd7da 100644 --- a/app/views/invoice_mailer/invoice_email.text.erb +++ b/app/views/invoice_mailer/invoice_email.text.erb @@ -1,5 +1,5 @@ -<%= t('you_have_a_new_invoice') %> +<%= t(:you_have_a_new_invoice) %> -<%= t('sincerely') %>, +<%= t(:sincerely) %>, <%= Setting.eis_invoice_contact %> <%= @invoice.seller_phone %> diff --git a/config/initializers/pdfkit.rb b/config/initializers/pdfkit.rb index 6c9559d98..b38887c6e 100644 --- a/config/initializers/pdfkit.rb +++ b/config/initializers/pdfkit.rb @@ -1,7 +1,8 @@ PDFKit.configure do |config| config.wkhtmltopdf = "#{Rails.root}/vendor/bin/wkhtmltopdf" config.default_options = { - page_size: 'A4' + page_size: 'A4', + quiet: true # :print_media_type => true } end diff --git a/db/schema.rb b/db/schema.rb index 491b5d633..d30dece39 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -297,8 +297,12 @@ ActiveRecord::Schema.define(version: 20150429135339) do t.integer "legacy_id" t.integer "legacy_registrar_id" t.integer "legacy_registrant_id" + t.datetime "outzone_at" + t.datetime "delete_at" end + add_index "domains", ["delete_at"], name: "index_domains_on_delete_at", using: :btree + add_index "domains", ["outzone_at"], name: "index_domains_on_outzone_at", using: :btree add_index "domains", ["registrant_id"], name: "index_domains_on_registrant_id", using: :btree add_index "domains", ["registrar_id"], name: "index_domains_on_registrar_id", using: :btree diff --git a/spec/models/invoice_spec.rb b/spec/models/invoice_spec.rb index 4ec594640..54a640d2d 100644 --- a/spec/models/invoice_spec.rb +++ b/spec/models/invoice_spec.rb @@ -24,9 +24,9 @@ describe Invoice do ]) end - # it 'should not have any versions' do - # @invoice.versions.should == [] - # end + it 'should not have any versions' do + @invoice.versions.should == [] + end end context 'with valid attributes' do @@ -76,14 +76,14 @@ describe Invoice do Invoice.where(cancelled_at: nil).count.should == 1 end - # it 'should have one version' do - # with_versioning do - # @invoice.versions.should == [] - # @invoice.body = 'New body' - # @invoice.save - # @invoice.errors.full_messages.should match_array([]) - # @invoice.versions.size.should == 1 - # end - # end + it 'should have one version' do + with_versioning do + @invoice.versions.should == [] + @invoice.buyer_name = 'New name' + @invoice.save + @invoice.errors.full_messages.should match_array([]) + @invoice.versions.size.should == 1 + end + end end end From 3962eda53913cccbf555498aa5123247caacbee8 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 30 Apr 2015 12:47:11 +0300 Subject: [PATCH 2/5] Update translation keys --- app/controllers/admin/invoices_controller.rb | 4 +- app/controllers/epp/errors_controller.rb | 2 +- .../registrar/deposits_controller.rb | 4 +- .../registrar/domains_controller.rb | 2 +- .../registrar/nameservers_controller.rb | 6 +- .../registrar/sessions_controller.rb | 26 ++++----- app/views/admin/bank_statements/index.haml | 4 +- app/views/admin/bank_transactions/edit.haml | 6 +- app/views/admin/bank_transactions/show.haml | 32 +++++----- app/views/admin/certificates/show.haml | 32 +++++----- .../admin/contacts/partials/_domains.haml | 8 +-- app/views/admin/domain_versions/oldindex.haml | 4 +- app/views/admin/domains/_form.haml | 2 +- .../domains/form_partials/_statuses.haml | 6 +- .../admin/domains/partials/_dnskeys.haml | 10 ++-- .../admin/domains/partials/_general.haml | 14 ++--- .../admin/domains/partials/_keyrelays.haml | 12 ++-- .../domains/partials/_legal_documents.haml | 6 +- .../admin/domains/partials/_nameservers.haml | 8 +-- .../admin/domains/partials/_statuses.haml | 6 +- .../domains/partials/_tech_contacts.haml | 8 +-- app/views/admin/invoices/index.haml | 8 +-- app/views/admin/invoices/show.haml | 2 +- app/views/admin/registrars/_form.haml | 2 +- app/views/admin/registrars/show.haml | 2 +- .../invoice_mailer/invoice_email.html.erb | 4 +- .../contacts/form_partials/_disclose.haml | 16 ++--- app/views/registrar/contacts/info_index.haml | 4 +- app/views/registrar/domains/_check_form.haml | 2 +- app/views/registrar/domains/_form.haml | 2 +- app/views/registrar/domains/check.haml | 8 +-- app/views/registrar/domains/delete.haml | 4 +- app/views/registrar/domains/index.haml | 2 +- .../registrar/domains/partials/_contacts.haml | 4 +- .../registrar/domains/partials/_dnskeys.haml | 18 +++--- .../domains/partials/_nameservers.haml | 6 +- .../registrar/domains/partials/_statuses.haml | 4 +- app/views/registrar/domains/renew_index.haml | 2 +- app/views/registrar/domains/transfer.haml | 4 +- app/views/registrar/invoices/index.haml | 2 +- .../invoices/partials/_banklinks.haml | 2 +- .../registrar/invoices/partials/_buyer.haml | 16 ++--- .../registrar/invoices/partials/_details.haml | 22 +++---- .../registrar/invoices/partials/_items.haml | 16 ++--- .../registrar/invoices/partials/_seller.haml | 26 ++++----- .../registrar/invoices/partials/_total.haml | 12 ++-- app/views/registrar/invoices/pdf.haml | 58 +++++++++---------- app/views/registrar/nameservers/index.haml | 2 +- app/views/registrar/polls/show.haml | 28 ++++----- 49 files changed, 240 insertions(+), 240 deletions(-) diff --git a/app/controllers/admin/invoices_controller.rb b/app/controllers/admin/invoices_controller.rb index d2f9db426..fdbe80070 100644 --- a/app/controllers/admin/invoices_controller.rb +++ b/app/controllers/admin/invoices_controller.rb @@ -13,10 +13,10 @@ class Admin::InvoicesController < AdminController def cancel if @invoice.cancel - flash[:notice] = t('record_updated') + flash[:notice] = t(:record_updated) redirect_to([:admin, @invoice]) else - flash.now[:alert] = t('failed_to_update_record') + flash.now[:alert] = t(:failed_to_update_record) render :show end end diff --git a/app/controllers/epp/errors_controller.rb b/app/controllers/epp/errors_controller.rb index cefa026a0..cba923bc9 100644 --- a/app/controllers/epp/errors_controller.rb +++ b/app/controllers/epp/errors_controller.rb @@ -7,7 +7,7 @@ class Epp::ErrorsController < EppController end def not_found - epp_errors << { code: 2400, msg: t('could_not_determine_object_type_check_xml_format_and_namespaces') } + epp_errors << { code: 2400, msg: t(:could_not_determine_object_type_check_xml_format_and_namespaces) } render_epp_response '/epp/error' end end diff --git a/app/controllers/registrar/deposits_controller.rb b/app/controllers/registrar/deposits_controller.rb index 1f1bafd00..6f1dfff13 100644 --- a/app/controllers/registrar/deposits_controller.rb +++ b/app/controllers/registrar/deposits_controller.rb @@ -10,10 +10,10 @@ class Registrar::DepositsController < RegistrarController @invoice = @deposit.issue_prepayment_invoice if @invoice.persisted? - flash[:notice] = t('please_pay_the_following_invoice') + flash[:notice] = t(:please_pay_the_following_invoice) redirect_to [:registrar, @invoice] else - flash[:alert] = t('failed_to_create_record') + flash[:alert] = t(:failed_to_create_record) render 'new' end end diff --git a/app/controllers/registrar/domains_controller.rb b/app/controllers/registrar/domains_controller.rb index df616cc16..5a62c5ad5 100644 --- a/app/controllers/registrar/domains_controller.rb +++ b/app/controllers/registrar/domains_controller.rb @@ -23,7 +23,7 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller if response_ok? render 'info' else - flash[:alert] = t('domain_not_found') + flash[:alert] = t(:domain_not_found) redirect_to registrar_domains_url and return end end diff --git a/app/controllers/registrar/nameservers_controller.rb b/app/controllers/registrar/nameservers_controller.rb index bda879862..68c1dbfee 100644 --- a/app/controllers/registrar/nameservers_controller.rb +++ b/app/controllers/registrar/nameservers_controller.rb @@ -13,13 +13,13 @@ class Registrar::NameserversController < RegistrarController ) if prc == 'replaced_none' - flash.now[:alert] = t('no_hostnames_replaced') + flash.now[:alert] = t(:no_hostnames_replaced) elsif prc == 'replaced_all' params[:q][:hostname_end] = params[:hostname_end_replacement] params[:hostname_end_replacement] = nil - flash.now[:notice] = t('all_hostnames_replaced') + flash.now[:notice] = t(:all_hostnames_replaced) else - flash.now[:warning] = t('hostnames_partially_replaced') + flash.now[:warning] = t(:hostnames_partially_replaced) end end diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index b82fe43bc..4623effd6 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -39,9 +39,9 @@ class Registrar::SessionsController < ::SessionsController if @user.persisted? session[:user_id_code] = response.user_id_code session[:mid_session_code] = client.session_code - render json: { message: t('check_your_phone_for_confirmation_code') }, status: :ok + render json: { message: t(:check_your_phone_for_confirmation_code) }, status: :ok else - render json: { message: t('no_such_user') }, status: :unauthorized + render json: { message: t(:no_such_user) }, status: :unauthorized end end @@ -55,31 +55,31 @@ class Registrar::SessionsController < ::SessionsController case auth_status.status when 'OUTSTANDING_TRANSACTION' - render json: { message: t('check_your_phone_for_confirmation_code') }, status: :ok + render json: { message: t(:check_your_phone_for_confirmation_code) }, status: :ok when 'USER_AUTHENTICATED' @user = find_user_by_idc(session[:user_id_code]) sign_in @user - flash[:notice] = t('welcome') + flash[:notice] = t(:welcome) flash.keep(:notice) render js: "window.location = '#{registrar_root_path}'" when 'NOT_VALID' - render json: { message: t('user_signature_is_invalid') }, status: :bad_request + render json: { message: t(:user_signature_is_invalid) }, status: :bad_request when 'EXPIRED_TRANSACTION' - render json: { message: t('session_timeout') }, status: :bad_request + render json: { message: t(:session_timeout) }, status: :bad_request when 'USER_CANCEL' - render json: { message: t('user_cancelled') }, status: :bad_request + render json: { message: t(:user_cancelled) }, status: :bad_request when 'MID_NOT_READY' - render json: { message: t('mid_not_ready') }, status: :bad_request + render json: { message: t(:mid_not_ready) }, status: :bad_request when 'PHONE_ABSENT' - render json: { message: t('phone_absent') }, status: :bad_request + render json: { message: t(:phone_absent) }, status: :bad_request when 'SENDING_ERROR' - render json: { message: t('sending_error') }, status: :bad_request + render json: { message: t(:sending_error) }, status: :bad_request when 'SIM_ERROR' - render json: { message: t('sim_error') }, status: :bad_request + render json: { message: t(:sim_error) }, status: :bad_request when 'INTERNAL_ERROR' - render json: { message: t('internal_error') }, status: :bad_request + render json: { message: t(:internal_error) }, status: :bad_request else - render json: { message: t('internal_error') }, status: :bad_request + render json: { message: t(:internal_error) }, status: :bad_request end end # rubocop: enable Metrics/PerceivedComplexity diff --git a/app/views/admin/bank_statements/index.haml b/app/views/admin/bank_statements/index.haml index f82783df4..afb3a7be1 100644 --- a/app/views/admin/bank_statements/index.haml +++ b/app/views/admin/bank_statements/index.haml @@ -9,14 +9,14 @@ %thead %tr %th{class: 'col-xs-3'} - = sort_link(@q, 'created_at', t('imported_at')) + = sort_link(@q, 'created_at', t(:imported_at)) %th{class: 'col-xs-3'} = sort_link(@q, 'bank_code') %th{class: 'col-xs-3'} = sort_link(@q, 'iban', t('iban').upcase) / TODO: Make this searchable by caching the status to the database %th{class: 'col-xs-3'} - = t('status') + = t(:status) %tbody - @bank_statements.each do |x| %tr diff --git a/app/views/admin/bank_transactions/edit.haml b/app/views/admin/bank_transactions/edit.haml index 5985f3e3a..5c38ea6e0 100644 --- a/app/views/admin/bank_transactions/edit.haml +++ b/app/views/admin/bank_transactions/edit.haml @@ -1,5 +1,5 @@ - content_for :actions do - = link_to(t('back'), admin_bank_transaction_path(@bank_transaction), class: 'btn btn-default') + = link_to(t(:back), admin_bank_transaction_path(@bank_transaction), class: 'btn btn-default') = render 'shared/title', name: t(:bank_transaction) = form_for([:admin, @bank_transaction], html: { class: 'form-horizontal' }) do |f| @@ -11,7 +11,7 @@ = f.label :status, class: 'col-md-2 control-label' - c = @bank_transaction.binded? ? 'text-success' : 'text-danger' .col-md-10.form-control-static{class: c} - = @bank_transaction.binded? ? t('binded') : t('not_binded') + = @bank_transaction.binded? ? t(:binded) : t(:not_binded) .form-group = f.label :description, class: 'col-md-2 control-label' @@ -71,4 +71,4 @@ %hr .row .col-md-8.text-right - = button_tag(t('save'), class: 'btn btn-primary') + = button_tag(t(:save), class: 'btn btn-primary') diff --git a/app/views/admin/bank_transactions/show.haml b/app/views/admin/bank_transactions/show.haml index 4a325ab53..7bcd8cfa1 100644 --- a/app/views/admin/bank_transactions/show.haml +++ b/app/views/admin/bank_transactions/show.haml @@ -1,5 +1,5 @@ - content_for :actions do - = link_to(t('edit'), edit_admin_bank_transaction_path(@bank_transaction), class: 'btn btn-primary') + = link_to(t(:edit), edit_admin_bank_transaction_path(@bank_transaction), class: 'btn btn-primary') = link_to(t('back_to_bank_statement'), admin_bank_statement_path(@bank_transaction.bank_statement), class: 'btn btn-default') = render 'shared/title', name: t(:bank_transaction) = render 'shared/full_errors', object: @bank_transaction @@ -10,52 +10,52 @@ %h3.panel-title= t(:details) .panel-body %dl.dl-horizontal - %dt= t('document_no') + %dt= t(:document_no) %dd= @bank_transaction.document_no - %dt= t('status') + %dt= t(:status) - c = @bank_transaction.binded? ? 'text-success' : 'text-danger' - %dd{class: c}= @bank_transaction.binded? ? t('binded') : t('not_binded') + %dd{class: c}= @bank_transaction.binded? ? t(:binded) : t(:not_binded) - %dt= t('bank_reference') + %dt= t(:bank_reference) %dd= @bank_transaction.bank_reference %dt= t('iban').upcase %dd= @bank_transaction.iban - %dt= t('buyer_bank_code') + %dt= t(:buyer_bank_code) %dd= @bank_transaction.buyer_bank_code - %dt= t('buyer_iban') + %dt= t(:buyer_iban) %dd= @bank_transaction.buyer_iban - %dt= t('buyer_name') + %dt= t(:buyer_name) %dd= @bank_transaction.buyer_name - %dt= t('description') + %dt= t(:description) %dd= @bank_transaction.description - %dt= t('sum') + %dt= t(:sum) %dd= @bank_transaction.sum - %dt= t('currency') + %dt= t(:currency) %dd= @bank_transaction.currency - %dt= t('reference_no') + %dt= t(:reference_no) %dd= @bank_transaction.reference_no - %dt= t('paid_at') + %dt= t(:paid_at) %dd= l(@bank_transaction.paid_at, format: :date_long) - if @bank_transaction.binded? - %dt= t('binded_invoice') + %dt= t(:binded_invoice) %dd= link_to(@bank_transaction.binded_invoice, admin_invoice_path(@bank_transaction.binded_invoice)) - unless @bank_transaction.binded? = form_for([:admin, @bank_transaction], url: {action: :bind}, html: { class: 'form-inline' }) do |f| .form-group %dl.dl-horizontal - %dt{style: 'padding-top: 5px'}= t('binded_invoice') + %dt{style: 'padding-top: 5px'}= t(:binded_invoice) %dd = text_field_tag(:invoice_no, params[:invoice_no], class: 'form-control') - = button_tag(t('bind_manually'), class: 'btn btn-primary') + = button_tag(t(:bind_manually), class: 'btn btn-primary') diff --git a/app/views/admin/certificates/show.haml b/app/views/admin/certificates/show.haml index e38b634bc..8be28ab8b 100644 --- a/app/views/admin/certificates/show.haml +++ b/app/views/admin/certificates/show.haml @@ -13,21 +13,21 @@ .panel.panel-default .panel-heading.clearfix .pull-left - = t('csr') + = t(:csr) .pull-right - = link_to(t('download'), download_csr_admin_api_user_certificate_path(@api_user, @certificate), class: 'btn btn-default btn-xs') + = link_to(t(:download), download_csr_admin_api_user_certificate_path(@api_user, @certificate), class: 'btn btn-default btn-xs') - unless @crt - = link_to(t('sign_this_request'), sign_admin_api_user_certificate_path(@api_user, @certificate), method: :post, class: 'btn btn-primary btn-xs') + = link_to(t(:sign_this_request), sign_admin_api_user_certificate_path(@api_user, @certificate), method: :post, class: 'btn btn-primary btn-xs') .panel-body %dl.dl-horizontal - %dt= t('version') + %dt= t(:version) %dd= @csr.version - %dt= t('subject') + %dt= t(:subject) %dd= @csr.subject - %dt= t('signature_algorithm') + %dt= t(:signature_algorithm) %dd= @csr.signature_algorithm - if @crt @@ -39,32 +39,32 @@ = t('crt') unless @certificate.revoked? = t('crt_revoked') if @certificate.revoked? .pull-right - = link_to(t('download'), download_crt_admin_api_user_certificate_path(@api_user, @certificate), class: 'btn btn-default btn-xs') + = link_to(t(:download), download_crt_admin_api_user_certificate_path(@api_user, @certificate), class: 'btn btn-default btn-xs') - unless @certificate.revoked? - = link_to(t('revoke_this_certificate'), revoke_admin_api_user_certificate_path(@api_user, @certificate), method: :post, class: 'btn btn-primary btn-xs') + = link_to(t(:revoke_this_certificate), revoke_admin_api_user_certificate_path(@api_user, @certificate), method: :post, class: 'btn btn-primary btn-xs') - if @crt .panel-body %dl.dl-horizontal - %dt= t('version') + %dt= t(:version) %dd= @crt.version - %dt= t('serial_number') + %dt= t(:serial_number) %dd= @crt.serial - %dt= t('signature_algorithm') + %dt= t(:signature_algorithm) %dd= @crt.signature_algorithm - %dt= t('issuer') + %dt= t(:issuer) %dd= @crt.issuer - %dt= t('valid_from') + %dt= t(:valid_from) %dd= @crt.not_before - %dt= t('valid_to') + %dt= t(:valid_to) %dd= @crt.not_after - %dt= t('subject') + %dt= t(:subject) %dd= @crt.subject - %dt= t('extensions') + %dt= t(:extensions) %dd= @crt.extensions.map(&:to_s).join('
').html_safe diff --git a/app/views/admin/contacts/partials/_domains.haml b/app/views/admin/contacts/partials/_domains.haml index 592bd976c..142c06397 100644 --- a/app/views/admin/contacts/partials/_domains.haml +++ b/app/views/admin/contacts/partials/_domains.haml @@ -1,12 +1,12 @@ #contacts.panel.panel-default - .panel-heading= t('domains') + .panel-heading= t(:domains) .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-4'}= t('domain_name') - %th{class: 'col-xs-4'}= t('registrar') - %th{class: 'col-xs-4'}= t('valid_to') + %th{class: 'col-xs-4'}= t(:domain_name) + %th{class: 'col-xs-4'}= t(:registrar) + %th{class: 'col-xs-4'}= t(:valid_to) %tbody - @contact.domains_owned.each do |x| %tr diff --git a/app/views/admin/domain_versions/oldindex.haml b/app/views/admin/domain_versions/oldindex.haml index cc4d3d99a..15a57d0f7 100644 --- a/app/views/admin/domain_versions/oldindex.haml +++ b/app/views/admin/domain_versions/oldindex.haml @@ -1,6 +1,6 @@ -# .row -# .col-sm-12 - -# %h2.text-center-xs= t('domains') + -# %h2.text-center-xs= t(:domains) -# %hr -# .row -# .col-md-12 @@ -9,7 +9,7 @@ -# %thead -# %tr -# %th{class: 'col-xs-1'} - -# = t('name') + -# = t(:name) -# %th{class: 'col-xs-1'} -# = sort_link(@q, 'whodunnit') -# %th{class: 'col-xs-1'} diff --git a/app/views/admin/domains/_form.haml b/app/views/admin/domains/_form.haml index 54587125c..3e16d5f03 100644 --- a/app/views/admin/domains/_form.haml +++ b/app/views/admin/domains/_form.haml @@ -9,7 +9,7 @@ = render 'admin/domains/form_partials/statuses', f: f .row .col-md-8.text-right - = button_tag(t('save'), class: 'btn btn-primary') + = button_tag(t(:save), class: 'btn btn-primary') :coffee $ -> diff --git a/app/views/admin/domains/form_partials/_statuses.haml b/app/views/admin/domains/form_partials/_statuses.haml index a2354343b..7ae89a8da 100644 --- a/app/views/admin/domains/form_partials/_statuses.haml +++ b/app/views/admin/domains/form_partials/_statuses.haml @@ -2,10 +2,10 @@ = f.fields_for :domain_statuses, @server_statuses do |status_fields| .panel.panel-default .panel-heading.clearfix - .pull-left= t('status') + .pull-left= t(:status) .pull-right - = link_to(t('add_another'), '#', class: 'btn btn-primary btn-xs add-domain-status') - = link_to(t('delete'), '#', class: 'btn btn-danger btn-xs destroy') + = link_to(t(:add_another), '#', class: 'btn btn-primary btn-xs add-domain-status') + = link_to(t(:delete), '#', class: 'btn btn-danger btn-xs destroy') .panel-body .errors = render 'shared/errors', object: status_fields.object diff --git a/app/views/admin/domains/partials/_dnskeys.haml b/app/views/admin/domains/partials/_dnskeys.haml index f4c04a71d..6d5759e65 100644 --- a/app/views/admin/domains/partials/_dnskeys.haml +++ b/app/views/admin/domains/partials/_dnskeys.haml @@ -1,15 +1,15 @@ - panel_class = @domain.errors.messages[:dnskeys] ? 'panel-danger' : 'panel-default' #dnskeys.panel{class: panel_class} .panel-heading.clearfix - = t('dnskeys') + = t(:dnskeys) .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-1'}= t('flag') - %th{class: 'col-xs-1'}= t('protocol') - %th{class: 'col-xs-1'}= t('algorithm') - %th{class: 'col-xs-9'}= t('public_key') + %th{class: 'col-xs-1'}= t(:flag) + %th{class: 'col-xs-1'}= t(:protocol) + %th{class: 'col-xs-1'}= t(:algorithm) + %th{class: 'col-xs-9'}= t(:public_key) %tbody - @domain.dnskeys.each do |x| %tr diff --git a/app/views/admin/domains/partials/_general.haml b/app/views/admin/domains/partials/_general.haml index b715330ab..17a6d5c45 100644 --- a/app/views/admin/domains/partials/_general.haml +++ b/app/views/admin/domains/partials/_general.haml @@ -1,22 +1,22 @@ .panel.panel-default .panel-heading - %h3.panel-title= t('general') + %h3.panel-title= t(:general) .panel-body %dl.dl-horizontal - %dt= t('name') + %dt= t(:name) %dd= @domain.name - %dt= t('registered_at') + %dt= t(:registered_at) %dd= l(@domain.registered_at) - %dt= t('registrar') + %dt= t(:registrar) %dd= link_to(@domain.registrar, root_path) - %dt= t('password') + %dt= t(:password) %dd= @domain.auth_info - %dt= t('valid_from') + %dt= t(:valid_from) %dd= l(@domain.valid_from) - %dt= t('valid_to') + %dt= t(:valid_to) %dd= l(@domain.valid_to) diff --git a/app/views/admin/domains/partials/_keyrelays.haml b/app/views/admin/domains/partials/_keyrelays.haml index 850abb9f0..43d099383 100644 --- a/app/views/admin/domains/partials/_keyrelays.haml +++ b/app/views/admin/domains/partials/_keyrelays.haml @@ -1,15 +1,15 @@ .panel{class: 'panel-default'} .panel-heading.clearfix - = t('keyrelays') + = t(:keyrelays) .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-4'}= t('uploaded_at') - %th{class: 'col-xs-3'}= t('expiry') - %th{class: 'col-xs-2'}= t('requester') - %th{class: 'col-xs-2'}= t('accepter') - %th{class: 'col-xs-1'}= t('status') + %th{class: 'col-xs-4'}= t(:uploaded_at) + %th{class: 'col-xs-3'}= t(:expiry) + %th{class: 'col-xs-2'}= t(:requester) + %th{class: 'col-xs-2'}= t(:accepter) + %th{class: 'col-xs-1'}= t(:status) %tbody - @domain.keyrelays.includes([:requester, :accepter]).order(pa_date: :desc).each do |x| %tr diff --git a/app/views/admin/domains/partials/_legal_documents.haml b/app/views/admin/domains/partials/_legal_documents.haml index 5a25ae325..900a9784a 100644 --- a/app/views/admin/domains/partials/_legal_documents.haml +++ b/app/views/admin/domains/partials/_legal_documents.haml @@ -1,12 +1,12 @@ .panel.panel-default .panel-heading.clearfix - = t('legal_documents') + = t(:legal_documents) .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-8'}= t('created_at') - %th{class: 'col-xs-4'}= t('type') + %th{class: 'col-xs-8'}= t(:created_at) + %th{class: 'col-xs-4'}= t(:type) %tbody - legal_documents.each do |x| %tr diff --git a/app/views/admin/domains/partials/_nameservers.haml b/app/views/admin/domains/partials/_nameservers.haml index 0b34986aa..db3ca759a 100644 --- a/app/views/admin/domains/partials/_nameservers.haml +++ b/app/views/admin/domains/partials/_nameservers.haml @@ -1,14 +1,14 @@ - panel_class = @domain.errors.messages[:nameservers] ? 'panel-danger' : 'panel-default' #nameservers.panel{class: panel_class} .panel-heading.clearfix - = t('nameservers') + = t(:nameservers) .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-4'}= t('hostname') - %th{class: 'col-xs-4'}= t('ipv4') - %th{class: 'col-xs-4'}= t('ipv6') + %th{class: 'col-xs-4'}= t(:hostname) + %th{class: 'col-xs-4'}= t(:ipv4) + %th{class: 'col-xs-4'}= t(:ipv6) %tbody - @domain.nameservers.each do |x| %tr diff --git a/app/views/admin/domains/partials/_statuses.haml b/app/views/admin/domains/partials/_statuses.haml index f570921be..f6f6a115c 100644 --- a/app/views/admin/domains/partials/_statuses.haml +++ b/app/views/admin/domains/partials/_statuses.haml @@ -1,13 +1,13 @@ - panel_class = @domain.errors.messages[:domain_statuses] ? 'panel-danger' : 'panel-default' #domain_statuses.panel{class: panel_class} .panel-heading.clearfix - = t('statuses') + = t(:statuses) .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-6'}= t('status') - %th{class: 'col-xs-6'}= t('description') + %th{class: 'col-xs-6'}= t(:status) + %th{class: 'col-xs-6'}= t(:description) %tbody - @domain.domain_statuses.each do |x| %tr diff --git a/app/views/admin/domains/partials/_tech_contacts.haml b/app/views/admin/domains/partials/_tech_contacts.haml index ea7eff13d..06c9ef95f 100644 --- a/app/views/admin/domains/partials/_tech_contacts.haml +++ b/app/views/admin/domains/partials/_tech_contacts.haml @@ -1,14 +1,14 @@ - panel_class = @domain.errors.messages[:tech_contacts] ? 'panel-danger' : 'panel-default' #tech_contacts.panel{class: panel_class} .panel-heading.clearfix - = t('tech_contacts') + = t(:tech_contacts) .table-responsive %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-4'}= t('name') - %th{class: 'col-xs-4'}= t('code') - %th{class: 'col-xs-4'}= t('email') + %th{class: 'col-xs-4'}= t(:name) + %th{class: 'col-xs-4'}= t(:code) + %th{class: 'col-xs-4'}= t(:email) %tbody - @domain.tech_contacts.each do |tc| %tr diff --git a/app/views/admin/invoices/index.haml b/app/views/admin/invoices/index.haml index 207f74c1d..45efe74de 100644 --- a/app/views/admin/invoices/index.haml +++ b/app/views/admin/invoices/index.haml @@ -1,6 +1,6 @@ .row .col-sm-12 - %h2.text-center-xs= t('invoices') + %h2.text-center-xs= t(:invoices) %hr .row .col-md-12 @@ -22,16 +22,16 @@ %td= link_to(x, [:admin, x]) %td= link_to(x.buyer_name, admin_registrar_path(x.buyer_id)) - if x.cancelled? - %td.text-grey= t('cancelled') + %td.text-grey= t(:cancelled) - else %td= l(x.due_date) - if x.binded? %td= l(x.receipt_date) - elsif x.cancelled? - %td.text-grey= t('cancelled') + %td.text-grey= t(:cancelled) - else - %td.text-danger= t('unpaid') + %td.text-danger= t(:unpaid) .row .col-md-12 = paginate @invoices diff --git a/app/views/admin/invoices/show.haml b/app/views/admin/invoices/show.haml index ccae84913..9bab21f1d 100644 --- a/app/views/admin/invoices/show.haml +++ b/app/views/admin/invoices/show.haml @@ -6,7 +6,7 @@ %h1.text-right.text-center-xs - if !@invoice.cancelled? && !@invoice.binded? = link_to(t(:cancel), cancel_admin_invoice_path(@invoice), method: :patch, class: 'btn btn-default') - = link_to(t('back'), admin_invoices_path, class: 'btn btn-default') + = link_to(t(:back), admin_invoices_path, class: 'btn btn-default') %hr = render 'shared/full_errors', object: @invoice diff --git a/app/views/admin/registrars/_form.haml b/app/views/admin/registrars/_form.haml index b54eb01e5..cd36c08eb 100644 --- a/app/views/admin/registrars/_form.haml +++ b/app/views/admin/registrars/_form.haml @@ -73,4 +73,4 @@ %hr .row .col-md-8.text-right - = button_tag(t('save'), class: 'btn btn-primary') + = button_tag(t(:save), class: 'btn btn-primary') diff --git a/app/views/admin/registrars/show.haml b/app/views/admin/registrars/show.haml index 17699cd90..f472b7625 100644 --- a/app/views/admin/registrars/show.haml +++ b/app/views/admin/registrars/show.haml @@ -60,7 +60,7 @@ .pull-left = t(:api_users) .pull-right - = link_to(t('create_new_api_user'), new_admin_registrar_api_user_path(@registrar), class: 'btn btn-primary btn-xs') + = link_to(t(:create_new_api_user), new_admin_registrar_api_user_path(@registrar), class: 'btn btn-primary btn-xs') .table-responsive %table.table.table-hover.table-bordered.table-condensed diff --git a/app/views/invoice_mailer/invoice_email.html.erb b/app/views/invoice_mailer/invoice_email.html.erb index 02be04880..0a9e4163b 100644 --- a/app/views/invoice_mailer/invoice_email.html.erb +++ b/app/views/invoice_mailer/invoice_email.html.erb @@ -1,5 +1,5 @@ -<%= t('you_have_a_new_invoice') %> +<%= t(:you_have_a_new_invoice) %>

-<%= t('sincerely') %>,
+<%= t(:sincerely) %>,
<%= Setting.eis_invoice_contact %>
<%= @invoice.seller_phone %> diff --git a/app/views/registrar/contacts/form_partials/_disclose.haml b/app/views/registrar/contacts/form_partials/_disclose.haml index e7c7ee959..51f675c57 100644 --- a/app/views/registrar/contacts/form_partials/_disclose.haml +++ b/app/views/registrar/contacts/form_partials/_disclose.haml @@ -1,41 +1,41 @@ .panel.panel-default .panel-heading.clearfix - .pull-left= t('contact_disclosure') + .pull-left= t(:contact_disclosure) .panel-body .form-group - = label_tag :contact_disclose_flag, t('flag_type'), class: 'col-md-2 control-label' + = label_tag :contact_disclose_flag, t(:flag_type), class: 'col-md-2 control-label' .col-md-10 =# check_box_tag('contact[disclose][sv_policy]', @contact_params[:disclose][:sv_policy], class: 'form-control') = select_tag('contact[disclose][flag]', options_for_select(Depp::Contact::DISCLOSURE_TYPES) ) .panel-body .form-group - = label_tag :contact_disclose_name, t('name'), class: 'col-md-2 control-label' + = label_tag :contact_disclose_name, t(:name), class: 'col-md-2 control-label' .col-md-10 = check_box_tag('contact[disclose][name]') .form-group - = label_tag :contact_disclose_email, t('email'), class: 'col-md-2 control-label' + = label_tag :contact_disclose_email, t(:email), class: 'col-md-2 control-label' .col-md-10 = check_box_tag('contact[disclose][email]') .form-group - = label_tag :contact_disclose_org_name, t('org_name'), class: 'col-md-2 control-label' + = label_tag :contact_disclose_org_name, t(:org_name), class: 'col-md-2 control-label' .col-md-10 = check_box_tag('contact[disclose][org_name]') .form-group - = label_tag :contact_disclose_address, t('address'), class: 'col-md-2 control-label' + = label_tag :contact_disclose_address, t(:address), class: 'col-md-2 control-label' .col-md-10 = check_box_tag('contact[disclose][address]') .form-group - = label_tag :contact_disclose_voice, t('voice'), class: 'col-md-2 control-label' + = label_tag :contact_disclose_voice, t(:voice), class: 'col-md-2 control-label' .col-md-10 = check_box_tag('contact[disclose][voice]') .form-group - = label_tag :contact_disclose_fax, t('fax'), class: 'col-md-2 control-label' + = label_tag :contact_disclose_fax, t(:fax), class: 'col-md-2 control-label' .col-md-10 = check_box_tag('contact[disclose][fax]') diff --git a/app/views/registrar/contacts/info_index.haml b/app/views/registrar/contacts/info_index.haml index c4fd16f68..8bec10ee0 100644 --- a/app/views/registrar/contacts/info_index.haml +++ b/app/views/registrar/contacts/info_index.haml @@ -4,11 +4,11 @@ .col-md-12 = form_tag registrar_contact_path, class: 'form-horizontal', method: :get do .form-group - = label_tag :contact_id, t('contact_id'), class: 'col-md-2 control-label' + = label_tag :contact_id, t(:contact_id), class: 'col-md-2 control-label' .col-md-10 = text_field_tag :contact_id, params[:contact_id], class: 'form-control', autocomplete: 'off' .form-group - = label_tag :password, t('password'), class: 'col-md-2 control-label' + = label_tag :password, t(:password), class: 'col-md-2 control-label' .col-md-10 = text_field_tag :password, params[:password], class: 'form-control', autocomplete: 'off' .form-group diff --git a/app/views/registrar/domains/_check_form.haml b/app/views/registrar/domains/_check_form.haml index 90242a7c0..2468fa69a 100644 --- a/app/views/registrar/domains/_check_form.haml +++ b/app/views/registrar/domains/_check_form.haml @@ -1,7 +1,7 @@ = form_tag check_registrar_domains_path, class: 'form-horizontal', method: :get do .col-md-11 .form-group - = text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t('domain_name'), autocomplete: 'off' + = text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t(:domain_name), autocomplete: 'off' .col-md-1.text-right.text-center-xs .form-group %button.btn.btn-primary diff --git a/app/views/registrar/domains/_form.haml b/app/views/registrar/domains/_form.haml index 385a2f507..aebe4ce65 100644 --- a/app/views/registrar/domains/_form.haml +++ b/app/views/registrar/domains/_form.haml @@ -15,7 +15,7 @@ .form-group .col-md-3.control-label - c, fr = 'required', true if params[:domain_name].blank? - = label_tag 'domain[legal_document]', t('legal_document'), class: c + = label_tag 'domain[legal_document]', t(:legal_document), class: c .col-md-7 = file_field_tag 'domain[legal_document]', required: fr .col-md-4 diff --git a/app/views/registrar/domains/check.haml b/app/views/registrar/domains/check.haml index 4808e9c5c..f8ebfeaca 100644 --- a/app/views/registrar/domains/check.haml +++ b/app/views/registrar/domains/check.haml @@ -10,16 +10,16 @@ .col-md-12 .panel.panel-default .panel-heading - %h3.panel-title= t('result') + %h3.panel-title= t(:result) .panel-body %dl.dl-horizontal - %dt= t('name') + %dt= t(:name) %dd= @data.css('name').text - name = @data.css('name').first - %dt= t('available') + %dt= t(:available) %dd= name['avail'] - if @data.css('reason').text.present? - %dt= t('reason') + %dt= t(:reason) %dd= @data.css('reason').text diff --git a/app/views/registrar/domains/delete.haml b/app/views/registrar/domains/delete.haml index ab83cd813..cbadbecd9 100644 --- a/app/views/registrar/domains/delete.haml +++ b/app/views/registrar/domains/delete.haml @@ -8,11 +8,11 @@ .panel-body .form-group .col-md-4.control-label - = label_tag 'domain[legal_document]', t('legal_document'), class: 'required' + = label_tag 'domain[legal_document]', t(:legal_document), class: 'required' .col-md-6 = file_field_tag 'domain[legal_document]', required: true = hidden_field_tag 'domain[name]', params[:domain_name] %hr .row .col-md-8.text-right - = button_tag t('delete'), class: 'btn btn-danger' + = button_tag t(:delete), class: 'btn btn-danger' diff --git a/app/views/registrar/domains/index.haml b/app/views/registrar/domains/index.haml index 3a65ddcbe..4574a9ef6 100644 --- a/app/views/registrar/domains/index.haml +++ b/app/views/registrar/domains/index.haml @@ -10,7 +10,7 @@ = form_tag info_registrar_domains_path, class: 'form-horizontal', method: :get do .col-md-11 .form-group - = text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t('domain_name'), autocomplete: 'off', autofocus: true + = text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t(:domain_name), autocomplete: 'off', autofocus: true .col-md-1.text-right.text-center-xs .form-group %button.btn.btn-default diff --git a/app/views/registrar/domains/partials/_contacts.haml b/app/views/registrar/domains/partials/_contacts.haml index ddb6d41e4..6c5bdeb86 100644 --- a/app/views/registrar/domains/partials/_contacts.haml +++ b/app/views/registrar/domains/partials/_contacts.haml @@ -5,8 +5,8 @@ %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-4'}= t('type') - %th{class: 'col-xs-8'}= t('code') + %th{class: 'col-xs-4'}= t(:type) + %th{class: 'col-xs-8'}= t(:code) %tbody - @data.css('contact').each do |x| %tr diff --git a/app/views/registrar/domains/partials/_dnskeys.haml b/app/views/registrar/domains/partials/_dnskeys.haml index 9bbca3e95..fc5961849 100644 --- a/app/views/registrar/domains/partials/_dnskeys.haml +++ b/app/views/registrar/domains/partials/_dnskeys.haml @@ -1,33 +1,33 @@ .panel.panel-default .panel-heading - %h3.panel-title= t('dnskeys') + %h3.panel-title= t(:dnskeys) .panel-body{style: 'word-wrap: break-word;'} - @data.css('dsData').each do |x| %dl.dl-horizontal - if x.css('keyTag').text.present? - %dt= t('ds_key_tag') + %dt= t(:ds_key_tag) %dd= x.css('keyTag').text - if x.css('alg').first.text.present? - %dt= t('ds_algorithm') + %dt= t(:ds_algorithm) %dd= x.css('alg').first.text - if x.css('digestType').text.present? - %dt= t('ds_digest_type') + %dt= t(:ds_digest_type) %dd= x.css('digestType').text - if x.css('digest').text.present? - %dt= t('ds_digest') + %dt= t(:ds_digest) %dd= x.css('digest').text - %dt= t('flag') + %dt= t(:flag) %dd= x.css('flags').text - %dt= t('protocol') + %dt= t(:protocol) %dd= x.css('protocol').text - %dt= t('algorithm') + %dt= t(:algorithm) %dd= x.css('keyData > alg').text - %dt= t('public_key') + %dt= t(:public_key) %dd= x.css('pubKey').text diff --git a/app/views/registrar/domains/partials/_nameservers.haml b/app/views/registrar/domains/partials/_nameservers.haml index 851801229..2ab72d95a 100644 --- a/app/views/registrar/domains/partials/_nameservers.haml +++ b/app/views/registrar/domains/partials/_nameservers.haml @@ -5,9 +5,9 @@ %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-4'}= t('hostname') - %th{class: 'col-xs-4'}= t('ipv4') - %th{class: 'col-xs-4'}= t('ipv6') + %th{class: 'col-xs-4'}= t(:hostname) + %th{class: 'col-xs-4'}= t(:ipv4) + %th{class: 'col-xs-4'}= t(:ipv6) %tbody - @data.css('hostAttr').each do |x| %tr diff --git a/app/views/registrar/domains/partials/_statuses.haml b/app/views/registrar/domains/partials/_statuses.haml index 5cd71caec..57ecc4105 100644 --- a/app/views/registrar/domains/partials/_statuses.haml +++ b/app/views/registrar/domains/partials/_statuses.haml @@ -5,8 +5,8 @@ %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-6'}= t('status') - %th{class: 'col-xs-6'}= t('description') + %th{class: 'col-xs-6'}= t(:status) + %th{class: 'col-xs-6'}= t(:description) %tbody - @data.css('status').each do |x| %tr diff --git a/app/views/registrar/domains/renew_index.haml b/app/views/registrar/domains/renew_index.haml index 51dee074a..92f7a8108 100644 --- a/app/views/registrar/domains/renew_index.haml +++ b/app/views/registrar/domains/renew_index.haml @@ -8,7 +8,7 @@ = label_tag :domain_name, t(:name), class: 'required' .col-md-7 = text_field_tag :domain_name, params[:domain_name], - class: 'form-control', placeholder: t('domain_name'), autocomplete: 'off', required: true + class: 'form-control', placeholder: t(:domain_name), autocomplete: 'off', required: true .form-group .col-md-3.control-label diff --git a/app/views/registrar/domains/transfer.haml b/app/views/registrar/domains/transfer.haml index 1bb7caee9..b5a8f438f 100644 --- a/app/views/registrar/domains/transfer.haml +++ b/app/views/registrar/domains/transfer.haml @@ -4,10 +4,10 @@ .col-md-12 .panel.panel-default .panel-heading - %h3.panel-title= t('result') + %h3.panel-title= t(:result) .panel-body %dl.dl-horizontal - %dt= t('domain_name') + %dt= t(:domain_name) %dd= @data.css('name').text - @data.css('trnData').children.each do |x| diff --git a/app/views/registrar/invoices/index.haml b/app/views/registrar/invoices/index.haml index 18f027fb0..d0c38940b 100644 --- a/app/views/registrar/invoices/index.haml +++ b/app/views/registrar/invoices/index.haml @@ -63,7 +63,7 @@ - if x.receipt_date %td= l(x.receipt_date) - elsif x.cancelled? - %td.text-grey= t('cancelled') + %td.text-grey= t(:cancelled) - else %td{class: 'text-danger'}= t(:unpaid) diff --git a/app/views/registrar/invoices/partials/_banklinks.haml b/app/views/registrar/invoices/partials/_banklinks.haml index 883adb418..efd6f8564 100644 --- a/app/views/registrar/invoices/partials/_banklinks.haml +++ b/app/views/registrar/invoices/partials/_banklinks.haml @@ -1,4 +1,4 @@ -%h4= t('pay_by_bank_link') +%h4= t(:pay_by_bank_link) %hr = link_to '#' do = image_tag('swed.png') diff --git a/app/views/registrar/invoices/partials/_buyer.haml b/app/views/registrar/invoices/partials/_buyer.haml index 2993cd823..30824ff01 100644 --- a/app/views/registrar/invoices/partials/_buyer.haml +++ b/app/views/registrar/invoices/partials/_buyer.haml @@ -1,23 +1,23 @@ -%h4= t('buyer') +%h4= t(:buyer) %hr %dl.dl-horizontal - %dt= t('name') + %dt= t(:name) %dd= @invoice.buyer_name - %dt= t('reg_no') + %dt= t(:reg_no) %dd= @invoice.buyer_reg_no - %dt= t('address') + %dt= t(:address) %dd= @invoice.buyer_address - %dt= t('country') + %dt= t(:country) %dd= @invoice.buyer_country - %dt= t('phone') + %dt= t(:phone) %dd= @invoice.buyer_phone - %dt= t('url') + %dt= t(:url) %dd= @invoice.buyer_url - %dt= t('email') + %dt= t(:email) %dd= @invoice.buyer_email diff --git a/app/views/registrar/invoices/partials/_details.haml b/app/views/registrar/invoices/partials/_details.haml index 0e5528514..07a2d0761 100644 --- a/app/views/registrar/invoices/partials/_details.haml +++ b/app/views/registrar/invoices/partials/_details.haml @@ -1,33 +1,33 @@ -%h4= t('details') +%h4= t(:details) %hr %dl.dl-horizontal - %dt= t('issue_date') + %dt= t(:issue_date) %dd= l(@invoice.created_at) - if @invoice.cancelled? - %dt= t('cancel_date') + %dt= t(:cancel_date) %dd= l(@invoice.cancelled_at) - %dt= t('due_date') + %dt= t(:due_date) - if @invoice.cancelled? - %dd.text-grey= t('cancelled') + %dd.text-grey= t(:cancelled) - else %dd= l(@invoice.due_date) - %dt= t('receipt_date') + %dt= t(:receipt_date) - if @invoice.binded? %dd= l(@invoice.receipt_date) - elsif @invoice.cancelled? - %dd.text-grey= t('cancelled') + %dd.text-grey= t(:cancelled) - else - %dd{class: 'text-danger'}= t('unpaid') + %dd{class: 'text-danger'}= t(:unpaid) - %dt= t('payment_term') + %dt= t(:payment_term) %dd= t(@invoice.payment_term) - %dt= t('description') + %dt= t(:description) - @invoice.description.prepend(' - ') if @invoice.description.present? %dd= "#{t('invoice_no', no: @invoice.id)}#{@invoice.description}" - %dt= t('reference_no') + %dt= t(:reference_no) %dd= @invoice.reference_no diff --git a/app/views/registrar/invoices/partials/_items.haml b/app/views/registrar/invoices/partials/_items.haml index 4babfaddd..784fe4412 100644 --- a/app/views/registrar/invoices/partials/_items.haml +++ b/app/views/registrar/invoices/partials/_items.haml @@ -1,14 +1,14 @@ -%h4= t('items') +%h4= t(:items) %hr .table-responsive %table.table.table-hover.table-condensed %thead %tr - %th{class: 'col-xs-4'}= t('description') - %th{class: 'col-xs-2'}= t('unit') - %th{class: 'col-xs-2'}= t('amount') - %th{class: 'col-xs-2'}= t('price') - %th{class: 'col-xs-2'}= t('total') + %th{class: 'col-xs-4'}= t(:description) + %th{class: 'col-xs-2'}= t(:unit) + %th{class: 'col-xs-2'}= t(:amount) + %th{class: 'col-xs-2'}= t(:price) + %th{class: 'col-xs-2'}= t(:total) %tbody - @invoice.items.each do |x| %tr @@ -20,7 +20,7 @@ %tfoot %tr %th{colspan: 3} - %th= t('total_without_vat') + %th= t(:total_without_vat) %td= @invoice.sum_without_vat %tr %th.no-border{colspan: 3} @@ -28,5 +28,5 @@ %td= @invoice.vat %tr %th.no-border{colspan: 3} - %th= t('total') + %th= t(:total) %td= @invoice.sum diff --git a/app/views/registrar/invoices/partials/_seller.haml b/app/views/registrar/invoices/partials/_seller.haml index ab082fcd0..0008c2f13 100644 --- a/app/views/registrar/invoices/partials/_seller.haml +++ b/app/views/registrar/invoices/partials/_seller.haml @@ -1,38 +1,38 @@ -%h4= t('seller') +%h4= t(:seller) %hr %dl.dl-horizontal - %dt= t('name') + %dt= t(:name) %dd= @invoice.seller_name - %dt= t('reg_no') + %dt= t(:reg_no) %dd= @invoice.seller_reg_no - %dt= t('iban') + %dt= t(:iban) %dd= @invoice.seller_iban - %dt= t('bank') + %dt= t(:bank) %dd= @invoice.seller_bank - %dt= t('swift') + %dt= t(:swift) %dd= @invoice.seller_swift - %dt= t('vat_no') + %dt= t(:vat_no) %dd= @invoice.seller_vat_no - %dt= t('address') + %dt= t(:address) %dd= @invoice.seller_address - %dt= t('country') + %dt= t(:country) %dd= @invoice.seller_country - %dt= t('phone') + %dt= t(:phone) %dd= @invoice.seller_phone - %dt= t('url') + %dt= t(:url) %dd= @invoice.seller_url - %dt= t('email') + %dt= t(:email) %dd= @invoice.seller_email - %dt= t('issuer') + %dt= t(:issuer) %dd= @invoice.seller_contact_name diff --git a/app/views/registrar/invoices/partials/_total.haml b/app/views/registrar/invoices/partials/_total.haml index 247f84b64..5ed1db4f2 100644 --- a/app/views/registrar/invoices/partials/_total.haml +++ b/app/views/registrar/invoices/partials/_total.haml @@ -1,17 +1,17 @@ -%h4= t('total') +%h4= t(:total) %hr %dl.dl-horizontal - / %dt= t('document_name') + / %dt= t(:document_name) / %dd= t(@invoice.document_name) - %dt= t('issue_date') + %dt= t(:issue_date) %dd= l(@invoice.created_at) - %dt= t('due_date') + %dt= t(:due_date) %dd= l(@invoice.due_date) - %dt= t('payment_term') + %dt= t(:payment_term) %dd= t(@invoice.payment_term) - %dt= t('description') + %dt= t(:description) %dd= @invoice.description diff --git a/app/views/registrar/invoices/pdf.haml b/app/views/registrar/invoices/pdf.haml index 95cb3c1a0..f4644d80e 100644 --- a/app/views/registrar/invoices/pdf.haml +++ b/app/views/registrar/invoices/pdf.haml @@ -148,68 +148,68 @@ Details %hr %dl.dl-horizontal - %dt= t('issue_date') + %dt= t(:issue_date) %dd= l(@invoice.created_at) - if @invoice.cancelled? - %dt= t('cancel_date') + %dt= t(:cancel_date) %dd= l(@invoice.cancelled_at) - %dt= t('due_date') + %dt= t(:due_date) - if @invoice.cancelled? - %dd= t('cancelled') + %dd= t(:cancelled) - else %dd= l(@invoice.due_date) - %dt= t('receipt_date') + %dt= t(:receipt_date) - if @invoice.binded? %dd= l(@invoice.receipt_date) - elsif @invoice.cancelled? - %dd= t('cancelled') + %dd= t(:cancelled) - else - %dd{class: 'text-danger'}= t('unpaid') + %dd{class: 'text-danger'}= t(:unpaid) - %dt= t('issuer') + %dt= t(:issuer) %dd= @invoice.seller_contact_name - %dt= t('payment_term') + %dt= t(:payment_term) %dd= t(@invoice.payment_term) - %dt= t('description') + %dt= t(:description) - @invoice.description.prepend(' - ') if @invoice.description.present? %dd= "#{t('invoice_no', no: @invoice.id)}#{@invoice.description}" - %dt= t('reference_no') + %dt= t(:reference_no) %dd= @invoice.reference_no .col-md-6.right - %h4= t('client') + %h4= t(:client) %hr %dl.dl-horizontal - %dt= t('name') + %dt= t(:name) %dd= @invoice.buyer_name - %dt= t('reg_no') + %dt= t(:reg_no) %dd= @invoice.buyer_reg_no - if @invoice.buyer_address.present? - %dt= t('address') + %dt= t(:address) %dd= @invoice.buyer_address - if @invoice.buyer_country.present? - %dt= t('country') + %dt= t(:country) %dd= @invoice.buyer_country - if @invoice.buyer_phone.present? - %dt= t('phone') + %dt= t(:phone) %dd= @invoice.buyer_phone - if @invoice.buyer_phone.present? - %dt= t('url') + %dt= t(:url) %dd= @invoice.buyer_url - if @invoice.buyer_email.present? - %dt= t('email') + %dt= t(:email) %dd= @invoice.buyer_email .clear @@ -219,11 +219,11 @@ %table.table.table-hover.table-condensed %thead %tr - %th{class: 'col-xs-4'}= t('description') - %th{class: 'col-xs-2'}= t('unit') - %th{class: 'col-xs-1'}= t('amount') - %th{class: 'col-xs-3'}= t('price') - %th{class: 'col-xs-2'}= t('total') + %th{class: 'col-xs-4'}= t(:description) + %th{class: 'col-xs-2'}= t(:unit) + %th{class: 'col-xs-1'}= t(:amount) + %th{class: 'col-xs-3'}= t(:price) + %th{class: 'col-xs-2'}= t(:total) %tbody - @invoice.items.each do |x| %tr @@ -235,7 +235,7 @@ %tfoot %tr %th{colspan: 3} - %th= t('total_without_vat') + %th= t(:total_without_vat) %td= "#{@invoice.sum_without_vat} #{@invoice.currency}" %tr %th.no-border{colspan: 3} @@ -243,7 +243,7 @@ %td= "#{@invoice.vat} #{@invoice.currency}" %tr %th.no-border{colspan: 3} - %th= t('total') + %th= t(:total) %td= "#{@invoice.sum} #{@invoice.currency}" #footer @@ -268,11 +268,11 @@ = @invoice.seller_url .col-md-3.text-right.left - = t('bank') + = t(:bank) %br - = t('iban') + = t(:iban) %br - = t('swift') + = t(:swift) .col-md-3.left = @invoice.seller_bank diff --git a/app/views/registrar/nameservers/index.haml b/app/views/registrar/nameservers/index.haml index 493f17cd0..915b0d935 100644 --- a/app/views/registrar/nameservers/index.haml +++ b/app/views/registrar/nameservers/index.haml @@ -25,7 +25,7 @@ = t(:replace) .row .col-md-12 - %p.help-block= t('hostnames_will_be_replaced_only_if_domain_validates_with_the_new_nameserver') + %p.help-block= t(:hostnames_will_be_replaced_only_if_domain_validates_with_the_new_nameserver) %hr .row .col-md-12 diff --git a/app/views/registrar/polls/show.haml b/app/views/registrar/polls/show.haml index fcfa994a3..90a5bb02a 100644 --- a/app/views/registrar/polls/show.haml +++ b/app/views/registrar/polls/show.haml @@ -11,49 +11,49 @@ .pull-left= t('message_no', id: msg_q['id']) .pull-right - if @data.css('panData').any? # this is a keyrelay request - = link_to(t('confirm'), 'javascript: void(0);', class: 'btn btn-warning btn-xs js-keyrelay-confirm') + = link_to(t(:confirm), 'javascript: void(0);', class: 'btn btn-warning btn-xs js-keyrelay-confirm') - if @data.css('trnData trStatus').any? # this is a transfer request - unless ['serverApproved', 'clientApproved'].include?(@data.css('trStatus').first.text) - = link_to(t('confirm'), 'javascript: void(0);', class: 'btn btn-warning btn-xs js-transfer-confirm') - = link_to(t('dequeue'), registrar_poll_path(id: msg_q['id']), method: :delete, class: 'btn btn-primary btn-xs') + = link_to(t(:confirm), 'javascript: void(0);', class: 'btn btn-warning btn-xs js-transfer-confirm') + = link_to(t(:dequeue), registrar_poll_path(id: msg_q['id']), method: :delete, class: 'btn btn-primary btn-xs') .panel-body %dl.dl-horizontal - %dt= t('message') + %dt= t(:message) %dd= msg_q.css('msg').text - %dt= t('queue_date') + %dt= t(:queue_date) %dd= @data.css('qDate').text %dl.dl-horizontal / keyrelay - if @data.css('panData').any? - %dt= t('domain_name') + %dt= t(:domain_name) %dd= @data.css('name').text - %dt= t('password') + %dt= t(:password) %dd= @data.css('pw').text - if @data.css('relative').text.present? - %dt= t('expiry_relative') + %dt= t(:expiry_relative) %dd= @data.css('relative').text - if @data.css('absolute').text.present? - %dt= t('expiry_absolute') + %dt= t(:expiry_absolute) %dd= @data.css('absolute').text %dt paDate %dd= @data.css('paDate').text - %dt= t('flag') + %dt= t(:flag) %dd= @data.css('flags').text - %dt= t('protocol') + %dt= t(:protocol) %dd= @data.css('protocol').text - %dt= t('algorithm') + %dt= t(:algorithm) %dd= @data.css('alg').text - %dt= t('public_key') + %dt= t(:public_key) %dd= @data.css('pubKey').text = form_tag confirm_keyrelay_registrar_poll_path, class: 'js-keyrelay-form' do @@ -79,7 +79,7 @@ %hr .row .col-md-12 - %p.bg-info{style: 'padding: 15px;'}= t('you_have_no_new_messages') + %p.bg-info{style: 'padding: 15px;'}= t(:you_have_no_new_messages) :coffee $(".js-keyrelay-confirm").on "click", -> From 0af59ef351f129db9b99b5d0f0c2be5f2bd71f97 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 30 Apr 2015 15:16:21 +0300 Subject: [PATCH 3/5] Cleaned up rspec create settings and refactored whois_record --- Guardfile | 4 +- app/models/domain.rb | 13 +- app/models/registrar.rb | 2 - app/models/whois_record.rb | 95 +++++++------- spec/epp/contact_spec.rb | 1 - spec/epp/domain_spec.rb | 1 - spec/epp/keyrelay_spec.rb | 1 - spec/epp/poll_spec.rb | 2 - spec/features/admin/admin_user_spec.rb | 2 - spec/features/admin/api_user_spec.rb | 2 - spec/features/admin/contact_spec.rb | 2 - spec/features/admin/epp_log_spec.rb | 2 - spec/features/admin/invoice_spec.rb | 2 - spec/features/admin/repp_log_spec.rb | 2 - spec/features/admin/zonefile_setting_spec.rb | 2 - spec/features/registrar/contact_spec.rb | 1 - spec/features/registrar/domain_spec.rb | 1 - spec/features/registrar/invoices_spec.rb | 1 - spec/features/registrar/root_spec.rb | 1 - spec/features/registrar/sessions_spec.rb | 1 - spec/features/sessions_spec.rb | 1 - spec/features/setting_management_spec.rb | 2 - spec/models/dnskey_spec.rb | 4 - spec/models/domain_spec.rb | 75 ----------- spec/models/epp_domain_spec.rb | 4 - spec/models/setting_spec.rb | 1 - spec/models/whois_record_spec.rb | 127 +++++++++++++++++++ spec/models/zonefile_setting_spec.rb | 1 - spec/rails_helper.rb | 27 ++++ spec/requests/v1/contact_spec.rb | 1 - spec/requests/v1/domain_spec.rb | 1 - spec/support/general.rb | 26 ---- 32 files changed, 210 insertions(+), 198 deletions(-) create mode 100644 spec/models/whois_record_spec.rb delete mode 100644 spec/support/general.rb diff --git a/Guardfile b/Guardfile index 31958aa77..ab7619ed7 100644 --- a/Guardfile +++ b/Guardfile @@ -9,8 +9,8 @@ group :red_green_refactor, halt_on_fail: true do # watch(%r{^(config|lib)/.*}) # end - guard :rspec, cmd: 'spring rspec --fail-fast', notification: false do - # guard :rspec, cmd: 'spring rspec', notification: false do + # 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" } diff --git a/app/models/domain.rb b/app/models/domain.rb index a094f48ae..d0ae261b3 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -54,7 +54,6 @@ class Domain < ActiveRecord::Base end after_save :manage_automatic_statuses after_save :update_whois_record - after_save :update_whois_server validates :name_dirty, domain_name: true, uniqueness: true validates :period, numericality: { only_integer: true } @@ -123,6 +122,7 @@ class Domain < ActiveRecord::Base def included includes( + :registrant, :registrar, :nameservers, :whois_record, @@ -244,15 +244,6 @@ class Domain < ActiveRecord::Base end def update_whois_record - self.whois_record = WhoisRecord.create if whois_record.blank? - whois_record.update - end - - def update_whois_server - if whois_record.present? - whois_record.update_whois_server - else - logger.info "NO WHOIS BODY for domain: #{name}" - end + whois_record.blank? ? create_whois_record : whois_record.save end end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 1723ebdd2..ea36daef5 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -37,8 +37,6 @@ class Registrar < ActiveRecord::Base end end - after_save :touch_domains_version - validates :email, :billing_email, format: /@/, allow_blank: true class << self diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index 928896236..d8384edfd 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -1,32 +1,33 @@ class WhoisRecord < ActiveRecord::Base belongs_to :domain - def update_whois_server - return logger.info "NO WHOIS NAME for whois record id: #{id}" if name.blank? - wd = Whois::Record.find_or_initialize_by(name: name) - wd.body = body - wd.json = json - wd.save + validates :domain, :name, :body, :json, presence: true + + before_validation :populate + def populate + return if domain.blank? + self.json = generate_json + self.name = json['name'] + self.body = generated_body end # rubocop:disable Metrics/MethodLength - def h - @h ||= HashWithIndifferentAccess.new - end + def generate_json + h = HashWithIndifferentAccess.new + return h if domain.blank? - def update @disclosed = [] h[:name] = domain.name h[:registrant] = domain.registrant.name h[:status] = domain.domain_statuses.map(&:human_value).join(', ') - h[:registered] = domain.registered_at and domain.registered_at.to_s(:db) - h[:updated_at] = domain.updated_at and domain.updated_at.to_s(:db) - h[:valid_to] = domain.valid_to and domain.valid_to.to_s(:db) + h[:registered] = domain.registered_at.try(:to_s, :iso8601) + h[:updated_at] = domain.updated_at.try(:to_s, :iso8601) + h[:valid_to] = domain.valid_to.try(:to_s, :iso8601) h[:registrar] = domain.registrar.name h[:registrar_phone] = domain.registrar.phone h[:registrar_address] = domain.registrar.address - h[:registrar_update_at] = domain.registrar.updated_at.to_s(:db) + h[:registrar_update_at] = domain.registrar.updated_at.try(:to_s, :iso8601) h[:admin_contacts] = [] domain.admin_contacts.each do |ac| @disclosed << [:email, ac.email] @@ -34,7 +35,7 @@ class WhoisRecord < ActiveRecord::Base name: ac.name, email: ac.email, registrar: ac.registrar.name, - created_at: ac.created_at.to_s(:db) + created_at: ac.created_at.try(:to_s, :iso8601) } end h[:tech_contacts] = [] @@ -44,23 +45,18 @@ class WhoisRecord < ActiveRecord::Base name: tc.name, email: tc.email, registrar: tc.registrar.name, - created_at: tc.created_at.to_s(:db) + created_at: tc.created_at.try(:to_s, :iso8601) } end h[:nameservers] = [] domain.nameservers.each do |ns| h[:nameservers] << { hostname: ns.hostname, - updated_at: ns.updated_at.to_s(:db) + updated_at: ns.updated_at.try(:to_s, :iso8601) } end - h[:disclosed] = @disclosed - - self.name = h[:name] - self.body = generated_body - self.json = h - save + h end def generated_body @@ -68,21 +64,21 @@ class WhoisRecord < ActiveRecord::Base Estonia .ee Top Level Domain WHOIS server Domain: - name: #{h[:name]} - registrant: #{h[:registrant]} - status: #{h[:status]} - registered: #{h[:registered]} - changed: #{h[:updated_at]} - expire: #{h[:valid_to]} + name: #{json['name']} + registrant: #{json['registrant']} + status: #{json['status']} + registered: #{Time.zone.parse(json['registered'])} + changed: #{Time.zone.parse(json['updated_at'])} + expire: #{Time.zone.parse(json['valid_to'])} outzone: delete: -#{contacts_body(h[:admin_contacts], h[:tech_contacts])} +#{contacts_body(json['admin_contacts'], json['tech_contacts'])} Registrar: - name: #{h[:registrar]} - phone: #{h[:registrar_phone]} - address: #{h[:registrar_address]} - changed: #{h[:registrar_update_at]} -#{nameservers_body(h[:nameservers])} + name: #{json['registrar']} + phone: #{json['registrar_phone']} + address: #{json['registrar_address']} + changed: #{Time.zone.parse(json['registrar_update_at'])} +#{nameservers_body(json['nameservers'])} Estonia .ee Top Level Domain WHOIS server More information at http://internet.ee EOS @@ -90,34 +86,47 @@ More information at http://internet.ee # rubocop:enable Metrics/MethodLength def contacts_body(admins, techs) + admins ||= [] + techs ||= [] + out = '' out << (admins.size > 1 ? "\nAdministrative contacts" : "\nAdministrative contact") admins.each do |c| - out << "\n name: #{c[:name]}" + out << "\n name: #{c['name']}" out << "\n email: Not Disclosed - Visit www.internet.ee for webbased WHOIS" - out << "\n registrar: #{c[:registrar]}" - out << "\n created: #{c[:created_at]}" + out << "\n registrar: #{c['registrar']}" + out << "\n created: #{Time.zone.parse(c['created_at'])}" out << "\n" end out << (techs.size > 1 ? "\nTechnical contacts" : "\nTechnical contact:") techs.each do |c| - out << "\n name: #{c[:name]}" + out << "\n name: #{c['name']}" out << "\n email: Not Disclosed - Visit www.internet.ee for webbased WHOIS" - out << "\n registrar: #{c[:registrar]}" - out << "\n created: #{c[:created_at]}" + out << "\n registrar: #{c['registrar']}" + out << "\n created: #{Time.zone.parse(c['created_at'])}" out << "\n" end out end def nameservers_body(nservers) + nservers ||= [] + out = "\nName servers:" nservers.each do |ns| - out << "\n nserver: #{ns[:hostname]}" - out << "\n changed: #{ns[:updated_at]}" + out << "\n nserver: #{ns['hostname']}" + out << "\n changed: #{Time.zone.parse(ns['updated_at'])}" out << "\n" end out end + + def update_whois_server + return logger.info "NO WHOIS NAME for whois record id: #{id}" if name.blank? + wd = Whois::Record.find_or_initialize_by(name: name) + wd.body = body + wd.json = json + wd.save + end end diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index cb5f4555e..7efcf04f9 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' describe 'EPP Contact', epp: true do before :all do - create_settings @registrar1 = Fabricate(:registrar1) @registrar2 = Fabricate(:registrar2) @epp_xml = EppXml::Contact.new(cl_trid: 'ABC-12345') diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 95fe3c821..c7dd22f6a 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' describe 'EPP Domain', epp: true do before(:all) do - create_settings @epp_xml = EppXml.new(cl_trid: 'ABC-12345') @registrar1 = Fabricate(:registrar1) @registrar2 = Fabricate(:registrar2) diff --git a/spec/epp/keyrelay_spec.rb b/spec/epp/keyrelay_spec.rb index da5bdf570..451c5f7cc 100644 --- a/spec/epp/keyrelay_spec.rb +++ b/spec/epp/keyrelay_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' describe 'EPP Keyrelay', epp: true do before(:all) do - create_settings @registrar1 = Fabricate(:registrar1) @registrar2 = Fabricate(:registrar2) @domain = Fabricate(:domain, registrar: @registrar2) diff --git a/spec/epp/poll_spec.rb b/spec/epp/poll_spec.rb index b1639c546..cf585ff69 100644 --- a/spec/epp/poll_spec.rb +++ b/spec/epp/poll_spec.rb @@ -18,8 +18,6 @@ describe 'EPP Poll', epp: true do login_as :registrar1 @uniq_no = proc { @i ||= 0; @i += 1 } - - create_settings end it 'returns no messages in poll' do diff --git a/spec/features/admin/admin_user_spec.rb b/spec/features/admin/admin_user_spec.rb index 2e9219341..2a08245af 100644 --- a/spec/features/admin/admin_user_spec.rb +++ b/spec/features/admin/admin_user_spec.rb @@ -1,8 +1,6 @@ require 'rails_helper' feature 'Admin users', type: :feature do - background { create_settings } - before :all do @admin_user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') end diff --git a/spec/features/admin/api_user_spec.rb b/spec/features/admin/api_user_spec.rb index a8a752154..36ba2a767 100644 --- a/spec/features/admin/api_user_spec.rb +++ b/spec/features/admin/api_user_spec.rb @@ -1,8 +1,6 @@ require 'rails_helper' feature 'Api users', type: :feature do - background { create_settings } - before :all do @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @api_user = Fabricate(:api_user) diff --git a/spec/features/admin/contact_spec.rb b/spec/features/admin/contact_spec.rb index afd67c296..18fcd19cf 100644 --- a/spec/features/admin/contact_spec.rb +++ b/spec/features/admin/contact_spec.rb @@ -1,8 +1,6 @@ require 'rails_helper' feature 'Admin contact', type: :feature do - background { create_settings } - before :all do @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @contact = Fabricate(:contact, name: 'Mr John') diff --git a/spec/features/admin/epp_log_spec.rb b/spec/features/admin/epp_log_spec.rb index 6c260ecd5..9aeebde2b 100644 --- a/spec/features/admin/epp_log_spec.rb +++ b/spec/features/admin/epp_log_spec.rb @@ -1,8 +1,6 @@ require 'rails_helper' feature 'EPP log', type: :feature do - background { create_settings } - before :all do @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @contact = Fabricate(:contact, name: 'Mr John') diff --git a/spec/features/admin/invoice_spec.rb b/spec/features/admin/invoice_spec.rb index f2a58d0a8..176ba2b66 100644 --- a/spec/features/admin/invoice_spec.rb +++ b/spec/features/admin/invoice_spec.rb @@ -1,8 +1,6 @@ require 'rails_helper' feature 'Invoice', type: :feature do - background { create_settings } - before :all do @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') Fabricate(:invoice) diff --git a/spec/features/admin/repp_log_spec.rb b/spec/features/admin/repp_log_spec.rb index 95a73c4e5..7f1cf4af3 100644 --- a/spec/features/admin/repp_log_spec.rb +++ b/spec/features/admin/repp_log_spec.rb @@ -1,8 +1,6 @@ require 'rails_helper' feature 'Repp log', type: :feature do - background { create_settings } - before :all do @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') end diff --git a/spec/features/admin/zonefile_setting_spec.rb b/spec/features/admin/zonefile_setting_spec.rb index d7653c75a..afcdc2a7c 100644 --- a/spec/features/admin/zonefile_setting_spec.rb +++ b/spec/features/admin/zonefile_setting_spec.rb @@ -1,8 +1,6 @@ require 'rails_helper' feature 'Zonefile settings', type: :feature do - background { create_settings } - before :all do @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') end diff --git a/spec/features/registrar/contact_spec.rb b/spec/features/registrar/contact_spec.rb index 1650b1a9c..150103559 100644 --- a/spec/features/registrar/contact_spec.rb +++ b/spec/features/registrar/contact_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' feature 'Contact', type: :feature do before :all do - create_settings @user = Fabricate(:api_user) end diff --git a/spec/features/registrar/domain_spec.rb b/spec/features/registrar/domain_spec.rb index 647fcee4f..c72f50b84 100644 --- a/spec/features/registrar/domain_spec.rb +++ b/spec/features/registrar/domain_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' feature 'Domains', type: :feature do before :all do - create_settings @user = Fabricate(:api_user) end diff --git a/spec/features/registrar/invoices_spec.rb b/spec/features/registrar/invoices_spec.rb index 2deb54f73..88deed70b 100644 --- a/spec/features/registrar/invoices_spec.rb +++ b/spec/features/registrar/invoices_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' feature 'Invoices', type: :feature do before :all do - create_settings @user = Fabricate(:api_user) @invoice = Fabricate(:invoice, buyer: @user.registrar) end diff --git a/spec/features/registrar/root_spec.rb b/spec/features/registrar/root_spec.rb index 0d6b751fb..a00b80b3c 100644 --- a/spec/features/registrar/root_spec.rb +++ b/spec/features/registrar/root_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' feature 'Root', type: :feature do before :all do - create_settings Fabricate(:api_user) end diff --git a/spec/features/registrar/sessions_spec.rb b/spec/features/registrar/sessions_spec.rb index 97b50bec9..26f73851c 100644 --- a/spec/features/registrar/sessions_spec.rb +++ b/spec/features/registrar/sessions_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' feature 'Sessions', type: :feature do before :all do - create_settings Fabricate(:api_user) end diff --git a/spec/features/sessions_spec.rb b/spec/features/sessions_spec.rb index c22698976..20ff66a38 100644 --- a/spec/features/sessions_spec.rb +++ b/spec/features/sessions_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' feature 'Sessions', type: :feature do before :all do - create_settings Fabricate(:ee_user) @registrar1 = Fabricate(:registrar1) @registrar2 = Fabricate(:registrar2) diff --git a/spec/features/setting_management_spec.rb b/spec/features/setting_management_spec.rb index 8888afae3..7f18ff5fa 100644 --- a/spec/features/setting_management_spec.rb +++ b/spec/features/setting_management_spec.rb @@ -3,8 +3,6 @@ require 'rails_helper' feature 'Setting management', type: :feature do let(:user) { Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') } - background { create_settings } - scenario 'User changes a setting' do sign_in user visit admin_settings_path diff --git a/spec/models/dnskey_spec.rb b/spec/models/dnskey_spec.rb index dff7d84b2..911713da5 100644 --- a/spec/models/dnskey_spec.rb +++ b/spec/models/dnskey_spec.rb @@ -1,10 +1,6 @@ require 'rails_helper' describe Dnskey do - before :all do - create_settings - end - it { should belong_to(:domain) } context 'with invalid attribute' do diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index ac8dc8c10..fadcb98e0 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -1,10 +1,6 @@ require 'rails_helper' describe Domain do - before :all do - create_settings - end - it { should belong_to(:registrar) } it { should have_many(:nameservers) } it { should belong_to(:registrant) } @@ -81,77 +77,6 @@ describe Domain do @domain.whois_record.json.present?.should == true end - it 'should have whois record present by default' do - @domain.name = 'yeah.ee' - @domain.updated_at = Time.zone.parse('2020.02.02 02:00') - @domain.registered_at = Time.zone.parse('2000.01.01 9:00') - @domain.valid_to = Time.zone.parse('2016.04.21 0:00') - registrar = Fabricate(:registrar, - name: 'First Registrar Ltd', - created_at: Time.zone.parse('1995.01.01'), - updated_at: Time.zone.parse('1996.01.01')) - @domain.registrant = Fabricate(:contact, - name: 'Jarren Jakubowski0', - created_at: Time.zone.parse('2005.01.01')) - @domain.admin_contacts = [Fabricate(:contact, - name: 'First Admin', - registrar: registrar, - created_at: Time.zone.parse('2016.01.01'))] - @domain.tech_contacts = [Fabricate(:contact, - name: 'First Tech', - registrar: registrar, - created_at: Time.zone.parse('2016.01.01'))] - @domain.registrar = registrar - ns1 = Fabricate(:nameserver, hostname: 'test.ee') - ns1.updated_at = Time.zone.parse('1980.01.01') - ns2 = Fabricate(:nameserver, hostname: 'test1.ee') - ns2.updated_at = Time.zone.parse('1970.01.01') - @domain.nameservers = [ns1, ns2] - - @domain.update_whois_record - @domain.whois_record.body.should == <<-EOS -Estonia .ee Top Level Domain WHOIS server - -Domain: - name: yeah.ee - registrant: Jarren Jakubowski0 - status: ok (paid and in zone) - registered: 2000-01-01 09:00:00 UTC - changed: 2020-02-02 02:00:00 UTC - expire: 2016-04-21 00:00:00 UTC - outzone: - delete: - -Administrative contact - name: First Admin - email: Not Disclosed - Visit www.internet.ee for webbased WHOIS - registrar: First Registrar Ltd - created: 2016-01-01 00:00:00 - -Technical contact: - name: First Tech - email: Not Disclosed - Visit www.internet.ee for webbased WHOIS - registrar: First Registrar Ltd - created: 2016-01-01 00:00:00 - -Registrar: - name: First Registrar Ltd - phone: - address: Street 999, Town, County, Postal - changed: 1996-01-01 00:00:00 - -Name servers: - nserver: test.ee - changed: 1980-01-01 00:00:00 - - nserver: test1.ee - changed: 1970-01-01 00:00:00 - -Estonia .ee Top Level Domain WHOIS server -More information at http://internet.ee - EOS - end - context 'with versioning' do it 'should not have one version' do with_versioning do diff --git a/spec/models/epp_domain_spec.rb b/spec/models/epp_domain_spec.rb index 3cd640005..9dab00c8a 100644 --- a/spec/models/epp_domain_spec.rb +++ b/spec/models/epp_domain_spec.rb @@ -3,9 +3,5 @@ require 'rails_helper' describe Epp::Domain do context 'with sufficient settings' do let(:domain) { Fabricate(:epp_domain) } - - before(:each) do - create_settings - end end end diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 9459fc999..84af99501 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' describe Setting do it 'returns value' do - create_settings expect(Setting.ns_min_count).to eq(2) Setting.ns_min_count = '2' expect(Setting.ns_min_count).to eq('2') diff --git a/spec/models/whois_record_spec.rb b/spec/models/whois_record_spec.rb new file mode 100644 index 000000000..964603d95 --- /dev/null +++ b/spec/models/whois_record_spec.rb @@ -0,0 +1,127 @@ +require 'rails_helper' + +describe WhoisRecord do + context 'with invalid attribute' do + before :all do + @whois_record = WhoisRecord.new + end + + it 'should not be valid' do + @whois_record.valid? + @whois_record.errors.full_messages.should match_array([ + "Body is missing", + "Domain is missing", + "Json is missing", + "Name is missing" + ]) + end + + it 'should not support versions' do + @whois_record.respond_to?(:versions).should == false + end + + it 'should not have whois body' do + @whois_record.body.should == nil + end + end + + context 'with valid attributes' do + before :all do + @whois_record = Fabricate(:domain).whois_record + end + + it 'should be valid' do + @whois_record.valid? + @whois_record.errors.full_messages.should match_array([]) + end + + it 'should be valid twice' do + @whois_record = Fabricate(:domain).whois_record + @whois_record.valid? + @whois_record.errors.full_messages.should match_array([]) + end + + it 'should have whois body by default' do + @whois_record.body.present?.should == true + end + + it 'should have whois json by default' do + @whois_record.json.present?.should == true + end + + it 'should have whois record present by default' do + @domain = Fabricate(:domain, name: 'yeah.ee') + @domain.updated_at = Time.zone.parse('2020.02.02 02:00') + @domain.valid_to = Time.zone.parse('2016.04.21 0:00') + registrar = Fabricate(:registrar, + name: 'First Registrar Ltd', + created_at: Time.zone.parse('1995.01.01'), + updated_at: Time.zone.parse('1996.01.01')) + @domain.registrant = Fabricate(:contact, + name: 'Jarren Jakubowski0', + created_at: Time.zone.parse('2005.01.01')) + @domain.admin_contacts = [Fabricate(:contact, + name: 'First Admin', + registrar: registrar, + created_at: Time.zone.parse('2016.01.01'))] + @domain.tech_contacts = [Fabricate(:contact, + name: 'First Tech', + registrar: registrar, + created_at: Time.zone.parse('2016.01.01'))] + @domain.registrar = registrar + ns1 = Fabricate(:nameserver, hostname: 'test.ee') + ns1.updated_at = Time.zone.parse('1980.01.01') + ns2 = Fabricate(:nameserver, hostname: 'test1.ee') + ns2.updated_at = Time.zone.parse('1970.01.01') + @domain.nameservers = [ns1, ns2] + + @domain.save + + # load some very dynamic attributes + registered = @domain.whois_record.json['registered'] + changed = @domain.whois_record.json['updated_at'] + + @domain.whois_record.body.should == <<-EOS +Estonia .ee Top Level Domain WHOIS server + +Domain: + name: yeah.ee + registrant: Jarren Jakubowski0 + status: ok (paid and in zone) + registered: #{Time.zone.parse(registered)} + changed: #{Time.zone.parse(changed)} + expire: 2016-04-21 00:00:00 UTC + outzone: + delete: + +Administrative contact + name: First Admin + email: Not Disclosed - Visit www.internet.ee for webbased WHOIS + registrar: First Registrar Ltd + created: 2016-01-01 00:00:00 UTC + +Technical contact: + name: First Tech + email: Not Disclosed - Visit www.internet.ee for webbased WHOIS + registrar: First Registrar Ltd + created: 2016-01-01 00:00:00 UTC + +Registrar: + name: First Registrar Ltd + phone: + address: Street 999, Town, County, Postal + changed: 1996-01-01 00:00:00 UTC + +Name servers: + nserver: test.ee + changed: 1980-01-01 00:00:00 UTC + + nserver: test1.ee + changed: 1970-01-01 00:00:00 UTC + +Estonia .ee Top Level Domain WHOIS server +More information at http://internet.ee + EOS + end + end +end diff --git a/spec/models/zonefile_setting_spec.rb b/spec/models/zonefile_setting_spec.rb index 2239fa4c8..9604a1cd0 100644 --- a/spec/models/zonefile_setting_spec.rb +++ b/spec/models/zonefile_setting_spec.rb @@ -1,7 +1,6 @@ require 'rails_helper' describe ZonefileSetting do - before { create_settings } it 'generates the zonefile' do ZonefileSetting.where({ origin: 'ee', diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index cd28b925b..eca52cf12 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -26,6 +26,28 @@ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } # If you are not using ActiveRecord, you can remove this line. ActiveRecord::Migration.maintain_test_schema! +# create general settings +def create_settings + Setting.ds_algorithm = 2 + Setting.ds_data_allowed = true + Setting.ds_data_with_key_allowed = true + Setting.key_data_allowed = true + + Setting.dnskeys_min_count = 0 + Setting.dnskeys_max_count = 9 + Setting.ns_min_count = 2 + Setting.ns_max_count = 11 + + Setting.transfer_wait_time = 0 + + Setting.admin_contacts_min_count = 1 + Setting.admin_contacts_max_count = 10 + Setting.tech_contacts_min_count = 0 + Setting.tech_contacts_max_count = 10 + + Setting.client_side_status_editing_enabled = true +end + RSpec.configure do |config| config.filter_run focus: true config.run_all_when_everything_filtered = true @@ -45,21 +67,26 @@ RSpec.configure do |config| config.before(:all) do DatabaseCleaner.clean_with(:truncation) + create_settings end config.before(:all, epp: true) do DatabaseCleaner.strategy = nil + create_settings end config.before(:each, js: true) do DatabaseCleaner.strategy = :truncation + create_settings end config.before(:each, type: :request) do DatabaseCleaner.strategy = :truncation + create_settings end config.before(:each, type: :model) do + create_settings DatabaseCleaner.strategy = :transaction DatabaseCleaner.start end diff --git a/spec/requests/v1/contact_spec.rb b/spec/requests/v1/contact_spec.rb index bd5f8567b..6db06c28d 100644 --- a/spec/requests/v1/contact_spec.rb +++ b/spec/requests/v1/contact_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' describe Repp::ContactV1 do before :all do - create_settings @api_user = Fabricate(:gitlab_api_user) Fabricate.times(2, :contact, registrar: @api_user.registrar) Fabricate.times(2, :contact) diff --git a/spec/requests/v1/domain_spec.rb b/spec/requests/v1/domain_spec.rb index e4a10680a..a7502ad0e 100644 --- a/spec/requests/v1/domain_spec.rb +++ b/spec/requests/v1/domain_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' describe Repp::DomainV1 do before :all do - create_settings @registrar1 = Fabricate(:registrar1) @api_user = Fabricate(:gitlab_api_user, registrar: @registrar1) Fabricate.times(2, :domain, registrar: @api_user.registrar) diff --git a/spec/support/general.rb b/spec/support/general.rb deleted file mode 100644 index 5831ebf83..000000000 --- a/spec/support/general.rb +++ /dev/null @@ -1,26 +0,0 @@ -module General - def create_settings - Setting.ds_algorithm = 2 - Setting.ds_data_allowed = true - Setting.ds_data_with_key_allowed = true - Setting.key_data_allowed = true - - Setting.dnskeys_min_count = 0 - Setting.dnskeys_max_count = 9 - Setting.ns_min_count = 2 - Setting.ns_max_count = 11 - - Setting.transfer_wait_time = 0 - - Setting.admin_contacts_min_count = 1 - Setting.admin_contacts_max_count = 10 - Setting.tech_contacts_min_count = 0 - Setting.tech_contacts_max_count = 10 - - Setting.client_side_status_editing_enabled = true - end -end - -RSpec.configure do |c| - c.include General -end From dabd7ecb62f70415919f2a8858cbe7832bfce23b Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 30 Apr 2015 18:29:26 +0300 Subject: [PATCH 4/5] Updated pagination size and registrar trigger now honors only whois attributes --- .../admin/registrars_controller.rb | 2 +- app/models/registrar.rb | 15 +++++++++ app/models/whois_record.rb | 21 ++++++++++-- config/initializers/kaminari_config.rb | 10 ++++++ ...121807_add_registrar_id_to_whois_record.rb | 6 ++++ db/schema.rb | 8 +++-- lib/tasks/whois.rake | 33 ++++++++----------- spec/models/whois_record_spec.rb | 8 +++++ 8 files changed, 77 insertions(+), 26 deletions(-) create mode 100644 config/initializers/kaminari_config.rb create mode 100644 db/migrate/20150430121807_add_registrar_id_to_whois_record.rb diff --git a/app/controllers/admin/registrars_controller.rb b/app/controllers/admin/registrars_controller.rb index ed9955518..5448ced2e 100644 --- a/app/controllers/admin/registrars_controller.rb +++ b/app/controllers/admin/registrars_controller.rb @@ -6,7 +6,7 @@ class Admin::RegistrarsController < AdminController end def index - @q = Registrar.search(params[:q]) + @q = Registrar.ordered.search(params[:q]) @registrars = @q.result.page(params[:page]) end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index ea36daef5..a2dbf4385 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -8,6 +8,7 @@ class Registrar < ActiveRecord::Base has_many :invoices, foreign_key: 'buyer_id' has_many :accounts has_many :nameservers, through: :domains + has_many :whois_records belongs_to :country_deprecated, foreign_key: :country_id @@ -39,6 +40,15 @@ class Registrar < ActiveRecord::Base validates :email, :billing_email, format: /@/, allow_blank: true + WHOIS_TRIGGERS = %w(name email phone street city state zip) + + after_save :update_whois_records + def update_whois_records + if changed? && (changes.keys & WHOIS_TRIGGERS).present? + whois_records.map(&:save) # slow currently + end + end + class << self def search_by_query(query) res = search(name_or_reg_no_cont: query).result @@ -48,6 +58,11 @@ class Registrar < ActiveRecord::Base def eis find_by(reg_no: '90010019') end + + def ordered + order(name: :asc) + end + end def issue_prepayment_invoice(amount, description = nil) # rubocop:disable Metrics/MethodLength diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index d8384edfd..e1a0f124b 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -5,10 +5,25 @@ class WhoisRecord < ActiveRecord::Base before_validation :populate def populate - return if domain.blank? + return if domain_id.blank? self.json = generate_json - self.name = json['name'] self.body = generated_body + self.name = json['name'] + self.registrar_id = domain.registrar_id # for faster registrar updates + end + + class << self + def included + includes( + domain: [ + :registrant, + :registrar, + :nameservers, + { tech_contacts: :registrar }, + { admin_contacts: :registrar } + ] + ) + end end # rubocop:disable Metrics/MethodLength @@ -24,10 +39,12 @@ class WhoisRecord < ActiveRecord::Base h[:updated_at] = domain.updated_at.try(:to_s, :iso8601) h[:valid_to] = domain.valid_to.try(:to_s, :iso8601) + # update registar triggers when adding new attributes h[:registrar] = domain.registrar.name h[:registrar_phone] = domain.registrar.phone h[:registrar_address] = domain.registrar.address h[:registrar_update_at] = domain.registrar.updated_at.try(:to_s, :iso8601) + h[:admin_contacts] = [] domain.admin_contacts.each do |ac| @disclosed << [:email, ac.email] diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb new file mode 100644 index 000000000..2eeb4bab6 --- /dev/null +++ b/config/initializers/kaminari_config.rb @@ -0,0 +1,10 @@ +Kaminari.configure do |config| + config.default_per_page = 75 + # config.max_per_page = nil + # config.window = 4 + # config.outer_window = 0 + # config.left = 0 + # config.right = 0 + # config.page_method_name = :page + # config.param_name = :page +end diff --git a/db/migrate/20150430121807_add_registrar_id_to_whois_record.rb b/db/migrate/20150430121807_add_registrar_id_to_whois_record.rb new file mode 100644 index 000000000..c9551ca9e --- /dev/null +++ b/db/migrate/20150430121807_add_registrar_id_to_whois_record.rb @@ -0,0 +1,6 @@ +class AddRegistrarIdToWhoisRecord < ActiveRecord::Migration + def change + add_column :whois_records, :registrar_id, :integer + add_index :whois_records, :registrar_id + end +end diff --git a/db/schema.rb b/db/schema.rb index d30dece39..86e8b4017 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150429135339) do +ActiveRecord::Schema.define(version: 20150430121807) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -917,11 +917,13 @@ ActiveRecord::Schema.define(version: 20150429135339) do t.string "name" t.text "body" t.json "json" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "registrar_id" end add_index "whois_records", ["domain_id"], name: "index_whois_records_on_domain_id", using: :btree + add_index "whois_records", ["registrar_id"], name: "index_whois_records_on_registrar_id", using: :btree create_table "zonefile_settings", force: :cascade do |t| t.string "origin" diff --git a/lib/tasks/whois.rake b/lib/tasks/whois.rake index 9a62dee9a..293a34d2d 100644 --- a/lib/tasks/whois.rake +++ b/lib/tasks/whois.rake @@ -1,19 +1,25 @@ namespace :whois do - desc 'Regenerate whois records at Registry master database (slow)' + desc 'Regenerate Registry whois_records table and sync with whois server (slower)' task regenerate: :environment do start = Time.zone.now.to_f - print "-----> Regenerate whois records at Registry master database..." - Domain.included.find_each(batch_size: 50000).with_index do |d, index| - d.update_whois_record - print '.' if index % 100 == 0 + + @i = 0 + print "-----> Regenerate Registry whois_records table and sync with whois server..." + ActiveRecord::Base.uncached do + puts "\n#{@i}" + Domain.included.find_in_batches(batch_size: 10000) do |batch| + batch.map { |d| d.update_whois_record } + puts(@i += 10000) + GC.start + end end puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds" end - desc 'Delete whois database data and sync with Registry master database (fast)' + desc 'Delete whois database data and import from Registry master database (faster)' task export: :environment do start = Time.zone.now.to_f - print "-----> Delete whois database data and sync with Registry master database..." + print "-----> Delete whois database data and import from Registry whois_records table..." whois_records = WhoisRecord.pluck(:name, :body, :json) Whois::Record.delete_all Whois::Record.import([:name, :body, :json], whois_records) @@ -37,18 +43,5 @@ namespace :whois do puts "\n#{e}" end end - - desc 'Force whois schema into exsisting whois database' - task force_load: [:environment] do - whois_db = "whois_#{Rails.env}" - begin - puts "\n------------------------ #{whois_db} schema loading ------------------------------\n" - ActiveRecord::Base.clear_all_connections! - ActiveRecord::Base.establish_connection(whois_db.to_sym) - load("#{Rails.root}/db/#{schema_file(whois_db)}") - rescue => e - puts "\n#{e}" - end - end end end diff --git a/spec/models/whois_record_spec.rb b/spec/models/whois_record_spec.rb index 964603d95..7e89984d1 100644 --- a/spec/models/whois_record_spec.rb +++ b/spec/models/whois_record_spec.rb @@ -23,6 +23,10 @@ describe WhoisRecord do it 'should not have whois body' do @whois_record.body.should == nil end + + it 'should not have registrar' do + @whois_record.registrar.should == nil + end end context 'with valid attributes' do @@ -41,6 +45,10 @@ describe WhoisRecord do @whois_record.errors.full_messages.should match_array([]) end + it 'should have registrar' do + @whois_record.registrar.present?.should == true + end + it 'should have whois body by default' do @whois_record.body.present?.should == true end From 5ed51852af008b8c9bfa8969f3709978791623c8 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 30 Apr 2015 18:32:27 +0300 Subject: [PATCH 5/5] skip alpha migration --- db/migrate/20150429135339_add_missing_data.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/migrate/20150429135339_add_missing_data.rb b/db/migrate/20150429135339_add_missing_data.rb index de69bf908..edc972a21 100644 --- a/db/migrate/20150429135339_add_missing_data.rb +++ b/db/migrate/20150429135339_add_missing_data.rb @@ -2,6 +2,8 @@ class AddMissingData < ActiveRecord::Migration def change return if Rails.env == 'development' return if Rails.env == 'test' + return if Rails.env == 'alpha' + puts 'GENERATING ACCOUNTS' Registrar.all.each do |x| Account.create(