mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +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
|
||||
- RAILS_ENV=test bundle exec rake db:all:schema:load
|
||||
- RAILS_ENV=test bundle exec rake db:seed
|
||||
- RAILS_ENV=test bundle exec rake zonefile:replace_procedure
|
||||
script:
|
||||
- RAILS_ENV=test bundle exec rake
|
||||
cache: bundler
|
||||
|
|
|
@ -17,4 +17,20 @@ module ApplicationHelper
|
|||
"#{contact.ident} [#{contact.ident_country_code} #{contact.ident_type}]"
|
||||
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
|
||||
|
|
|
@ -28,20 +28,24 @@ module Versions
|
|||
return nil if creator_str.blank?
|
||||
|
||||
if creator_str =~ /^\d-api-/
|
||||
ApiUser.find_by(id: creator_str)
|
||||
creator = ApiUser.find_by(id: creator_str)
|
||||
else
|
||||
AdminUser.find_by(id: creator_str)
|
||||
creator = AdminUser.find_by(id: creator_str)
|
||||
end
|
||||
|
||||
creator.present? ? creator : creator_str
|
||||
end
|
||||
|
||||
def updator
|
||||
return nil if updator_str.blank?
|
||||
|
||||
if updator_str =~ /^\d-api-/
|
||||
ApiUser.find_by(id: updator_str)
|
||||
updator = ApiUser.find_by(id: updator_str)
|
||||
else
|
||||
AdminUser.find_by(id: updator_str)
|
||||
updator = AdminUser.find_by(id: updator_str)
|
||||
end
|
||||
|
||||
updator.present? ? updator : updator_str
|
||||
end
|
||||
|
||||
# callbacks
|
||||
|
|
|
@ -116,7 +116,7 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
def generate_auth_info
|
||||
return if @generate_auth_info_disabled
|
||||
self.auth_info = SecureRandom.hex(16)
|
||||
self.auth_info = SecureRandom.hex(11)
|
||||
end
|
||||
|
||||
def disable_generate_auth_info! # needed for testing
|
||||
|
|
|
@ -32,18 +32,15 @@
|
|||
%dd
|
||||
= l(@contact.created_at, format: :short)
|
||||
by
|
||||
= link_to(@contact.creator, [:admin, @contact.creator])
|
||||
= creator_link(@contact)
|
||||
|
||||
%dt= t(:updated)
|
||||
%dd
|
||||
= l(@contact.updated_at, format: :short)
|
||||
by
|
||||
= link_to(@contact.updator, [:admin, @contact.updator])
|
||||
|
||||
= updator_link(@contact)
|
||||
|
||||
%dt= t(:registrar)
|
||||
%dd
|
||||
- if @contact.registrar.present?
|
||||
= link_to(@contact.registrar, admin_registrar_path(@contact.registrar))
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# 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')
|
||||
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
|
||||
def other_databases
|
||||
@db ||= ["api_log_#{Rails.env}", "whois_#{Rails.env}"]
|
||||
def databases
|
||||
@db ||= [Rails.env, "api_log_#{Rails.env}", "whois_#{Rails.env}"]
|
||||
end
|
||||
|
||||
def schema_file(db)
|
||||
case db
|
||||
when Rails.env
|
||||
'schema.rb'
|
||||
when "api_log_#{Rails.env}"
|
||||
'api_log_schema.rb'
|
||||
when "whois_#{Rails.env}"
|
||||
|
@ -14,28 +16,31 @@ namespace :db do
|
|||
|
||||
namespace :all do
|
||||
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:schema:load'].invoke
|
||||
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
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"
|
||||
end
|
||||
|
||||
desc 'Create all databases: registry, api_log and whois'
|
||||
task create: [:environment] do
|
||||
puts "\n---------------------------- Create main database ----------------------------------------\n"
|
||||
Rake::Task['db:create'].invoke
|
||||
|
||||
other_databases.each do |name|
|
||||
task create: [:environment, :load_config] do
|
||||
databases.each do |name|
|
||||
begin
|
||||
puts "\n---------------------------- Create #{name} ----------------------------------------\n"
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
conf = ActiveRecord::Base.configurations
|
||||
ActiveRecord::Base.connection.create_database(conf[name]['database'].to_sym, conf[name])
|
||||
|
||||
if name == Rails.env
|
||||
ActiveRecord::Tasks::DatabaseTasks.create_current
|
||||
else
|
||||
ActiveRecord::Base.connection.create_database(conf[name]['database'].to_sym, conf[name])
|
||||
end
|
||||
rescue => e
|
||||
puts "\n#{e}"
|
||||
end
|
||||
|
@ -43,15 +48,11 @@ namespace :db do
|
|||
end
|
||||
|
||||
desc 'Drop all databaseses: registry, api_log and whois'
|
||||
task drop: [:environment] do
|
||||
# just in case we allow only drop test, comment it out please for temp
|
||||
task drop: [:environment, :load_config] do
|
||||
# just in case we allow only drop test, comment it out only for temp
|
||||
return unless Rails.env.test?
|
||||
|
||||
Rake::Task['db:drop'].invoke
|
||||
conf = ActiveRecord::Base.configurations
|
||||
puts "#{conf[Rails.env]['database']} dropped"
|
||||
|
||||
other_databases.each do |name|
|
||||
databases.each do |name|
|
||||
begin
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
ActiveRecord::Base.establish_connection(name.to_sym)
|
||||
|
@ -70,11 +71,8 @@ namespace :db do
|
|||
|
||||
namespace :schema do
|
||||
desc 'Schema load for all databases: registry, api_log and whois'
|
||||
task load: [:environment] do
|
||||
puts "\n---------------------------- Main schema load ----------------------------------------\n"
|
||||
Rake::Task['db:schema:load'].invoke
|
||||
|
||||
other_databases.each do |name|
|
||||
task load: [:environment, :load_config] do
|
||||
databases.each do |name|
|
||||
begin
|
||||
puts "\n---------------------------- #{name} schema loaded ----------------------------------------\n"
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
|
@ -91,11 +89,8 @@ namespace :db do
|
|||
end
|
||||
|
||||
desc 'Schema load for all databases: registry, api_log and whois'
|
||||
task dump: [:environment] do
|
||||
puts "\n---------------------------- Main schema load ----------------------------------------\n"
|
||||
Rake::Task['db:schema:dump'].invoke
|
||||
|
||||
other_databases.each do |name|
|
||||
task dump: [:environment, :load_config] do
|
||||
databases.each do |name|
|
||||
begin
|
||||
puts "\n---------------------------- #{name} ----------------------------------------\n"
|
||||
filename = "#{Rails.root}/db/#{schema_file(name)}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Fabricator(:contact) do
|
||||
code { "sh#{Faker::Number.number(8)}" }
|
||||
code { sequence(:code) { |i| "sh#{Faker::Number.number(8)}#{i}" } }
|
||||
auth_info 'password'
|
||||
name { sequence(:name) { |i| "#{Faker::Name.name}#{i}" } }
|
||||
phone '+372.12345678'
|
||||
|
@ -8,7 +8,7 @@ Fabricator(:contact) do
|
|||
ident_type 'priv'
|
||||
ident_country_code 'EE'
|
||||
address
|
||||
registrar { Fabricate(:registrar, name: Faker::Company.name, reg_no: Faker::Company.duns_number) }
|
||||
registrar { Fabricate(:registrar) }
|
||||
disclosure { Fabricate(:contact_disclosure) }
|
||||
# rubocop: disable Style/SymbolProc
|
||||
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