mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
Merge branch 'master' into 499-admin-wildcard-search
This commit is contained in:
parent
f93286c2e6
commit
fd6e625d25
49 changed files with 382 additions and 160 deletions
|
@ -17,7 +17,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Login to container registry
|
- name: Login to container registry
|
||||||
env:
|
env:
|
||||||
|
|
6
.github/workflows/ruby.yml
vendored
6
.github/workflows/ruby.yml
vendored
|
@ -22,7 +22,7 @@ jobs:
|
||||||
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: ruby/setup-ruby@v1
|
- uses: ruby/setup-ruby@v1
|
||||||
with:
|
with:
|
||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: ${{ matrix.ruby }}
|
||||||
|
@ -79,7 +79,7 @@ jobs:
|
||||||
- name: Save coverage
|
- name: Save coverage
|
||||||
run: ./cc-test-reporter format-coverage --output coverage/codeclimate.${{ matrix.ruby }}.json
|
run: ./cc-test-reporter format-coverage --output coverage/codeclimate.${{ matrix.ruby }}.json
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2.3.1
|
- uses: actions/upload-artifact@v3.0.0
|
||||||
with:
|
with:
|
||||||
name: coverage-${{ matrix.ruby }}
|
name: coverage-${{ matrix.ruby }}
|
||||||
path: coverage/codeclimate.${{ matrix.ruby }}.json
|
path: coverage/codeclimate.${{ matrix.ruby }}.json
|
||||||
|
@ -104,7 +104,7 @@ jobs:
|
||||||
- name: Give test coverage reporter executable permissions
|
- name: Give test coverage reporter executable permissions
|
||||||
run: chmod +x cc-test-reporter
|
run: chmod +x cc-test-reporter
|
||||||
|
|
||||||
- uses: actions/download-artifact@v2.1.0
|
- uses: actions/download-artifact@v3.0.0
|
||||||
with:
|
with:
|
||||||
name: coverage-${{ matrix.ruby }}
|
name: coverage-${{ matrix.ruby }}
|
||||||
path: coverage
|
path: coverage
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,6 +9,7 @@
|
||||||
/config/application.yml
|
/config/application.yml
|
||||||
/config/environments/development.rb
|
/config/environments/development.rb
|
||||||
/config/deploy.rb
|
/config/deploy.rb
|
||||||
|
/config/master.key
|
||||||
/.idea
|
/.idea
|
||||||
|
|
||||||
# Do not commit one. Instead, download the latest from https://github.com/internetee/style-guide.
|
# Do not commit one. Instead, download the latest from https://github.com/internetee/style-guide.
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
31.03.2022
|
||||||
|
* Sidekiq update to 6.4.1 [#2322](https://github.com/internetee/registry/pull/2322)
|
||||||
|
|
||||||
|
25.03.2022
|
||||||
|
* Bulk change of business contacts' names requires now user confirmation [#2309](https://github.com/internetee/registry/pull/2309)
|
||||||
|
|
||||||
23.02.2022
|
23.02.2022
|
||||||
* FD notes are updated when basis for FD changes [#2216](https://github.com/internetee/registry/issues/2216)
|
* FD notes are updated when basis for FD changes [#2216](https://github.com/internetee/registry/issues/2216)
|
||||||
* Admin: date filter end date in domain hostory is now inclusive [#2274](https://github.com/internetee/registry/issues/2274)
|
* Admin: date filter end date in domain hostory is now inclusive [#2274](https://github.com/internetee/registry/issues/2274)
|
||||||
|
|
6
Gemfile
6
Gemfile
|
@ -17,7 +17,7 @@ gem 'figaro', '~> 1.2'
|
||||||
|
|
||||||
# model related
|
# model related
|
||||||
gem 'paper_trail', '~> 12.1'
|
gem 'paper_trail', '~> 12.1'
|
||||||
gem 'pg', '1.3.3'
|
gem 'pg', '1.3.5'
|
||||||
# 1.8 is for Rails < 5.0
|
# 1.8 is for Rails < 5.0
|
||||||
gem 'ransack', '~> 2.6.0'
|
gem 'ransack', '~> 2.6.0'
|
||||||
gem 'truemail', '~> 2.4' # validates email by regexp, mail server existence and address existence
|
gem 'truemail', '~> 2.4' # validates email by regexp, mail server existence and address existence
|
||||||
|
@ -40,7 +40,7 @@ gem 'select2-rails', '4.0.13' # for autocomplete
|
||||||
gem 'selectize-rails', '0.12.6' # include selectize.js for select
|
gem 'selectize-rails', '0.12.6' # include selectize.js for select
|
||||||
|
|
||||||
# registry specfic
|
# registry specfic
|
||||||
gem 'data_migrate', '~> 7.0'
|
gem 'data_migrate', '~> 8.0'
|
||||||
gem 'dnsruby', '~> 1.61'
|
gem 'dnsruby', '~> 1.61'
|
||||||
gem 'isikukood' # for EE-id validation
|
gem 'isikukood' # for EE-id validation
|
||||||
gem 'money-rails'
|
gem 'money-rails'
|
||||||
|
@ -70,7 +70,7 @@ gem 'jquery-ui-rails', '6.0.1'
|
||||||
gem 'pdfkit'
|
gem 'pdfkit'
|
||||||
gem 'que'
|
gem 'que'
|
||||||
gem 'que-web'
|
gem 'que-web'
|
||||||
gem 'sidekiq'
|
gem 'sidekiq', '>= 6.4.1'
|
||||||
|
|
||||||
gem 'company_register', github: 'internetee/company_register',
|
gem 'company_register', github: 'internetee/company_register',
|
||||||
branch: 'master'
|
branch: 'master'
|
||||||
|
|
22
Gemfile.lock
22
Gemfile.lock
|
@ -193,7 +193,7 @@ GEM
|
||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.12.2)
|
coffee-script-source (1.12.2)
|
||||||
concurrent-ruby (1.1.9)
|
concurrent-ruby (1.1.10)
|
||||||
connection_pool (2.2.5)
|
connection_pool (2.2.5)
|
||||||
countries (4.0.1)
|
countries (4.0.1)
|
||||||
i18n_data (~> 0.13.0)
|
i18n_data (~> 0.13.0)
|
||||||
|
@ -205,7 +205,7 @@ GEM
|
||||||
daemons-rails (1.2.1)
|
daemons-rails (1.2.1)
|
||||||
daemons
|
daemons
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
data_migrate (7.0.2)
|
data_migrate (8.0.0)
|
||||||
activerecord (>= 5.0)
|
activerecord (>= 5.0)
|
||||||
railties (>= 5.0)
|
railties (>= 5.0)
|
||||||
database_cleaner (2.0.1)
|
database_cleaner (2.0.1)
|
||||||
|
@ -289,7 +289,7 @@ GEM
|
||||||
kaminari-core (1.2.1)
|
kaminari-core (1.2.1)
|
||||||
libxml-ruby (3.2.1)
|
libxml-ruby (3.2.1)
|
||||||
logger (1.4.3)
|
logger (1.4.3)
|
||||||
loofah (2.12.0)
|
loofah (2.16.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
mail (2.7.1)
|
mail (2.7.1)
|
||||||
|
@ -351,7 +351,7 @@ GEM
|
||||||
activerecord (>= 5.2)
|
activerecord (>= 5.2)
|
||||||
request_store (~> 1.1)
|
request_store (~> 1.1)
|
||||||
pdfkit (0.8.5)
|
pdfkit (0.8.5)
|
||||||
pg (1.3.3)
|
pg (1.3.5)
|
||||||
pg_query (2.1.2)
|
pg_query (2.1.2)
|
||||||
google-protobuf (>= 3.17.1)
|
google-protobuf (>= 3.17.1)
|
||||||
pghero (2.8.1)
|
pghero (2.8.1)
|
||||||
|
@ -360,7 +360,7 @@ GEM
|
||||||
coderay (~> 1.1)
|
coderay (~> 1.1)
|
||||||
method_source (~> 1.0)
|
method_source (~> 1.0)
|
||||||
public_suffix (4.0.6)
|
public_suffix (4.0.6)
|
||||||
puma (5.6.2)
|
puma (5.6.4)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
que (0.14.3)
|
que (0.14.3)
|
||||||
que-web (0.7.2)
|
que-web (0.7.2)
|
||||||
|
@ -449,7 +449,7 @@ GEM
|
||||||
selenium-webdriver (3.142.7)
|
selenium-webdriver (3.142.7)
|
||||||
childprocess (>= 0.5, < 4.0)
|
childprocess (>= 0.5, < 4.0)
|
||||||
rubyzip (>= 1.2.2)
|
rubyzip (>= 1.2.2)
|
||||||
sidekiq (6.4.0)
|
sidekiq (6.4.1)
|
||||||
connection_pool (>= 2.2.2)
|
connection_pool (>= 2.2.2)
|
||||||
rack (~> 2.0)
|
rack (~> 2.0)
|
||||||
redis (>= 4.2.0)
|
redis (>= 4.2.0)
|
||||||
|
@ -480,7 +480,7 @@ GEM
|
||||||
attr_required (>= 0.0.5)
|
attr_required (>= 0.0.5)
|
||||||
httpclient (>= 2.4)
|
httpclient (>= 2.4)
|
||||||
temple (0.8.2)
|
temple (0.8.2)
|
||||||
thor (1.1.0)
|
thor (1.2.1)
|
||||||
tilt (2.0.10)
|
tilt (2.0.10)
|
||||||
truemail (2.4.9)
|
truemail (2.4.9)
|
||||||
simpleidn (~> 0.2.1)
|
simpleidn (~> 0.2.1)
|
||||||
|
@ -544,7 +544,7 @@ DEPENDENCIES
|
||||||
company_register!
|
company_register!
|
||||||
countries
|
countries
|
||||||
daemons-rails (= 1.2.1)
|
daemons-rails (= 1.2.1)
|
||||||
data_migrate (~> 7.0)
|
data_migrate (~> 8.0)
|
||||||
database_cleaner
|
database_cleaner
|
||||||
devise (~> 4.8)
|
devise (~> 4.8)
|
||||||
digidoc_client!
|
digidoc_client!
|
||||||
|
@ -574,7 +574,7 @@ DEPENDENCIES
|
||||||
omniauth-tara!
|
omniauth-tara!
|
||||||
paper_trail (~> 12.1)
|
paper_trail (~> 12.1)
|
||||||
pdfkit
|
pdfkit
|
||||||
pg (= 1.3.3)
|
pg (= 1.3.5)
|
||||||
pg_query (>= 0.9.0)
|
pg_query (>= 0.9.0)
|
||||||
pghero
|
pghero
|
||||||
pry (= 0.14.1)
|
pry (= 0.14.1)
|
||||||
|
@ -588,7 +588,7 @@ DEPENDENCIES
|
||||||
sass-rails
|
sass-rails
|
||||||
select2-rails (= 4.0.13)
|
select2-rails (= 4.0.13)
|
||||||
selectize-rails (= 0.12.6)
|
selectize-rails (= 0.12.6)
|
||||||
sidekiq
|
sidekiq (>= 6.4.1)
|
||||||
simplecov (= 0.17.1)
|
simplecov (= 0.17.1)
|
||||||
simpleidn (= 0.2.1)
|
simpleidn (= 0.2.1)
|
||||||
spy
|
spy
|
||||||
|
@ -601,4 +601,4 @@ DEPENDENCIES
|
||||||
wkhtmltopdf-binary (~> 0.12.5.1)
|
wkhtmltopdf-binary (~> 0.12.5.1)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.2.31
|
2.3.9
|
||||||
|
|
|
@ -35,7 +35,8 @@ module Admin
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.csv do
|
format.csv do
|
||||||
send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
|
raw_csv = CsvGenerator.generate_csv(@q.result)
|
||||||
|
send_data raw_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Admin
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render page }
|
format.html { render page }
|
||||||
format.csv do
|
format.csv do
|
||||||
raw_csv = @q.result.to_csv
|
raw_csv = CsvGenerator.generate_csv(@q.result)
|
||||||
send_data raw_csv,
|
send_data raw_csv,
|
||||||
filename: "#{filename}_#{Time.zone.now.to_formatted_s(:number)}.csv",
|
filename: "#{filename}_#{Time.zone.now.to_formatted_s(:number)}.csv",
|
||||||
type: "#{Mime[:csv]}; charset=utf-8"
|
type: "#{Mime[:csv]}; charset=utf-8"
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
module Admin
|
module Admin
|
||||||
class ContactVersionsController < BaseController
|
class ContactVersionsController < BaseController
|
||||||
include ObjectVersionsHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
load_and_authorize_resource class: Version::ContactVersion
|
load_and_authorize_resource class: Version::ContactVersion
|
||||||
|
|
||||||
def index
|
def index
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
|
|
||||||
search_params = PartialSearchFormatter.format(params[:q])
|
search_params = PartialSearchFormatter.format(fix_date_params)
|
||||||
versions = Version::ContactVersion.includes(:item).order(created_at: :desc, id: :desc)
|
versions = Version::ContactVersion.includes(:item).order(created_at: :desc, id: :desc)
|
||||||
@q = versions.ransack(polymorphic_association(search_params))
|
@q = versions.ransack(polymorphic_association(search_params))
|
||||||
|
|
||||||
|
@ -48,5 +48,14 @@ module Admin
|
||||||
|
|
||||||
record_type
|
record_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fix_date_params
|
||||||
|
params_copy = params[:q].deep_dup
|
||||||
|
if params_copy['created_at_lteq'].present?
|
||||||
|
params_copy['created_at_lteq'] = Date.parse(params_copy['created_at_lteq']) + 1.day
|
||||||
|
end
|
||||||
|
|
||||||
|
params_copy
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
module Admin
|
module Admin
|
||||||
class DomainVersionsController < BaseController
|
class DomainVersionsController < BaseController
|
||||||
include ObjectVersionsHelper
|
|
||||||
|
|
||||||
load_and_authorize_resource class: Version::DomainVersion
|
load_and_authorize_resource class: Version::DomainVersion
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -82,9 +80,8 @@ module Admin
|
||||||
|
|
||||||
def fix_date_params
|
def fix_date_params
|
||||||
params_copy = params[:q].deep_dup
|
params_copy = params[:q].deep_dup
|
||||||
if params_copy['created_at_lteq'].present?
|
created_at = params_copy['created_at_lteq']
|
||||||
params_copy['created_at_lteq'] = Date.parse(params_copy['created_at_lteq']) + 1.day
|
params_copy['created_at_lteq'] = Date.parse(created_at) + 1.day if created_at.present?
|
||||||
end
|
|
||||||
|
|
||||||
params_copy
|
params_copy
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,6 +34,17 @@ module Api
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def do_need_update_contact
|
||||||
|
result = current_registrant_user.do_need_update_contact?
|
||||||
|
render json: { update_contacts: result[:result], counter: result[:counter] }
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_company_contacts
|
||||||
|
companies = current_registrant_user.update_company_contacts
|
||||||
|
|
||||||
|
render json: { message: 'get it', companies: companies }
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
logger.debug 'Received update request'
|
logger.debug 'Received update request'
|
||||||
logger.debug params
|
logger.debug params
|
||||||
|
|
|
@ -20,7 +20,8 @@ class Registrar
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { @account_activities = @q.result.page(params[:page]) }
|
format.html { @account_activities = @q.result.page(params[:page]) }
|
||||||
format.csv do
|
format.csv do
|
||||||
send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
|
raw_csv = CsvGenerator.generate_csv(@q.result)
|
||||||
|
send_data raw_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Registrar
|
||||||
@contacts = @contacts.per(contacts_per_page) if contacts_per_page.positive?
|
@contacts = @contacts.per(contacts_per_page) if contacts_per_page.positive?
|
||||||
end
|
end
|
||||||
format.csv do
|
format.csv do
|
||||||
raw_csv = contacts.to_csv
|
raw_csv = CsvGenerator.generate_csv(contacts)
|
||||||
send_data raw_csv, filename: 'contacts.csv', type: "#{Mime[:csv]}; charset=utf-8"
|
send_data raw_csv, filename: 'contacts.csv', type: "#{Mime[:csv]}; charset=utf-8"
|
||||||
end
|
end
|
||||||
format.pdf do
|
format.pdf do
|
||||||
|
|
|
@ -10,27 +10,11 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def ident_for(contact)
|
def ident_for(contact)
|
||||||
if contact.is_a? Hash
|
ident = contact.ident
|
||||||
ident_country_code = contact[:ident_country_code]
|
description = "[#{contact.ident_country_code} #{contact.ident_type}]"
|
||||||
ident_type = contact[:ident_type]
|
description.prepend("#{ident} ") if ident.present?
|
||||||
ident = contact[:ident]
|
|
||||||
else
|
|
||||||
ident_country_code = contact.ident_country_code
|
|
||||||
ident_type = contact.ident_type
|
|
||||||
ident = contact.ident
|
|
||||||
end
|
|
||||||
|
|
||||||
case ident_type
|
description
|
||||||
when 'birthday'
|
|
||||||
"#{ident} [#{ident_country_code} #{ident_type}]"
|
|
||||||
else
|
|
||||||
if ident.present?
|
|
||||||
"#{ident} [#{ident_country_code} #{ident_type}]"
|
|
||||||
else
|
|
||||||
"[#{ident_country_code} #{ident_type}]"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_commit_link
|
def current_commit_link
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
module ObjectVersionsHelper
|
|
||||||
def attach_existing_fields(version, new_object)
|
|
||||||
version.object_changes.to_h.each do |key, value|
|
|
||||||
method_name = "#{key}=".to_sym
|
|
||||||
new_object.public_send(method_name, event_value(version, value)) if new_object.respond_to?(method_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def only_present_fields(version, model)
|
|
||||||
field_names = model.column_names
|
|
||||||
version.object.to_h.select { |key, _value| field_names.include?(key) }
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def event_value(version, val)
|
|
||||||
version.event == 'destroy' ? val.first : val.last
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,10 +0,0 @@
|
||||||
module ToCsv
|
|
||||||
def to_csv
|
|
||||||
CSV.generate do |csv|
|
|
||||||
csv << column_names
|
|
||||||
all.find_each do |item|
|
|
||||||
csv << item.attributes.values_at(*column_names)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +1,4 @@
|
||||||
class Account < ApplicationRecord
|
class Account < ApplicationRecord
|
||||||
extend ToCsv
|
|
||||||
include Versions
|
include Versions
|
||||||
|
|
||||||
belongs_to :registrar, required: true
|
belongs_to :registrar, required: true
|
||||||
|
@ -12,4 +11,12 @@ class Account < ApplicationRecord
|
||||||
def activities
|
def activities
|
||||||
account_activities
|
account_activities
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_csv_row
|
||||||
|
[id, balance, currency, registrar]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.csv_header
|
||||||
|
['Id', 'Balance', 'Currency', 'Registrar']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,7 @@ class AccountActivity < ApplicationRecord
|
||||||
UPDATE_CREDIT = 'update_credit'.freeze
|
UPDATE_CREDIT = 'update_credit'.freeze
|
||||||
|
|
||||||
after_create :update_balance
|
after_create :update_balance
|
||||||
|
|
||||||
def update_balance
|
def update_balance
|
||||||
account.balance += sum
|
account.balance += sum
|
||||||
account.save
|
account.save
|
||||||
|
@ -19,23 +20,17 @@ class AccountActivity < ApplicationRecord
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_csv_row
|
||||||
|
[account.registrar.try(:code), description, I18n.t(activity_type), I18n.l(created_at), sum]
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def types_for_select
|
def types_for_select
|
||||||
[CREATE, RENEW, ADD_CREDIT, UPDATE_CREDIT].map { |x| [I18n.t(x), x] }
|
[CREATE, RENEW, ADD_CREDIT, UPDATE_CREDIT].map { |x| [I18n.t(x), x] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_csv
|
def csv_header
|
||||||
attributes = %w(description activity_type created_at sum)
|
['Registrar', 'Description', 'Activity Type', 'Receipt Date', 'Sum']
|
||||||
|
|
||||||
CSV.generate(headers: true) do |csv|
|
|
||||||
csv << %w(registrar description activity_type receipt_date sum)
|
|
||||||
|
|
||||||
all.each do |x|
|
|
||||||
attrs = [x.account.registrar.try(:code)]
|
|
||||||
attrs += attributes.map { |attr| x.send(attr) }
|
|
||||||
csv << attrs
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
module ApiLog
|
module ApiLog
|
||||||
class EppLog < Db
|
class EppLog < Db; end
|
||||||
extend ToCsv
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
module ApiLog
|
module ApiLog
|
||||||
class ReppLog < Db
|
class ReppLog < Db; end
|
||||||
extend ToCsv
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
class BlockedDomain < ApplicationRecord
|
class BlockedDomain < ApplicationRecord
|
||||||
include Versions
|
include Versions
|
||||||
extend ToCsv
|
|
||||||
before_save :generate_data
|
before_save :generate_data
|
||||||
after_destroy :remove_data
|
after_destroy :remove_data
|
||||||
|
|
||||||
|
|
|
@ -188,15 +188,6 @@ class Contact < ApplicationRecord
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_csv
|
|
||||||
CSV.generate do |csv|
|
|
||||||
csv << column_names
|
|
||||||
all.each do |contact|
|
|
||||||
csv << contact.attributes.values_at(*column_names)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def pdf(html)
|
def pdf(html)
|
||||||
kit = PDFKit.new(html)
|
kit = PDFKit.new(html)
|
||||||
kit.to_pdf
|
kit.to_pdf
|
||||||
|
@ -569,4 +560,27 @@ class Contact < ApplicationRecord
|
||||||
def deletable?
|
def deletable?
|
||||||
!linked?
|
!linked?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ident_human_description
|
||||||
|
description = "[#{ident_country_code} #{ident_type}]"
|
||||||
|
description.prepend("#{ident} ") if ident.present?
|
||||||
|
|
||||||
|
description
|
||||||
|
end
|
||||||
|
|
||||||
|
def as_csv_row
|
||||||
|
[
|
||||||
|
name,
|
||||||
|
code,
|
||||||
|
ident_human_description,
|
||||||
|
email,
|
||||||
|
created_at.to_formatted_s(:db),
|
||||||
|
registrar,
|
||||||
|
phone,
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.csv_header
|
||||||
|
['Name', 'ID', 'Ident', 'E-mail', 'Created at', 'Registrar', 'Phone']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class Dispute < ApplicationRecord
|
class Dispute < ApplicationRecord
|
||||||
extend ToCsv
|
|
||||||
include WhoisStatusPopulate
|
include WhoisStatusPopulate
|
||||||
validates :domain_name, :password, :starts_at, :expires_at, presence: true
|
validates :domain_name, :password, :starts_at, :expires_at, presence: true
|
||||||
before_validation :fill_empty_passwords, :set_expiry_date
|
before_validation :fill_empty_passwords, :set_expiry_date
|
||||||
|
|
|
@ -289,21 +289,6 @@ class Domain < ApplicationRecord
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_csv
|
|
||||||
CSV.generate do |csv|
|
|
||||||
headers = column_names.dup
|
|
||||||
swap_elements(headers, [[0, 1], [1, 5]])
|
|
||||||
headers[0] = 'Domain'
|
|
||||||
headers[1] = headers[1].humanize
|
|
||||||
csv << headers
|
|
||||||
all.find_each do |item|
|
|
||||||
row = item.attributes.values_at(*column_names)
|
|
||||||
swap_elements(row, [[0, 1], [1, 5]])
|
|
||||||
csv << row
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def registrant_user_domains_by_registrant(registrant_user)
|
def registrant_user_domains_by_registrant(registrant_user)
|
||||||
|
@ -753,6 +738,38 @@ class Domain < ApplicationRecord
|
||||||
contacts.select(&:email_verification_failed?)&.map(&:email)&.uniq
|
contacts.select(&:email_verification_failed?)&.map(&:email)&.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_csv_row
|
||||||
|
[
|
||||||
|
name,
|
||||||
|
registrant_name,
|
||||||
|
valid_to.to_formatted_s(:db),
|
||||||
|
registrar,
|
||||||
|
created_at.to_formatted_s(:db),
|
||||||
|
statuses,
|
||||||
|
contacts.pluck(:code),
|
||||||
|
force_delete_date,
|
||||||
|
force_delete_data,
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def registrant_name
|
||||||
|
return registrant.name if registrant
|
||||||
|
|
||||||
|
ver = Version::ContactVersion.where(item_id: registrant_id).last
|
||||||
|
contact = Contact.all_versions_for([registrant_id], created_at).first
|
||||||
|
|
||||||
|
contact = ObjectVersionsParser.new(ver).parse if contact.nil? && ver
|
||||||
|
|
||||||
|
contact.try(:name) || 'Deleted'
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.csv_header
|
||||||
|
[
|
||||||
|
'Domain', 'Registrant', 'Valid to', 'Registrar', 'Created at',
|
||||||
|
'Statuses', 'Contacts code', 'Force delete date', 'Force delete data'
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
def self.pdf(html)
|
def self.pdf(html)
|
||||||
kit = PDFKit.new(html)
|
kit = PDFKit.new(html)
|
||||||
kit.to_pdf
|
kit.to_pdf
|
||||||
|
|
|
@ -3,7 +3,6 @@ class Invoice < ApplicationRecord
|
||||||
include Invoice::Cancellable
|
include Invoice::Cancellable
|
||||||
include Invoice::Payable
|
include Invoice::Payable
|
||||||
include Invoice::BookKeeping
|
include Invoice::BookKeeping
|
||||||
extend ToCsv
|
|
||||||
|
|
||||||
belongs_to :buyer, class_name: 'Registrar'
|
belongs_to :buyer, class_name: 'Registrar'
|
||||||
has_one :account_activity
|
has_one :account_activity
|
||||||
|
@ -117,6 +116,23 @@ class Invoice < ApplicationRecord
|
||||||
e_invoice_sent_at.present?
|
e_invoice_sent_at.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_csv_row
|
||||||
|
[
|
||||||
|
number,
|
||||||
|
buyer,
|
||||||
|
cancelled? ? I18n.t(:cancelled) : due_date,
|
||||||
|
receipt_date_status,
|
||||||
|
issue_date,
|
||||||
|
total,
|
||||||
|
currency,
|
||||||
|
seller_name,
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.csv_header
|
||||||
|
['Number', 'Buyer', 'Due Date', 'Receipt Date', 'Issue Date', 'Total', 'Currency', 'Seller Name']
|
||||||
|
end
|
||||||
|
|
||||||
def self.create_from_transaction!(transaction)
|
def self.create_from_transaction!(transaction)
|
||||||
registrar_user = Registrar.find_by(reference_no: transaction.parsed_ref_number)
|
registrar_user = Registrar.find_by(reference_no: transaction.parsed_ref_number)
|
||||||
return unless registrar_user
|
return unless registrar_user
|
||||||
|
@ -128,6 +144,16 @@ class Invoice < ApplicationRecord
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def receipt_date_status
|
||||||
|
if paid?
|
||||||
|
receipt_date
|
||||||
|
elsif cancelled?
|
||||||
|
I18n.t(:cancelled)
|
||||||
|
else
|
||||||
|
I18n.t(:unpaid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def apply_default_buyer_vat_no
|
def apply_default_buyer_vat_no
|
||||||
self.buyer_vat_no = buyer.vat_no
|
self.buyer_vat_no = buyer.vat_no
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,16 +20,27 @@ class RegistrantUser < User
|
||||||
def companies(company_register = CompanyRegister::Client.new)
|
def companies(company_register = CompanyRegister::Client.new)
|
||||||
return [] if ident.include?('-')
|
return [] if ident.include?('-')
|
||||||
|
|
||||||
companies = company_register.representation_rights(citizen_personal_code: ident,
|
company_register.representation_rights(citizen_personal_code: ident,
|
||||||
citizen_country_code: country.alpha3)
|
citizen_country_code: country.alpha3)
|
||||||
|
|
||||||
companies = update_contacts_before_receive(companies)
|
|
||||||
companies
|
|
||||||
rescue CompanyRegister::NotAvailableError
|
rescue CompanyRegister::NotAvailableError
|
||||||
return []
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_contacts_before_receive(companies)
|
def do_need_update_contact?
|
||||||
|
return { result: false, counter: 0 } if companies.blank?
|
||||||
|
|
||||||
|
counter = 0
|
||||||
|
companies.each do |company|
|
||||||
|
counter += Contact.where(ident: company.registration_number, ident_country_code: 'EE')&.
|
||||||
|
reject { |contact| contact.name == company.company_name }.size
|
||||||
|
end
|
||||||
|
|
||||||
|
return { result: true, counter: counter } if counter.positive?
|
||||||
|
|
||||||
|
{ result: false, counter: 0 }
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_company_contacts
|
||||||
return [] if companies.blank?
|
return [] if companies.blank?
|
||||||
|
|
||||||
companies.each do |company|
|
companies.each do |company|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class ReservedDomain < ApplicationRecord
|
class ReservedDomain < ApplicationRecord
|
||||||
extend ToCsv
|
|
||||||
include Versions # version/reserved_domain_version.rb
|
include Versions # version/reserved_domain_version.rb
|
||||||
include WhoisStatusPopulate
|
include WhoisStatusPopulate
|
||||||
before_save :fill_empty_passwords
|
before_save :fill_empty_passwords
|
||||||
|
|
|
@ -1,7 +1,23 @@
|
||||||
class Version::ContactVersion < PaperTrail::Version
|
class Version::ContactVersion < PaperTrail::Version
|
||||||
extend ToCsv
|
|
||||||
include VersionSession
|
include VersionSession
|
||||||
|
|
||||||
self.table_name = :log_contacts
|
self.table_name = :log_contacts
|
||||||
self.sequence_name = :log_contacts_id_seq
|
self.sequence_name = :log_contacts_id_seq
|
||||||
|
|
||||||
|
def as_csv_row
|
||||||
|
contact = ObjectVersionsParser.new(self).parse
|
||||||
|
|
||||||
|
[
|
||||||
|
contact.name,
|
||||||
|
contact.code,
|
||||||
|
contact.ident_human_description,
|
||||||
|
contact.registrar,
|
||||||
|
event,
|
||||||
|
created_at.to_formatted_s(:db)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.csv_header
|
||||||
|
['Name', 'ID', 'Ident', 'Registrar', 'Action', 'Created at']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class Version::DomainVersion < PaperTrail::Version
|
class Version::DomainVersion < PaperTrail::Version
|
||||||
extend ToCsv
|
|
||||||
include VersionSession
|
include VersionSession
|
||||||
|
|
||||||
self.table_name = :log_domains
|
self.table_name = :log_domains
|
||||||
|
@ -7,6 +6,18 @@ class Version::DomainVersion < PaperTrail::Version
|
||||||
|
|
||||||
scope :deleted, -> { where(event: 'destroy') }
|
scope :deleted, -> { where(event: 'destroy') }
|
||||||
|
|
||||||
|
def as_csv_row
|
||||||
|
domain = ObjectVersionsParser.new(self).parse
|
||||||
|
|
||||||
|
[
|
||||||
|
domain.name,
|
||||||
|
domain.registrant_name,
|
||||||
|
domain.registrar,
|
||||||
|
event,
|
||||||
|
created_at.to_formatted_s(:db)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
def self.was_contact_linked?(contact_id)
|
def self.was_contact_linked?(contact_id)
|
||||||
sql = <<-SQL
|
sql = <<-SQL
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -43,4 +54,8 @@ class Version::DomainVersion < PaperTrail::Version
|
||||||
|
|
||||||
count_by_sql(sql).nonzero?
|
count_by_sql(sql).nonzero?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.csv_header
|
||||||
|
['Name', 'Registrant', 'Registrar', 'Action', 'Created at']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
29
app/services/csv_generator.rb
Normal file
29
app/services/csv_generator.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
class CsvGenerator
|
||||||
|
class << self
|
||||||
|
def generate_csv(objects)
|
||||||
|
class_name = objects.first.class
|
||||||
|
return default_generation(objects) unless custom_csv?(class_name)
|
||||||
|
|
||||||
|
CSV.generate do |csv|
|
||||||
|
csv << class_name.csv_header
|
||||||
|
objects.each { |object| csv << object.as_csv_row }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def default_generation(objects)
|
||||||
|
CSV.generate do |csv|
|
||||||
|
csv << objects.column_names
|
||||||
|
objects.all.find_each { |object| csv << object.attributes.values_at(*objects.column_names) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def custom_csv?(class_name)
|
||||||
|
[
|
||||||
|
Version::DomainVersion, Version::ContactVersion, Domain,
|
||||||
|
Contact, Invoice, Account, AccountActivity
|
||||||
|
].include?(class_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
28
app/services/object_versions_parser.rb
Normal file
28
app/services/object_versions_parser.rb
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
class ObjectVersionsParser
|
||||||
|
def initialize(version)
|
||||||
|
@version = version
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse
|
||||||
|
model = @version.item_type.constantize
|
||||||
|
attributes = only_present_fields(model)
|
||||||
|
history_object = model.new(attributes)
|
||||||
|
attach_existing_fields(history_object) unless @version.event == 'destroy'
|
||||||
|
|
||||||
|
history_object
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def attach_existing_fields(history_object)
|
||||||
|
@version.object_changes.to_h.each do |key, value|
|
||||||
|
method_name = "#{key}=".to_sym
|
||||||
|
history_object.public_send(method_name, value.last) if history_object.respond_to?(method_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def only_present_fields(model)
|
||||||
|
field_names = model.column_names
|
||||||
|
@version.object.to_h.select { |key, _value| field_names.include?(key) }
|
||||||
|
end
|
||||||
|
end
|
|
@ -64,9 +64,7 @@
|
||||||
%tbody
|
%tbody
|
||||||
- @versions.each do |version|
|
- @versions.each do |version|
|
||||||
- if version
|
- if version
|
||||||
- attributes = only_present_fields(version, Contact)
|
- contact = ObjectVersionsParser.new(version).parse
|
||||||
- contact = Contact.new(attributes)
|
|
||||||
- attach_existing_fields(version, contact)
|
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%td= link_to(contact.name, admin_contact_version_path(version.id))
|
%td= link_to(contact.name, admin_contact_version_path(version.id))
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
- attributes = only_present_fields(@version, Contact)
|
- contact = ObjectVersionsParser.new(@version).parse
|
||||||
- contact = Contact.new(attributes)
|
|
||||||
- attach_existing_fields(@version, contact)
|
|
||||||
= render 'shared/title', name: contact.name
|
= render 'shared/title', name: contact.name
|
||||||
|
|
||||||
.row
|
.row
|
||||||
|
|
|
@ -62,9 +62,7 @@
|
||||||
%tbody
|
%tbody
|
||||||
- @versions.each do |version|
|
- @versions.each do |version|
|
||||||
- if version
|
- if version
|
||||||
- attributes = only_present_fields(version, Domain)
|
- domain = ObjectVersionsParser.new(version).parse
|
||||||
- domain = Domain.new(attributes)
|
|
||||||
- attach_existing_fields(version, domain) unless version.event == 'destroy'
|
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%td= link_to(domain.name, admin_domain_version_path(version.id))
|
%td= link_to(domain.name, admin_domain_version_path(version.id))
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
- present_fields = only_present_fields(@version, Domain)
|
- domain = ObjectVersionsParser.new(@version).parse
|
||||||
- domain = Domain.new(present_fields)
|
|
||||||
- attach_existing_fields(@version, domain) unless @version.event == 'destroy'
|
|
||||||
|
|
||||||
- if @version
|
- if @version
|
||||||
- children = HashWithIndifferentAccess.new(@version.children)
|
- children = HashWithIndifferentAccess.new(@version.children)
|
||||||
|
|
|
@ -128,7 +128,10 @@ Rails.application.routes.draw do
|
||||||
resources :domains, only: %i[index show], param: :uuid do
|
resources :domains, only: %i[index show], param: :uuid do
|
||||||
resource :registry_lock, only: %i[create destroy]
|
resource :registry_lock, only: %i[create destroy]
|
||||||
end
|
end
|
||||||
resources :contacts, only: %i[index show update], param: :uuid
|
resources :contacts, only: %i[index show update], param: :uuid do
|
||||||
|
get 'do_need_update_contact', to: 'contacts#do_need_update_contact', as: :do_need_update_contact
|
||||||
|
post 'update_company_contacts', to: 'contacts#update_company_contacts', as: :update_company_contacts
|
||||||
|
end
|
||||||
resources :companies, only: %i[index]
|
resources :companies, only: %i[index]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
4
test/fixtures/files/accounts.csv
vendored
Normal file
4
test/fixtures/files/accounts.csv
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Id,Balance,Currency,Registrar
|
||||||
|
112846265,100.0,EUR,Best Names
|
||||||
|
298486374,100.0,EUR,Good Names
|
||||||
|
597560588,0.0,EUR,Not in use
|
|
3
test/fixtures/files/contact_versions.csv
vendored
Normal file
3
test/fixtures/files/contact_versions.csv
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Name,ID,Ident,Registrar,Action,Created at
|
||||||
|
,test_code,[ ],Best Names,update,2018-04-23 15:50:48
|
||||||
|
,,[ ],,update,2010-07-04 21:00:00
|
|
2
test/fixtures/files/contacts.csv
vendored
Normal file
2
test/fixtures/files/contacts.csv
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Name,ID,Ident,E-mail,Created at,Registrar,Phone
|
||||||
|
Acme Ltd,acme-ltd-001,1234567 [US org],acme@outlook.test,2010-07-05 07:30:00,Best Names,+555.555
|
|
3
test/fixtures/files/domain_versions.csv
vendored
Normal file
3
test/fixtures/files/domain_versions.csv
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Name,Registrant,Registrar,Action,Created at
|
||||||
|
,test_code,Best Names,update,2018-04-23 15:50:48
|
||||||
|
,John,,update,2010-07-04 21:00:00
|
|
2
test/fixtures/files/domains.csv
vendored
Normal file
2
test/fixtures/files/domains.csv
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Domain,Registrant,Valid to,Registrar,Created at,Statuses,Contacts code,Force delete date,Force delete data
|
||||||
|
metro.test,Jack,2010-07-05 00:00:00,Good Names,2010-07-05 07:30:00,[],"[""jack-001"", ""jack-001""]",,
|
|
3
test/fixtures/files/invoices.csv
vendored
Normal file
3
test/fixtures/files/invoices.csv
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Number,Buyer,Due Date,Receipt Date,Issue Date,Total,Currency,Seller Name
|
||||||
|
2,Best Names,2010-07-06,Unpaid,2010-07-05,16.5,EUR,Seller Ltd
|
||||||
|
1,Best Names,2010-07-06,2010-07-05,2010-07-05,16.5,EUR,Seller Ltd
|
|
|
@ -41,10 +41,8 @@ class RegistrantUserTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
company = Company.new(org.ident, "ace")
|
company = Company.new(org.ident, "ace")
|
||||||
|
|
||||||
company_register = Minitest::Mock.new
|
Spy.on(@user, :companies).and_return([company])
|
||||||
company_register.expect(:representation_rights, [company], [{ citizen_personal_code: '1234',
|
@user.update_company_contacts
|
||||||
citizen_country_code: 'USA' }])
|
|
||||||
@user.companies(company_register)
|
|
||||||
org.reload
|
org.reload
|
||||||
|
|
||||||
assert_equal org.name, company.company_name
|
assert_equal org.name, company.company_name
|
||||||
|
@ -63,6 +61,39 @@ class RegistrantUserTest < ActiveSupport::TestCase
|
||||||
company_register.verify
|
company_register.verify
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_should_return_zero_count_of_companies
|
||||||
|
assert_equal 'US-1234', @user.registrant_ident
|
||||||
|
org = contacts(:acme_ltd)
|
||||||
|
org.ident_country_code = 'EE'
|
||||||
|
org.save(validate: false)
|
||||||
|
org.reload
|
||||||
|
|
||||||
|
company_one = Company.new(org.ident, 'Acme Ltd')
|
||||||
|
|
||||||
|
Spy.on(@user, :companies).and_return([company_one])
|
||||||
|
response = @user.do_need_update_contact?
|
||||||
|
org.reload
|
||||||
|
|
||||||
|
assert_equal response[:counter], 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_should_return_count_of_contact_which_should_be_updated
|
||||||
|
assert_equal 'US-1234', @user.registrant_ident
|
||||||
|
org = contacts(:acme_ltd)
|
||||||
|
org.ident_country_code = 'EE'
|
||||||
|
org.save(validate: false)
|
||||||
|
org.reload
|
||||||
|
|
||||||
|
company_one = Company.new(org.ident, 'ace')
|
||||||
|
company_two = Company.new(org.ident, 'acer')
|
||||||
|
|
||||||
|
Spy.on(@user, :companies).and_return([company_one, company_two])
|
||||||
|
response = @user.do_need_update_contact?
|
||||||
|
org.reload
|
||||||
|
|
||||||
|
assert_equal response[:counter], 2
|
||||||
|
end
|
||||||
|
|
||||||
def test_returns_contacts
|
def test_returns_contacts
|
||||||
Contact.stub(:registrant_user_contacts, %w(john jane)) do
|
Contact.stub(:registrant_user_contacts, %w(john jane)) do
|
||||||
assert_equal %w(john jane), @user.contacts
|
assert_equal %w(john jane), @user.contacts
|
||||||
|
|
|
@ -29,4 +29,16 @@ class AdminAccountsSystemTest < ApplicationSystemTestCase
|
||||||
assert_text 'Account has been successfully updated'
|
assert_text 'Account has been successfully updated'
|
||||||
assert_text '234'
|
assert_text '234'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_download_accounts_list_as_csv
|
||||||
|
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||||
|
|
||||||
|
get admin_accounts_path(format: :csv)
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
|
||||||
|
assert_equal %(attachment; filename="accounts_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''accounts_#{Time.zone.now.to_formatted_s(:number)}.csv),
|
||||||
|
response.headers['Content-Disposition']
|
||||||
|
assert_equal file_fixture('accounts.csv').read, response.body
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -62,11 +62,10 @@ class ContactVersionsTest < ApplicationSystemTestCase
|
||||||
travel_to now
|
travel_to now
|
||||||
|
|
||||||
get admin_contact_versions_path(format: :csv)
|
get admin_contact_versions_path(format: :csv)
|
||||||
|
|
||||||
assert_response :ok
|
assert_response :ok
|
||||||
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
|
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
|
||||||
assert_equal %(attachment; filename="contact_history_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''contact_history_#{Time.zone.now.to_formatted_s(:number)}.csv),
|
assert_equal %(attachment; filename="contact_history_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''contact_history_#{Time.zone.now.to_formatted_s(:number)}.csv),
|
||||||
response.headers['Content-Disposition']
|
response.headers['Content-Disposition']
|
||||||
assert_not_empty response.body
|
assert_equal file_fixture('contact_versions.csv').read, response.body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
22
test/system/admin_area/contacts/csv_test.rb
Normal file
22
test/system/admin_area/contacts/csv_test.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
require 'application_system_test_case'
|
||||||
|
|
||||||
|
class ContactsCsvTest < ApplicationSystemTestCase
|
||||||
|
setup do
|
||||||
|
sign_in users(:admin)
|
||||||
|
Domain.destroy_all
|
||||||
|
Contact.all.each { |contact| contact.destroy unless contact.name == 'Acme Ltd' }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_download_contacts_list_as_csv
|
||||||
|
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||||
|
contact = Contact.first
|
||||||
|
contact.created_at = Time.zone.now
|
||||||
|
contact.save(validate: false)
|
||||||
|
|
||||||
|
visit admin_contacts_url
|
||||||
|
click_link('CSV')
|
||||||
|
|
||||||
|
assert_equal "attachment; filename=\"contacts_#{Time.zone.now.to_formatted_s(:number)}.csv\"; filename*=UTF-8''contacts_#{Time.zone.now.to_formatted_s(:number)}.csv", response_headers['Content-Disposition']
|
||||||
|
assert_equal file_fixture('contacts.csv').read, page.body
|
||||||
|
end
|
||||||
|
end
|
|
@ -98,7 +98,7 @@ class DomainVersionsTest < ApplicationSystemTestCase
|
||||||
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
|
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
|
||||||
assert_equal %(attachment; filename="domain_history_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''domain_history_#{Time.zone.now.to_formatted_s(:number)}.csv),
|
assert_equal %(attachment; filename="domain_history_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''domain_history_#{Time.zone.now.to_formatted_s(:number)}.csv),
|
||||||
response.headers['Content-Disposition']
|
response.headers['Content-Disposition']
|
||||||
assert_not_empty response.body
|
assert_equal file_fixture('domain_versions.csv').read, response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_search_event_param
|
def test_search_event_param
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
require 'application_system_test_case'
|
require 'application_system_test_case'
|
||||||
|
|
||||||
class AdminAreaCsvTest < ApplicationSystemTestCase
|
class DomainsCsvTest < ApplicationSystemTestCase
|
||||||
setup do
|
setup do
|
||||||
sign_in users(:admin)
|
sign_in users(:admin)
|
||||||
|
Domain.all.each { |domain| domain.destroy unless domain.name == 'metro.test' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_downloads_domain_list_as_csv
|
def test_download_domains_list_as_csv
|
||||||
search_params = {"valid_to_lteq"=>nil}
|
|
||||||
expected_csv = Domain.includes(:registrar, :registrant).search(search_params).result.to_csv
|
|
||||||
|
|
||||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||||
|
domain = Domain.first
|
||||||
|
domain.created_at = Time.zone.now
|
||||||
|
domain.save(validate: false)
|
||||||
|
|
||||||
visit admin_domains_url
|
visit admin_domains_url
|
||||||
click_link('CSV')
|
click_link('CSV')
|
||||||
|
|
||||||
assert_equal "attachment; filename=\"domains_#{Time.zone.now.to_formatted_s(:number)}.csv\"; filename*=UTF-8''domains_#{Time.zone.now.to_formatted_s(:number)}.csv", response_headers['Content-Disposition']
|
assert_equal "attachment; filename=\"domains_#{Time.zone.now.to_formatted_s(:number)}.csv\"; filename*=UTF-8''domains_#{Time.zone.now.to_formatted_s(:number)}.csv", response_headers['Content-Disposition']
|
||||||
assert_equal expected_csv, page.body
|
assert_equal file_fixture('domains.csv').read, page.body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,4 +40,14 @@ class AdminAreaInvoicesTest < ApplicationSystemTestCase
|
||||||
assert_current_path admin_invoice_path(@invoice)
|
assert_current_path admin_invoice_path(@invoice)
|
||||||
assert_text 'Invoice has been sent'
|
assert_text 'Invoice has been sent'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_download_invoices_list_as_csv
|
||||||
|
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||||
|
|
||||||
|
visit admin_invoices_url
|
||||||
|
click_link('CSV')
|
||||||
|
|
||||||
|
assert_equal "attachment; filename=\"invoices_#{Time.zone.now.to_formatted_s(:number)}.csv\"; filename*=UTF-8''invoices_#{Time.zone.now.to_formatted_s(:number)}.csv", response_headers['Content-Disposition']
|
||||||
|
assert_equal file_fixture('invoices.csv').read, page.body
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue