From 76f3a2876b76b7dc31831f7fdf35f6917cbea10c Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 25 Jun 2018 13:07:47 +0200 Subject: [PATCH] Review of correct test helper for integration tests. --- test/integration/clearbit_test.rb | 3 +-- test/integration/monitoring_controller_test.rb | 6 ++---- .../object_manager_attributes_controller_test.rb | 3 +-- test/integration/object_manager_test.rb | 3 +-- test/integration/package_test.rb | 3 +-- test/integration/zendesk_import_test.rb | 1 - test/integration_test_helper.rb | 8 ++++++++ 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/test/integration/clearbit_test.rb b/test/integration/clearbit_test.rb index be97d4b89..b5060db1e 100644 --- a/test/integration/clearbit_test.rb +++ b/test/integration/clearbit_test.rb @@ -1,8 +1,7 @@ -require 'integration_test_helper' +require 'test_helper' class ClearbitTest < ActiveSupport::TestCase - self.use_transactional_tests = true # check test 'base' do diff --git a/test/integration/monitoring_controller_test.rb b/test/integration/monitoring_controller_test.rb index 703dc244c..ce648e274 100644 --- a/test/integration/monitoring_controller_test.rb +++ b/test/integration/monitoring_controller_test.rb @@ -1,7 +1,7 @@ -require 'test_helper' +require 'integration_test_helper' class MonitoringControllerTest < ActionDispatch::IntegrationTest - self.use_transactional_tests = false + setup do # set accept header @@ -75,8 +75,6 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest roles: roles, ) - # ensure fresh state - Delayed::Job.destroy_all end test '01 monitoring without token' do diff --git a/test/integration/object_manager_attributes_controller_test.rb b/test/integration/object_manager_attributes_controller_test.rb index 5f137b113..498c076b4 100644 --- a/test/integration/object_manager_attributes_controller_test.rb +++ b/test/integration/object_manager_attributes_controller_test.rb @@ -1,8 +1,7 @@ -require 'test_helper' +require 'integration_test_helper' require 'rake' class ObjectManagerAttributesControllerTest < ActionDispatch::IntegrationTest - self.use_transactional_tests = false setup do diff --git a/test/integration/object_manager_test.rb b/test/integration/object_manager_test.rb index 9a6064668..55a5462d1 100644 --- a/test/integration/object_manager_test.rb +++ b/test/integration/object_manager_test.rb @@ -1,7 +1,6 @@ -require 'test_helper' +require 'integration_test_helper' class ObjectManagerTest < ActiveSupport::TestCase - self.use_transactional_tests = false test 'a object manager' do diff --git a/test/integration/package_test.rb b/test/integration/package_test.rb index 26bf7f7f2..8dfd53361 100644 --- a/test/integration/package_test.rb +++ b/test/integration/package_test.rb @@ -1,8 +1,7 @@ -require 'test_helper' +require 'integration_test_helper' class PackageTest < ActiveSupport::TestCase - self.use_transactional_tests = false test 'packages' do tests = [ diff --git a/test/integration/zendesk_import_test.rb b/test/integration/zendesk_import_test.rb index 1b781a9a1..b199b380e 100644 --- a/test/integration/zendesk_import_test.rb +++ b/test/integration/zendesk_import_test.rb @@ -3,7 +3,6 @@ require 'integration_test_helper' class ZendeskImportTest < ActiveSupport::TestCase self.test_order = :sorted - self.use_transactional_tests = false if !ENV['IMPORT_ZENDESK_ENDPOINT'] raise "ERROR: Need IMPORT_ZENDESK_ENDPOINT - hint IMPORT_ZENDESK_ENDPOINT='https://example.zendesk.com/api/v2'" diff --git a/test/integration_test_helper.rb b/test/integration_test_helper.rb index ec00050a4..150d75a9f 100644 --- a/test/integration_test_helper.rb +++ b/test/integration_test_helper.rb @@ -20,6 +20,9 @@ class ActiveSupport::TestCase load Rails.root.join('db', 'seeds.rb') load Rails.root.join('test', 'fixtures', 'seeds.rb') + # set system mode to done / to activate + Setting.set('system_init_done', true) + setup do # clear cache @@ -31,8 +34,13 @@ class ActiveSupport::TestCase # remove all session messages Sessions.cleanup + # remove old delayed jobs + Delayed::Job.destroy_all + # set current user UserInfo.current_user_id = nil + + travel_back end # Add more helper methods to be used by all tests here...