Stabilised tests.
This commit is contained in:
parent
3f633f252a
commit
967f814ff3
17 changed files with 77 additions and 60 deletions
|
@ -79,6 +79,8 @@ test:unit:mysql:
|
|||
- rake db:seed
|
||||
- rake test:units
|
||||
- rake test:controllers
|
||||
- ruby -I test/ test/integration/object_manager_test.rb
|
||||
- ruby -I test/ test/integration/package_test.rb
|
||||
- rake db:drop
|
||||
|
||||
test:unit:postgresql:
|
||||
|
@ -93,6 +95,8 @@ test:unit:postgresql:
|
|||
- rake db:seed
|
||||
- rake test:units
|
||||
- rake test:controllers
|
||||
- ruby -I test/ test/integration/object_manager_test.rb
|
||||
- ruby -I test/ test/integration/package_test.rb
|
||||
- rake db:drop
|
||||
|
||||
test:integration:autowizard:
|
||||
|
|
|
@ -41,6 +41,8 @@ script:
|
|||
- rake db:seed
|
||||
- rake test:units
|
||||
- rake test:controllers
|
||||
- ruby -I test/ test/integration/object_manager_test.rb
|
||||
- ruby -I test/ test/integration/package_test.rb
|
||||
- rake assets:precompile
|
||||
- rake db:drop
|
||||
- rake db:create
|
||||
|
|
|
@ -579,7 +579,7 @@ remove all session and spool messages
|
|||
next if !session_data
|
||||
next if !session_data[:user]
|
||||
next if !session_data[:user]['id']
|
||||
user = User.lookup( id: session_data[:user]['id'] )
|
||||
user = User.lookup(id: session_data[:user]['id'])
|
||||
next if !user
|
||||
|
||||
# start client thread
|
||||
|
@ -590,8 +590,10 @@ remove all session and spool messages
|
|||
thread_client(client_id)
|
||||
@@client_threads[client_id] = nil
|
||||
log('debug', "close client (#{client_id}) thread")
|
||||
if ActiveRecord::Base.connection.owner == Thread.current
|
||||
ActiveRecord::Base.connection.close
|
||||
end
|
||||
end
|
||||
sleep 0.5
|
||||
end
|
||||
|
||||
|
|
14
test/fixtures/seeds.rb
vendored
14
test/fixtures/seeds.rb
vendored
|
@ -20,5 +20,17 @@ email_address = EmailAddress.create_or_update(
|
|||
)
|
||||
Group.all.each do |group|
|
||||
group.email_address_id = email_address.id
|
||||
group.save
|
||||
group.save!
|
||||
end
|
||||
|
||||
User.create_or_update(
|
||||
login: 'admin@example.com',
|
||||
firstname: 'Default',
|
||||
lastname: 'Admin',
|
||||
email: 'admin@example.com',
|
||||
password: 'adminpw',
|
||||
active: true,
|
||||
roles: Role.where(name: %w(Admin)),
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
require 'integration_test_helper'
|
||||
|
||||
class ClearbitTest < ActiveSupport::TestCase
|
||||
self.use_transactional_tests = true
|
||||
|
||||
# check
|
||||
test 'base' do
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
require 'integration_test_helper'
|
||||
|
||||
class FacebookTest < ActiveSupport::TestCase
|
||||
self.test_order = :sorted
|
||||
self.use_transactional_tests = false
|
||||
|
||||
# set system mode to done / to activate
|
||||
Setting.set('system_init_done', true)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ObjectManagerTest < ActiveSupport::TestCase
|
||||
self.use_transactional_tests = false
|
||||
|
||||
test 'a object manager' do
|
||||
|
||||
list_objects = ObjectManager.list_objects
|
|
@ -2,6 +2,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class PackageTest < ActiveSupport::TestCase
|
||||
self.use_transactional_tests = false
|
||||
|
||||
test 'packages' do
|
||||
tests = [
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
require 'integration_test_helper'
|
||||
|
||||
class TwitterTest < ActiveSupport::TestCase
|
||||
self.test_order = :sorted
|
||||
self.use_transactional_tests = false
|
||||
|
||||
# set system mode to done / to activate
|
||||
Setting.set('system_init_done', true)
|
||||
|
|
|
@ -2,13 +2,16 @@
|
|||
require 'test_helper'
|
||||
|
||||
class UserDeviceControllerTest < ActionDispatch::IntegrationTest
|
||||
self.test_order = :sorted
|
||||
self.use_transactional_tests = false
|
||||
|
||||
setup do
|
||||
|
||||
# set accept header
|
||||
@headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' }
|
||||
|
||||
# create agent
|
||||
roles = Role.where( name: %w(Admin Agent) )
|
||||
roles = Role.where(name: %w(Admin Agent))
|
||||
groups = Group.all
|
||||
|
||||
UserInfo.current_user_id = 1
|
||||
|
@ -24,7 +27,7 @@ class UserDeviceControllerTest < ActionDispatch::IntegrationTest
|
|||
)
|
||||
|
||||
# create agent
|
||||
roles = Role.where( name: 'Agent' )
|
||||
roles = Role.where(name: 'Agent')
|
||||
@agent = User.create_or_update(
|
||||
login: 'user-device-agent',
|
||||
firstname: 'UserDevice',
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
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'"
|
||||
|
@ -45,7 +47,7 @@ class ZendeskImportTest < ActiveSupport::TestCase
|
|||
|
||||
# check count of imported items
|
||||
test 'check counts' do
|
||||
assert_equal(143, User.count, 'users')
|
||||
assert_equal(144, User.count, 'users')
|
||||
assert_equal(3, Group.count, 'groups')
|
||||
assert_equal(3, Role.count, 'roles')
|
||||
assert_equal(2, Organization.count, 'organizations')
|
||||
|
@ -69,7 +71,7 @@ class ZendeskImportTest < ActiveSupport::TestCase
|
|||
|
||||
checks = [
|
||||
{
|
||||
id: 4,
|
||||
id: 5,
|
||||
data: {
|
||||
firstname: 'Bob',
|
||||
lastname: 'Smith',
|
||||
|
@ -83,7 +85,7 @@ class ZendeskImportTest < ActiveSupport::TestCase
|
|||
groups: [group_support],
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
id: 6,
|
||||
data: {
|
||||
firstname: 'Hansimerkur',
|
||||
lastname: '',
|
||||
|
@ -96,7 +98,7 @@ class ZendeskImportTest < ActiveSupport::TestCase
|
|||
groups: [group_additional_group, group_support],
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
id: 7,
|
||||
data: {
|
||||
firstname: 'Bernd',
|
||||
lastname: 'Hofbecker',
|
||||
|
@ -108,7 +110,7 @@ class ZendeskImportTest < ActiveSupport::TestCase
|
|||
groups: [],
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
id: 8,
|
||||
data: {
|
||||
firstname: 'Zendesk',
|
||||
lastname: '',
|
||||
|
@ -120,7 +122,7 @@ class ZendeskImportTest < ActiveSupport::TestCase
|
|||
groups: [],
|
||||
},
|
||||
{
|
||||
id: 89,
|
||||
id: 90,
|
||||
data: {
|
||||
firstname: 'Hans',
|
||||
lastname: 'Peter Wurst',
|
||||
|
@ -309,7 +311,7 @@ class ZendeskImportTest < ActiveSupport::TestCase
|
|||
group_id: 3,
|
||||
priority_id: 3,
|
||||
owner_id: 1,
|
||||
customer_id: 6,
|
||||
customer_id: 7,
|
||||
organization_id: 2,
|
||||
test_checkbox: true,
|
||||
custom_integer: 999,
|
||||
|
@ -332,7 +334,7 @@ If you\'re reading this message in your email, click the ticket number link that
|
|||
group_id: 3,
|
||||
priority_id: 1,
|
||||
owner_id: 1,
|
||||
customer_id: 7,
|
||||
customer_id: 8,
|
||||
organization_id: nil,
|
||||
test_checkbox: false,
|
||||
custom_integer: nil,
|
||||
|
@ -353,7 +355,7 @@ If you\'re reading this message in your email, click the ticket number link that
|
|||
group_id: 3,
|
||||
priority_id: 2,
|
||||
owner_id: 1,
|
||||
customer_id: 91,
|
||||
customer_id: 92,
|
||||
organization_id: nil,
|
||||
},
|
||||
},
|
||||
|
@ -369,7 +371,7 @@ If you\'re reading this message in your email, click the ticket number link that
|
|||
group_id: 1,
|
||||
priority_id: 2,
|
||||
owner_id: 1,
|
||||
customer_id: 143,
|
||||
customer_id: 144,
|
||||
organization_id: nil,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -4,8 +4,9 @@ require 'rails/test_help'
|
|||
require 'cache'
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
# disable transactions
|
||||
#self.use_transactional_tests = false
|
||||
|
||||
# disable transactions / to work with own database connections for each thread
|
||||
self.use_transactional_tests = false
|
||||
|
||||
ActiveRecord::Base.logger = Rails.logger.clone
|
||||
ActiveRecord::Base.logger.level = Logger::INFO
|
||||
|
@ -22,15 +23,12 @@ class ActiveSupport::TestCase
|
|||
# clear cache
|
||||
Cache.clear
|
||||
|
||||
# reload settings
|
||||
Setting.reload
|
||||
|
||||
# remove all session messages
|
||||
Sessions.cleanup
|
||||
|
||||
# remove background jobs
|
||||
Delayed::Job.destroy_all
|
||||
Trigger.destroy_all
|
||||
ActivityStream.destroy_all
|
||||
PostmasterFilter.destroy_all
|
||||
|
||||
# set current user
|
||||
UserInfo.current_user_id = nil
|
||||
end
|
||||
|
|
|
@ -7,10 +7,7 @@ require 'simplecov-rcov'
|
|||
require 'coveralls'
|
||||
Coveralls.wear!
|
||||
|
||||
#ActiveSupport::TestCase.test_order = :sorted
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
self.test_order = :sorted
|
||||
|
||||
ActiveRecord::Base.logger = Rails.logger.clone
|
||||
ActiveRecord::Base.logger.level = Logger::INFO
|
||||
|
@ -27,9 +24,6 @@ class ActiveSupport::TestCase
|
|||
SimpleCov.start
|
||||
fixtures :all
|
||||
|
||||
# disable transactions
|
||||
self.use_transactional_tests = false
|
||||
|
||||
# clear cache
|
||||
Cache.clear
|
||||
|
||||
|
@ -52,27 +46,12 @@ class ActiveSupport::TestCase
|
|||
# clear cache
|
||||
Cache.clear
|
||||
|
||||
# reload settings
|
||||
Setting.reload
|
||||
|
||||
# remove all session messages
|
||||
Sessions.cleanup
|
||||
|
||||
# remove background jobs
|
||||
Delayed::Job.destroy_all
|
||||
Trigger.destroy_all
|
||||
ActivityStream.destroy_all
|
||||
PostmasterFilter.destroy_all
|
||||
Ticket.destroy_all
|
||||
Taskbar.destroy_all
|
||||
Sla.destroy_all
|
||||
Calendar.destroy_all
|
||||
|
||||
# reset settings
|
||||
Setting.all.pluck(:name).each do |name|
|
||||
next if name == 'models_searchable' # skip setting
|
||||
Setting.reset(name, false)
|
||||
end
|
||||
Setting.set('system_init_done', true)
|
||||
Setting.reload
|
||||
|
||||
# set current user
|
||||
UserInfo.current_user_id = nil
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class SessionEnhancedTest < ActiveSupport::TestCase
|
||||
test 'a check clients and send messages' do
|
||||
test 'check clients and send messages' do
|
||||
|
||||
# create users
|
||||
roles = Role.where(name: ['Agent'])
|
||||
|
@ -172,7 +172,8 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
|||
travel_back
|
||||
end
|
||||
|
||||
test 'b check client and backends' do
|
||||
test 'check client and backends' do
|
||||
|
||||
# create users
|
||||
roles = Role.where(name: ['Agent'])
|
||||
groups = Group.all
|
||||
|
|
|
@ -932,15 +932,9 @@ class UserTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test 'min admin permission check' do
|
||||
# workaround:
|
||||
# - We need to get rid of all admin users but can't delete them
|
||||
# because we have foreign keys pointing at them since the tests are not isolated yet :(
|
||||
# - We can't just remove the roles since then our check would take place
|
||||
# So we need to merge them with the User Nr 1 and destroy them afterwards
|
||||
User.with_permissions('admin').each do |user|
|
||||
Models.merge('User', 1, user.id)
|
||||
user.destroy!
|
||||
end
|
||||
|
||||
# delete inital admin
|
||||
User.find_by(login: 'admin@example.com').destroy
|
||||
|
||||
# store current admin count
|
||||
admin_count_inital = User.with_permissions('admin').count
|
||||
|
|
|
@ -90,6 +90,17 @@ class UserValidateAgentLimit < ActiveSupport::TestCase
|
|||
|
||||
assert_equal(User.with_permissions('ticket.agent').count, agent_max)
|
||||
|
||||
# set roles of agent again
|
||||
role_admin = Role.lookup(name: 'Admin')
|
||||
user2.roles = [role_agent, role_admin]
|
||||
user2.save!
|
||||
|
||||
user2.role_ids = [role_admin.id, role_agent_limit.id]
|
||||
user2.save!
|
||||
|
||||
user2.role_ids = [role_admin.id.to_s, role_agent_limit.id.to_s]
|
||||
user2.save!
|
||||
|
||||
user1.destroy!
|
||||
user2.destroy!
|
||||
user3.destroy!
|
||||
|
|
Loading…
Reference in a new issue