From 764784908f24e497375559ec9928fb9041b67bbc Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 2 May 2017 22:58:56 +0200 Subject: [PATCH] Support mt6 style. --- test/unit/auth_test.rb | 2 ++ test/unit/email_parser_test.rb | 6 +++++- test/unit/session_basic_test.rb | 15 ++++++--------- test/unit/session_collections_test.rb | 8 ++++---- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/test/unit/auth_test.rb b/test/unit/auth_test.rb index 5c147e3cf..f0b2b6a85 100644 --- a/test/unit/auth_test.rb +++ b/test/unit/auth_test.rb @@ -72,6 +72,8 @@ class AuthTest < ActiveSupport::TestCase assert_equal(user[key], value, 'verify') } end + elsif test[:result].nil? + assert_nil(user, 'failed or not existing') else assert_equal(test[:result], user, 'failed or not existing') end diff --git a/test/unit/email_parser_test.rb b/test/unit/email_parser_test.rb index 1031ea657..b3f4ffef3 100644 --- a/test/unit/email_parser_test.rb +++ b/test/unit/email_parser_test.rb @@ -1083,7 +1083,11 @@ end #puts '++' + file[:params][key.to_sym].to_s + '++' assert_equal(Digest::MD5.hexdigest(file[:params][key.to_sym].to_s), Digest::MD5.hexdigest(data[:body].to_s)) else - assert_equal(file[:params][key.to_sym], data[key.to_sym], "check #{key}") + if file[:params][key.to_sym] == nil + assert_nil(data[key.to_sym], "check #{key}") + else + assert_equal(file[:params][key.to_sym], data[key.to_sym], "check #{key}") + end end } diff --git a/test/unit/session_basic_test.rb b/test/unit/session_basic_test.rb index a4e0c321d..58d314716 100644 --- a/test/unit/session_basic_test.rb +++ b/test/unit/session_basic_test.rb @@ -143,10 +143,9 @@ class SessionBasicTest < ActiveSupport::TestCase # check again after touch result1 = collection_client1.push - assert(!result1, 'check collections - after touch - recall') + assert_nil(result1, 'check collections - after touch - recall') result2 = collection_client2.push - assert(!result2, 'check collections - after touch - recall') - assert_equal(result1, result2, 'check collections') + assert_nil(result2, 'check collections - after touch - recall') # change collection group = Group.create(name: "SomeGroup::#{rand(999_999)}", active: true) @@ -162,10 +161,9 @@ class SessionBasicTest < ActiveSupport::TestCase # check again after create travel 4.seconds result1 = collection_client1.push - assert(!result1, 'check collections - after create - recall') + assert_nil(result1, 'check collections - after create - recall') result2 = collection_client2.push - assert(!result2, 'check collections - after create - recall') - assert_equal(result1, result2, 'check collections') + assert_nil(result2, 'check collections - after create - recall') # change collection group.destroy @@ -181,10 +179,9 @@ class SessionBasicTest < ActiveSupport::TestCase # check again after destroy travel 4.seconds result1 = collection_client1.push - assert(!result1, 'check collections - after destroy - recall') + assert_nil(result1, 'check collections - after destroy - recall') result2 = collection_client2.push - assert(!result2, 'check collections - after destroy - recall') - assert_equal(result1, result2, 'check collections') + assert_nil(result2, 'check collections - after destroy - recall') travel_back end diff --git a/test/unit/session_collections_test.rb b/test/unit/session_collections_test.rb index c5dc200c2..d6883d715 100644 --- a/test/unit/session_collections_test.rb +++ b/test/unit/session_collections_test.rb @@ -175,7 +175,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase test 'b assets' do # create users roles = Role.where(name: %w(Agent Admin)) - groups = Group.all + groups = Group.all.order(id: :asc) UserInfo.current_user_id = 2 agent1 = User.create_or_update( @@ -193,19 +193,19 @@ class SessionCollectionsTest < ActiveSupport::TestCase assets = {} client1 = Sessions::Backend::Collections::Group.new(agent1, assets, false, '123-1', 4) data = client1.push - assert(data[:collection][:Group][groups.first.id]) + assert_equal(data[:collection][:Group][0]['id'], groups[0].id) assert(data[:assets][:Group][groups.first.id]) travel 10.seconds client1 = Sessions::Backend::Collections::Group.new(agent1, assets, false, '123-1', 4) data = client1.push - assert(data[:collection][:Group][groups.first.id]) + assert_equal(data[:collection][:Group][0]['id'], groups[0].id) assert(data[:assets][:Group][groups.first.id]) travel 2.minutes client1 = Sessions::Backend::Collections::Group.new(agent1, assets, false, '123-1', 4) data = client1.push - assert(data[:collection][:Group][groups.first.id]) + assert_equal(data[:collection][:Group][0]['id'], groups[0].id) assert_nil(data[:assets][:Group]) travel 10.seconds