diff --git a/test/fixtures/log_contacts.yml b/test/fixtures/log_contacts.yml new file mode 100644 index 000000000..8bcf8fa51 --- /dev/null +++ b/test/fixtures/log_contacts.yml @@ -0,0 +1,5 @@ +one: + item_id: <%= ActiveRecord::FixtureSet.identify(:john) %> + item_type: Contact + event: update + created_at: <%= Time.zone.parse('2010-07-05') %> \ No newline at end of file diff --git a/test/fixtures/log_domains.yml b/test/fixtures/log_domains.yml new file mode 100644 index 000000000..f328f902a --- /dev/null +++ b/test/fixtures/log_domains.yml @@ -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') %> \ No newline at end of file diff --git a/test/integration/contact/audit_log_test.rb b/test/integration/contact/audit_log_test.rb new file mode 100644 index 000000000..f0f6a4bf2 --- /dev/null +++ b/test/integration/contact/audit_log_test.rb @@ -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 \ No newline at end of file diff --git a/test/integration/domain/audit_log_test.rb b/test/integration/domain/audit_log_test.rb new file mode 100644 index 000000000..03446c2ef --- /dev/null +++ b/test/integration/domain/audit_log_test.rb @@ -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 \ No newline at end of file