Add tests

This commit is contained in:
Artur Beljajev 2019-03-04 15:26:25 +02:00
parent 647bf4c397
commit 6bab335f5a
4 changed files with 55 additions and 0 deletions

5
test/fixtures/log_contacts.yml vendored Normal file
View file

@ -0,0 +1,5 @@
one:
item_id: <%= ActiveRecord::FixtureSet.identify(:john) %>
item_type: Contact
event: update
created_at: <%= Time.zone.parse('2010-07-05') %>

8
test/fixtures/log_domains.yml vendored Normal file
View file

@ -0,0 +1,8 @@
one:
item_id: <%= ActiveRecord::FixtureSet.identify(:shop) %>
item_type: Domain
event: update
object:
registrant_id: <%= ActiveRecord::FixtureSet.identify(:john) %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
created_at: <%= Time.zone.parse('2010-07-05') %>

View file

@ -0,0 +1,16 @@
require 'test_helper'
class ContactAuditLogTest < ActionDispatch::IntegrationTest
def test_stores_metadata
contact = contacts(:john)
contact.legal_document_id = 1
assert_difference 'contact.versions.count' do
contact.save!
end
contact_version = contact.versions.last
assert_equal ({ legal_documents: [1] }).with_indifferent_access,
contact_version.children.with_indifferent_access
end
end

View file

@ -0,0 +1,26 @@
require 'test_helper'
class DomainAuditLogTest < ActionDispatch::IntegrationTest
def test_stores_metadata
domain = domains(:shop)
assert_equal [contacts(:jane).id], domain.admin_contacts.ids
assert_equal [contacts(:william).id, contacts(:acme_ltd).id].sort, domain.tech_contacts.ids.sort
assert_equal [nameservers(:shop_ns1).id, nameservers(:shop_ns2).id].sort, domain.nameservers.ids
.sort
assert_equal contacts(:john).id, domain.registrant_id
domain.legal_document_id = 1
assert_difference 'domain.versions.count' do
domain.save!
end
domain_version = domain.versions.last
assert_equal ({ admin_contacts: [contacts(:jane).id],
tech_contacts: [contacts(:william).id, contacts(:acme_ltd).id],
nameservers: [nameservers(:shop_ns1).id, nameservers(:shop_ns2).id],
dnskeys: [],
legal_documents: [1],
registrant: [contacts(:john).id] }).with_indifferent_access,
domain_version.children.with_indifferent_access
end
end