mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Merge pull request #1451 from internetee/improve-legal-documents
Improve legal documents
This commit is contained in:
commit
3836dcdf46
12 changed files with 42 additions and 17 deletions
|
@ -21,8 +21,6 @@ class Contact < ApplicationRecord
|
||||||
alias_attribute :kind, :ident_type
|
alias_attribute :kind, :ident_type
|
||||||
alias_attribute :copy_from_id, :original_id # Old attribute name; for PaperTrail
|
alias_attribute :copy_from_id, :original_id # Old attribute name; for PaperTrail
|
||||||
|
|
||||||
accepts_nested_attributes_for :legal_documents
|
|
||||||
|
|
||||||
scope :email_verification_failed, lambda {
|
scope :email_verification_failed, lambda {
|
||||||
joins('LEFT JOIN email_address_verifications emv ON contacts.email = emv.email')
|
joins('LEFT JOIN email_address_verifications emv ON contacts.email = emv.email')
|
||||||
.where('success = false and verified_at IS NOT NULL')
|
.where('success = false and verified_at IS NOT NULL')
|
||||||
|
|
|
@ -55,7 +55,6 @@ class Domain < ApplicationRecord
|
||||||
accepts_nested_attributes_for :dnskeys, allow_destroy: true
|
accepts_nested_attributes_for :dnskeys, allow_destroy: true
|
||||||
|
|
||||||
has_many :legal_documents, as: :documentable
|
has_many :legal_documents, as: :documentable
|
||||||
accepts_nested_attributes_for :legal_documents, reject_if: proc { |attrs| attrs[:body].blank? }
|
|
||||||
has_many :registrant_verifications, dependent: :destroy
|
has_many :registrant_verifications, dependent: :destroy
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class LegalDocument < ApplicationRecord
|
class LegalDocument < ApplicationRecord
|
||||||
cattr_accessor :explicitly_write_file
|
|
||||||
include EppErrors
|
include EppErrors
|
||||||
MIN_BODY_SIZE = (1.37 * 3.kilobytes).ceil
|
MIN_BODY_SIZE = (1.37 * 3.kilobytes).ceil
|
||||||
|
|
||||||
|
@ -44,7 +43,7 @@ class LegalDocument < ApplicationRecord
|
||||||
break unless File.file?(path)
|
break unless File.file?(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
File.open(path, 'wb') { |f| f.write(binary) } if !Rails.env.test? || self.class.explicitly_write_file
|
File.open(path, 'wb') { |f| f.write(binary) } unless Rails.env.test?
|
||||||
self.path = path
|
self.path = path
|
||||||
self.checksum = digest
|
self.checksum = digest
|
||||||
end
|
end
|
||||||
|
|
|
@ -202,7 +202,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :zonefiles
|
resources :zonefiles
|
||||||
resources :zones, controller: 'dns/zones', except: %i[show destroy]
|
resources :zones, controller: 'dns/zones', except: %i[show destroy]
|
||||||
resources :legal_documents
|
resources :legal_documents, only: :show
|
||||||
resources :prices, controller: 'billing/prices', except: %i[show destroy] do
|
resources :prices, controller: 'billing/prices', except: %i[show destroy] do
|
||||||
member do
|
member do
|
||||||
patch :expire
|
patch :expire
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeLegalDocumentsPathToNotNull < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
change_column_null :legal_documents, :path, false
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeLegalDocumentsDocumentTypeToNotNull < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
change_column_null :legal_documents, :document_type, false
|
||||||
|
end
|
||||||
|
end
|
|
@ -1069,12 +1069,12 @@ ALTER SEQUENCE public.invoices_id_seq OWNED BY public.invoices.id;
|
||||||
|
|
||||||
CREATE TABLE public.legal_documents (
|
CREATE TABLE public.legal_documents (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
document_type character varying,
|
document_type character varying NOT NULL,
|
||||||
documentable_id integer,
|
documentable_id integer,
|
||||||
documentable_type character varying,
|
documentable_type character varying,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
creator_str character varying,
|
creator_str character varying,
|
||||||
path character varying,
|
path character varying NOT NULL,
|
||||||
checksum character varying
|
checksum character varying
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4828,6 +4828,8 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20191203083643'),
|
('20191203083643'),
|
||||||
('20191206183853'),
|
('20191206183853'),
|
||||||
('20191212133136'),
|
('20191212133136'),
|
||||||
|
('20191219112434'),
|
||||||
|
('20191219124429'),
|
||||||
('20191227110904'),
|
('20191227110904'),
|
||||||
('20200113091254'),
|
('20200113091254'),
|
||||||
('20200115102202'),
|
('20200115102202'),
|
||||||
|
@ -4849,5 +4851,3 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20200811074839'),
|
('20200811074839'),
|
||||||
('20200812090409'),
|
('20200812090409'),
|
||||||
('20200812125810');
|
('20200812125810');
|
||||||
|
|
||||||
|
|
||||||
|
|
4
test/fixtures/legal_documents.yml
vendored
Normal file
4
test/fixtures/legal_documents.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
one:
|
||||||
|
documentable: shop (Domain)
|
||||||
|
document_type: pdf
|
||||||
|
path: some
|
|
@ -27,7 +27,7 @@ class EppDomainDeleteBaseTest < EppTestCase
|
||||||
</delete>
|
</delete>
|
||||||
<extension>
|
<extension>
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||||
<eis:legalDocument type="pdf">dGVzdCBmYWlsCg==</eis:legalDocument>
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||||
</eis:extdata>
|
</eis:extdata>
|
||||||
</extension>
|
</extension>
|
||||||
</command>
|
</command>
|
||||||
|
@ -35,6 +35,7 @@ class EppDomainDeleteBaseTest < EppTestCase
|
||||||
XML
|
XML
|
||||||
|
|
||||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
|
# binding.pry
|
||||||
assert_includes Domain.find_by(name: 'invalid.test').statuses, DomainStatus::PENDING_DELETE_CONFIRMATION
|
assert_includes Domain.find_by(name: 'invalid.test').statuses, DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||||
assert_epp_response :completed_successfully_action_pending
|
assert_epp_response :completed_successfully_action_pending
|
||||||
end
|
end
|
||||||
|
@ -54,7 +55,7 @@ class EppDomainDeleteBaseTest < EppTestCase
|
||||||
</delete>
|
</delete>
|
||||||
<extension>
|
<extension>
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||||
<eis:legalDocument type="pdf">dGVzdCBmYWlsCg==</eis:legalDocument>
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||||
</eis:extdata>
|
</eis:extdata>
|
||||||
</extension>
|
</extension>
|
||||||
</command>
|
</command>
|
||||||
|
@ -82,7 +83,7 @@ class EppDomainDeleteBaseTest < EppTestCase
|
||||||
</delete>
|
</delete>
|
||||||
<extension>
|
<extension>
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||||
<eis:legalDocument type="pdf">dGVzdCBmYWlsCg==</eis:legalDocument>
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||||
</eis:extdata>
|
</eis:extdata>
|
||||||
</extension>
|
</extension>
|
||||||
</command>
|
</command>
|
||||||
|
@ -113,7 +114,7 @@ class EppDomainDeleteBaseTest < EppTestCase
|
||||||
</delete>
|
</delete>
|
||||||
<extension>
|
<extension>
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||||
<eis:legalDocument type="pdf">dGVzdCBmYWlsCg==</eis:legalDocument>
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||||
</eis:extdata>
|
</eis:extdata>
|
||||||
</extension>
|
</extension>
|
||||||
</command>
|
</command>
|
||||||
|
@ -144,7 +145,7 @@ class EppDomainDeleteBaseTest < EppTestCase
|
||||||
</delete>
|
</delete>
|
||||||
<extension>
|
<extension>
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||||
<eis:legalDocument type="pdf">dGVzdCBmYWlsCg==</eis:legalDocument>
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||||
</eis:extdata>
|
</eis:extdata>
|
||||||
</extension>
|
</extension>
|
||||||
</command>
|
</command>
|
||||||
|
|
|
@ -150,7 +150,7 @@ class EppDomainTransferRequestTest < EppTestCase
|
||||||
</transfer>
|
</transfer>
|
||||||
<extension>
|
<extension>
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||||
<eis:legalDocument type="pdf">test</eis:legalDocument>
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||||
</eis:extdata>
|
</eis:extdata>
|
||||||
</extension>
|
</extension>
|
||||||
</command>
|
</command>
|
||||||
|
|
|
@ -7,7 +7,7 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
||||||
@domain = domains(:shop)
|
@domain = domains(:shop)
|
||||||
@new_registrant = contacts(:william)
|
@new_registrant = contacts(:william)
|
||||||
@user = users(:api_bestnames)
|
@user = users(:api_bestnames)
|
||||||
@legal_doc_path = 'test/fixtures/files/legaldoc.pdf'
|
@legal_doc_path = "#{'test' * 2000}"
|
||||||
|
|
||||||
@domain.update!(pending_json: { new_registrant_id: @new_registrant.id,
|
@domain.update!(pending_json: { new_registrant_id: @new_registrant.id,
|
||||||
new_registrant_name: @new_registrant.name,
|
new_registrant_name: @new_registrant.name,
|
||||||
|
|
14
test/models/legal_document_test.rb
Normal file
14
test/models/legal_document_test.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class LegalDocumentTest < ActiveSupport::TestCase
|
||||||
|
def test_valid_legal_document_fixture_is_valid
|
||||||
|
assert valid_legal_document.valid?, proc { valid_legal_document.errors.full_messages }
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def valid_legal_document
|
||||||
|
legal_documents(:one)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue