From fc30d76584297df7f2a6c14ef79f5d28917eaf58 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 21 May 2019 18:20:36 +0300 Subject: [PATCH] Sort array before comparing --- test/integration/domain/audit_log_test.rb | 29 +++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/integration/domain/audit_log_test.rb b/test/integration/domain/audit_log_test.rb index 03446c2efc..292994ca3f 100644 --- a/test/integration/domain/audit_log_test.rb +++ b/test/integration/domain/audit_log_test.rb @@ -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 \ No newline at end of file