Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Beljajev committed May 17, 2019
1 parent 647bf4c commit 6bab335
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/fixtures/log_contacts.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 8 additions & 0 deletions test/fixtures/log_domains.yml
Original file line number Diff line number Diff line change
@@ -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') %>
16 changes: 16 additions & 0 deletions test/integration/contact/audit_log_test.rb
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions test/integration/domain/audit_log_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6bab335

Please sign in to comment.