Skip to content

Commit

Permalink
Merge pull request #1211 from internetee/fix-test
Browse files Browse the repository at this point in the history
Sort array before comparing
  • Loading branch information
vohmar authored May 21, 2019
2 parents eed255f + fc30d76 commit 6fbfe06
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions test/integration/domain/audit_log_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@
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
admin_contact_ids = [contacts(:jane).id].sort
tech_contact_ids = [contacts(:william).id, contacts(:acme_ltd).id].sort
nameserver_ids = [nameservers(:shop_ns1).id, nameservers(:shop_ns2).id].sort
registrant_id = contacts(:john).id
legal_document_id = 1
assert_equal admin_contact_ids, domain.admin_contacts.ids
assert_equal tech_contact_ids, domain.tech_contacts.ids.sort
assert_equal nameserver_ids, domain.nameservers.ids.sort
assert_equal registrant_id, domain.registrant_id
domain.legal_document_id = legal_document_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
assert_equal admin_contact_ids, domain_version.children['admin_contacts'].sort
assert_equal tech_contact_ids, domain_version.children['tech_contacts'].sort
assert_equal nameserver_ids, domain_version.children['nameservers'].sort
assert_equal [], domain_version.children['dnskeys']
assert_equal [legal_document_id], domain_version.children['legal_documents']
assert_equal [registrant_id], domain_version.children['registrant']
end
end

0 comments on commit 6fbfe06

Please sign in to comment.