mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
Merge branch 'master' of github.com:domify/registry into registrar-portal
Conflicts: .travis.yml
This commit is contained in:
commit
57d239ccd1
9 changed files with 84 additions and 41 deletions
|
@ -17,6 +17,7 @@ before_script:
|
||||||
- cp config/database-travis.yml config/database.yml
|
- cp config/database-travis.yml config/database.yml
|
||||||
- RAILS_ENV=test bundle exec rake db:all:schema:load
|
- RAILS_ENV=test bundle exec rake db:all:schema:load
|
||||||
- RAILS_ENV=test bundle exec rake db:seed
|
- RAILS_ENV=test bundle exec rake db:seed
|
||||||
|
- RAILS_ENV=test bundle exec rake zonefile:replace_procedure
|
||||||
script:
|
script:
|
||||||
- RAILS_ENV=test bundle exec rake
|
- RAILS_ENV=test bundle exec rake
|
||||||
cache: bundler
|
cache: bundler
|
||||||
|
|
|
@ -17,4 +17,20 @@ module ApplicationHelper
|
||||||
"#{contact.ident} [#{contact.ident_country_code} #{contact.ident_type}]"
|
"#{contact.ident} [#{contact.ident_country_code} #{contact.ident_type}]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def creator_link(model)
|
||||||
|
return 'not present' if model.blank?
|
||||||
|
return model.creator if model.creator.is_a? String
|
||||||
|
|
||||||
|
# can be api user or some other user
|
||||||
|
link_to(model.creator, ['admin', model.creator])
|
||||||
|
end
|
||||||
|
|
||||||
|
def updator_link(model)
|
||||||
|
return 'not present' if model.blank?
|
||||||
|
return model.updator if model.updator.is_a? String
|
||||||
|
|
||||||
|
# can be api user or some other user
|
||||||
|
link_to(model.updator, ['admin', model.updator])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,20 +28,24 @@ module Versions
|
||||||
return nil if creator_str.blank?
|
return nil if creator_str.blank?
|
||||||
|
|
||||||
if creator_str =~ /^\d-api-/
|
if creator_str =~ /^\d-api-/
|
||||||
ApiUser.find_by(id: creator_str)
|
creator = ApiUser.find_by(id: creator_str)
|
||||||
else
|
else
|
||||||
AdminUser.find_by(id: creator_str)
|
creator = AdminUser.find_by(id: creator_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
creator.present? ? creator : creator_str
|
||||||
end
|
end
|
||||||
|
|
||||||
def updator
|
def updator
|
||||||
return nil if updator_str.blank?
|
return nil if updator_str.blank?
|
||||||
|
|
||||||
if updator_str =~ /^\d-api-/
|
if updator_str =~ /^\d-api-/
|
||||||
ApiUser.find_by(id: updator_str)
|
updator = ApiUser.find_by(id: updator_str)
|
||||||
else
|
else
|
||||||
AdminUser.find_by(id: updator_str)
|
updator = AdminUser.find_by(id: updator_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
updator.present? ? updator : updator_str
|
||||||
end
|
end
|
||||||
|
|
||||||
# callbacks
|
# callbacks
|
||||||
|
|
|
@ -116,7 +116,7 @@ class Contact < ActiveRecord::Base
|
||||||
|
|
||||||
def generate_auth_info
|
def generate_auth_info
|
||||||
return if @generate_auth_info_disabled
|
return if @generate_auth_info_disabled
|
||||||
self.auth_info = SecureRandom.hex(16)
|
self.auth_info = SecureRandom.hex(11)
|
||||||
end
|
end
|
||||||
|
|
||||||
def disable_generate_auth_info! # needed for testing
|
def disable_generate_auth_info! # needed for testing
|
||||||
|
|
|
@ -32,18 +32,15 @@
|
||||||
%dd
|
%dd
|
||||||
= l(@contact.created_at, format: :short)
|
= l(@contact.created_at, format: :short)
|
||||||
by
|
by
|
||||||
= link_to(@contact.creator, [:admin, @contact.creator])
|
= creator_link(@contact)
|
||||||
|
|
||||||
%dt= t(:updated)
|
%dt= t(:updated)
|
||||||
%dd
|
%dd
|
||||||
= l(@contact.updated_at, format: :short)
|
= l(@contact.updated_at, format: :short)
|
||||||
by
|
by
|
||||||
= link_to(@contact.updator, [:admin, @contact.updator])
|
= updator_link(@contact)
|
||||||
|
|
||||||
|
|
||||||
%dt= t(:registrar)
|
%dt= t(:registrar)
|
||||||
%dd
|
%dd
|
||||||
- if @contact.registrar.present?
|
- if @contact.registrar.present?
|
||||||
= link_to(@contact.registrar, admin_registrar_path(@contact.registrar))
|
= link_to(@contact.registrar, admin_registrar_path(@contact.registrar))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
# otherwise rake not working 100%
|
# otherwise rake not working 100%
|
||||||
con = ActiveRecord::Base.connection
|
begin
|
||||||
|
con = ActiveRecord::Base.connection
|
||||||
|
rescue ActiveRecord::NoDatabaseError => e
|
||||||
|
Rails.logger.info "Init settings didn't find database: #{e}"
|
||||||
|
end
|
||||||
|
|
||||||
if con.present? && con.table_exists?('settings')
|
if con.present? && con.table_exists?('settings')
|
||||||
Setting.disclosure_name = true if Setting.disclosure_name.nil?
|
Setting.disclosure_name = true if Setting.disclosure_name.nil?
|
||||||
Setting.disclosure_name = true if Setting.disclosure_name.nil?
|
Setting.disclosure_name = true if Setting.disclosure_name.nil?
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
namespace :db do
|
namespace :db do
|
||||||
def other_databases
|
def databases
|
||||||
@db ||= ["api_log_#{Rails.env}", "whois_#{Rails.env}"]
|
@db ||= [Rails.env, "api_log_#{Rails.env}", "whois_#{Rails.env}"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def schema_file(db)
|
def schema_file(db)
|
||||||
case db
|
case db
|
||||||
|
when Rails.env
|
||||||
|
'schema.rb'
|
||||||
when "api_log_#{Rails.env}"
|
when "api_log_#{Rails.env}"
|
||||||
'api_log_schema.rb'
|
'api_log_schema.rb'
|
||||||
when "whois_#{Rails.env}"
|
when "whois_#{Rails.env}"
|
||||||
|
@ -14,28 +16,31 @@ namespace :db do
|
||||||
|
|
||||||
namespace :all do
|
namespace :all do
|
||||||
desc 'Create all databases: registry, api_log and whois'
|
desc 'Create all databases: registry, api_log and whois'
|
||||||
task setup: [:environment] do
|
task setup: [:environment, :load_config] do
|
||||||
Rake::Task['db:all:create'].invoke
|
Rake::Task['db:all:create'].invoke
|
||||||
Rake::Task['db:all:schema:load'].invoke
|
Rake::Task['db:all:schema:load'].invoke
|
||||||
|
|
||||||
ActiveRecord::Base.clear_all_connections!
|
ActiveRecord::Base.clear_all_connections!
|
||||||
ActiveRecord::Base.establish_connection(Rails.env.to_sym)
|
ActiveRecord::Base.establish_connection(Rails.env.to_sym)
|
||||||
# puts "\n---------------------------- Import seed ----------------------------------------\n"
|
|
||||||
# Rake::Task['db:seed'].invoke
|
puts "\n---------------------------- Import seed ----------------------------------------\n"
|
||||||
|
Rake::Task['db:seed'].invoke
|
||||||
puts "\n All done!\n\n"
|
puts "\n All done!\n\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Create all databases: registry, api_log and whois'
|
desc 'Create all databases: registry, api_log and whois'
|
||||||
task create: [:environment] do
|
task create: [:environment, :load_config] do
|
||||||
puts "\n---------------------------- Create main database ----------------------------------------\n"
|
databases.each do |name|
|
||||||
Rake::Task['db:create'].invoke
|
|
||||||
|
|
||||||
other_databases.each do |name|
|
|
||||||
begin
|
begin
|
||||||
puts "\n---------------------------- Create #{name} ----------------------------------------\n"
|
puts "\n---------------------------- Create #{name} ----------------------------------------\n"
|
||||||
ActiveRecord::Base.clear_all_connections!
|
ActiveRecord::Base.clear_all_connections!
|
||||||
conf = ActiveRecord::Base.configurations
|
conf = ActiveRecord::Base.configurations
|
||||||
|
|
||||||
|
if name == Rails.env
|
||||||
|
ActiveRecord::Tasks::DatabaseTasks.create_current
|
||||||
|
else
|
||||||
ActiveRecord::Base.connection.create_database(conf[name]['database'].to_sym, conf[name])
|
ActiveRecord::Base.connection.create_database(conf[name]['database'].to_sym, conf[name])
|
||||||
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
puts "\n#{e}"
|
puts "\n#{e}"
|
||||||
end
|
end
|
||||||
|
@ -43,15 +48,11 @@ namespace :db do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Drop all databaseses: registry, api_log and whois'
|
desc 'Drop all databaseses: registry, api_log and whois'
|
||||||
task drop: [:environment] do
|
task drop: [:environment, :load_config] do
|
||||||
# just in case we allow only drop test, comment it out please for temp
|
# just in case we allow only drop test, comment it out only for temp
|
||||||
return unless Rails.env.test?
|
return unless Rails.env.test?
|
||||||
|
|
||||||
Rake::Task['db:drop'].invoke
|
databases.each do |name|
|
||||||
conf = ActiveRecord::Base.configurations
|
|
||||||
puts "#{conf[Rails.env]['database']} dropped"
|
|
||||||
|
|
||||||
other_databases.each do |name|
|
|
||||||
begin
|
begin
|
||||||
ActiveRecord::Base.clear_all_connections!
|
ActiveRecord::Base.clear_all_connections!
|
||||||
ActiveRecord::Base.establish_connection(name.to_sym)
|
ActiveRecord::Base.establish_connection(name.to_sym)
|
||||||
|
@ -70,11 +71,8 @@ namespace :db do
|
||||||
|
|
||||||
namespace :schema do
|
namespace :schema do
|
||||||
desc 'Schema load for all databases: registry, api_log and whois'
|
desc 'Schema load for all databases: registry, api_log and whois'
|
||||||
task load: [:environment] do
|
task load: [:environment, :load_config] do
|
||||||
puts "\n---------------------------- Main schema load ----------------------------------------\n"
|
databases.each do |name|
|
||||||
Rake::Task['db:schema:load'].invoke
|
|
||||||
|
|
||||||
other_databases.each do |name|
|
|
||||||
begin
|
begin
|
||||||
puts "\n---------------------------- #{name} schema loaded ----------------------------------------\n"
|
puts "\n---------------------------- #{name} schema loaded ----------------------------------------\n"
|
||||||
ActiveRecord::Base.clear_all_connections!
|
ActiveRecord::Base.clear_all_connections!
|
||||||
|
@ -91,11 +89,8 @@ namespace :db do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Schema load for all databases: registry, api_log and whois'
|
desc 'Schema load for all databases: registry, api_log and whois'
|
||||||
task dump: [:environment] do
|
task dump: [:environment, :load_config] do
|
||||||
puts "\n---------------------------- Main schema load ----------------------------------------\n"
|
databases.each do |name|
|
||||||
Rake::Task['db:schema:dump'].invoke
|
|
||||||
|
|
||||||
other_databases.each do |name|
|
|
||||||
begin
|
begin
|
||||||
puts "\n---------------------------- #{name} ----------------------------------------\n"
|
puts "\n---------------------------- #{name} ----------------------------------------\n"
|
||||||
filename = "#{Rails.root}/db/#{schema_file(name)}"
|
filename = "#{Rails.root}/db/#{schema_file(name)}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Fabricator(:contact) do
|
Fabricator(:contact) do
|
||||||
code { "sh#{Faker::Number.number(8)}" }
|
code { sequence(:code) { |i| "sh#{Faker::Number.number(8)}#{i}" } }
|
||||||
auth_info 'password'
|
auth_info 'password'
|
||||||
name { sequence(:name) { |i| "#{Faker::Name.name}#{i}" } }
|
name { sequence(:name) { |i| "#{Faker::Name.name}#{i}" } }
|
||||||
phone '+372.12345678'
|
phone '+372.12345678'
|
||||||
|
@ -8,7 +8,7 @@ Fabricator(:contact) do
|
||||||
ident_type 'priv'
|
ident_type 'priv'
|
||||||
ident_country_code 'EE'
|
ident_country_code 'EE'
|
||||||
address
|
address
|
||||||
registrar { Fabricate(:registrar, name: Faker::Company.name, reg_no: Faker::Company.duns_number) }
|
registrar { Fabricate(:registrar) }
|
||||||
disclosure { Fabricate(:contact_disclosure) }
|
disclosure { Fabricate(:contact_disclosure) }
|
||||||
# rubocop: disable Style/SymbolProc
|
# rubocop: disable Style/SymbolProc
|
||||||
after_validation { |c| c.disable_generate_auth_info! }
|
after_validation { |c| c.disable_generate_auth_info! }
|
||||||
|
|
25
spec/features/admin/contact_spec.rb
Normal file
25
spec/features/admin/contact_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
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')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should show index of contacts' do
|
||||||
|
sign_in @user
|
||||||
|
visit admin_contacts_url
|
||||||
|
|
||||||
|
page.should have_content('Mr John')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should show correct contact creator' do
|
||||||
|
sign_in @user
|
||||||
|
visit admin_contacts_url
|
||||||
|
|
||||||
|
click_link('Mr John')
|
||||||
|
page.should have_content('by autotest')
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue