Browse Source

Rework, get unit tests up and running again.

Martin Edenhofer 8 years ago
parent
commit
9b9f9ed8c5

+ 3 - 10
app/models/activity_stream.rb

@@ -50,11 +50,7 @@ add a new activity entry for an object
 
     # resturn if old entry is really fresh
     if result
-      activity_record_delay = if ENV['ZAMMAD_ACTIVITY_RECORD_DELAY']
-                                ENV['ZAMMAD_ACTIVITY_RECORD_DELAY'].to_i.seconds
-                              else
-                                90.seconds
-                              end
+      activity_record_delay = 90.seconds
       return result if result.created_at.to_i >= ( data[:created_at].to_i - activity_record_delay )
     end
 
@@ -97,13 +93,10 @@ return all activity entries of an user
 =end
 
   def self.list(user, limit)
-    # do not return an activity stream for custoers
+    # do not return an activity stream for customers
     return [] if !user.permissions?('ticket.agent') && !user.permissions?('admin')
 
-    permission_ids = []
-    user.roles.each { |role|
-      permission_ids = permission_ids.concat(role.permission_ids)
-    }
+    permission_ids = user.permissions_with_child_ids
     group_ids = user.group_ids
 
     stream = if group_ids.empty?

+ 2 - 2
app/models/channel/filter/database.rb

@@ -3,10 +3,10 @@
 # process all database filter
 module Channel::Filter::Database
 
-  def self.run( _channel, mail )
+  def self.run(_channel, mail)
 
     # process postmaster filter
-    filters = PostmasterFilter.where( active: true, channel: 'email' ).order(:name, :created_at)
+    filters = PostmasterFilter.where(active: true, channel: 'email').order(:name, :created_at)
     filters.each { |filter|
       Rails.logger.info " process filter #{filter.name} ..."
       all_matches_ok = true

+ 2 - 2
app/models/role.rb

@@ -52,7 +52,7 @@ get signup roles
 
   Role.signup_roles
 
-returnes
+returns
 
   [role1, role2, ...]
 
@@ -68,7 +68,7 @@ get signup role ids
 
   Role.signup_role_ids
 
-returnes
+returns
 
   [role1, role2, ...]
 

+ 26 - 0
app/models/user.rb

@@ -380,6 +380,32 @@ returns
 
 =begin
 
+returns all accessable permission ids of user
+
+  user = User.find(123)
+  user.permissions_with_child_ids
+
+returns
+
+  [permission1_id, permission2_id, permission3_id]
+
+=end
+
+  def permissions_with_child_ids
+    where = ''
+    where_bind = [true]
+    permissions.each { |permission_name, _value|
+      where += ' OR ' if where != ''
+      where += 'permissions.name = ? OR permissions.name LIKE ?'
+      where_bind.push permission_name
+      where_bind.push "#{permission_name}.%"
+    }
+    return [] if where == ''
+    Object.const_get('Permission').where("permissions.active = ? AND (#{where})", *where_bind).pluck(:id)
+  end
+
+=begin
+
 get all users with permission
 
   users = User.with_permissions('admin.session')

+ 6 - 1
test/controllers/search_controller_test.rb

@@ -2,7 +2,7 @@
 require 'test_helper'
 
 class SearchControllerTest < ActionDispatch::IntegrationTest
-  setup do
+  def base_data
 
     # clear cache
     Cache.clear
@@ -192,6 +192,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
   end
 
   test 'settings index with nobody' do
+    base_data
 
     params = {
       query: 'test 1234',
@@ -222,6 +223,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
   end
 
   test 'settings index with admin' do
+    base_data
 
     credentials = ActionController::HttpAuthentication::Basic.encode_credentials('search-admin@example.com', 'adminpw')
 
@@ -295,6 +297,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
   end
 
   test 'settings index with agent' do
+    base_data
 
     credentials = ActionController::HttpAuthentication::Basic.encode_credentials('search-agent@example.com', 'agentpw')
 
@@ -368,6 +371,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
   end
 
   test 'settings index with customer 1' do
+    base_data
 
     credentials = ActionController::HttpAuthentication::Basic.encode_credentials('search-customer1@example.com', 'customer1pw')
 
@@ -413,6 +417,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
   end
 
   test 'settings index with customer 2' do
+    base_data
 
     credentials = ActionController::HttpAuthentication::Basic.encode_credentials('search-customer2@example.com', 'customer2pw')
 

+ 3 - 0
test/test_helper.rb

@@ -44,6 +44,9 @@ class ActiveSupport::TestCase
 
     # remove background jobs
     Delayed::Job.destroy_all
+    ActivityStream.destroy_all
+    PostmasterFilter.destroy_all
+    Ticket.destroy_all
 
     # set current user
     UserInfo.current_user_id = nil

+ 169 - 355
test/unit/activity_stream_test.rb

@@ -5,7 +5,7 @@ class ActivityStreamTest < ActiveSupport::TestCase
   admin_user = nil
   current_user = nil
   test 'aaa - setup' do
-    role  = Role.lookup(name: 'Admin')
+    roles = Role.where(name: %w(Admin Agent))
     group = Group.lookup(name: 'Users')
     admin_user = User.create_or_update(
       login: 'admin',
@@ -14,7 +14,7 @@ class ActivityStreamTest < ActiveSupport::TestCase
       email: 'bob@example.com',
       password: 'some_pass',
       active: true,
-      role_ids: [role.id],
+      roles: roles,
       group_ids: [group.id],
       updated_by_id: 1,
       created_by_id: 1
@@ -23,377 +23,191 @@ class ActivityStreamTest < ActiveSupport::TestCase
   end
 
   test 'ticket+user' do
-    tests = [
-
-      # test 1
-      {
-        create: {
-          ticket: {
-            group_id: Group.lookup(name: 'Users').id,
-            customer_id: current_user.id,
-            owner_id: User.lookup(login: '-').id,
-            title: 'Unit Test 1 (äöüß)!',
-            state_id: Ticket::State.lookup(name: 'new').id,
-            priority_id: Ticket::Priority.lookup(name: '2 normal').id,
-            updated_by_id: current_user.id,
-            created_by_id: current_user.id,
-          },
-          article: {
-            updated_by_id: current_user.id,
-            created_by_id: current_user.id,
-            type_id: Ticket::Article::Type.lookup(name: 'phone').id,
-            sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id,
-            from: 'Unit Test <unittest@example.com>',
-            body: 'Unit Test 123',
-            internal: false,
-          },
-        },
-        update: {
-          ticket: {
-            title: 'Unit Test 1 (äöüß) - update!',
-            state_id: Ticket::State.lookup(name: 'open').id,
-            priority_id: Ticket::Priority.lookup(name: '1 low').id,
-          },
-        },
-        update2: {
-          ticket: {
-            title: 'Unit Test 2 (äöüß) - update!',
-            priority_id: Ticket::Priority.lookup(name: '2 normal').id,
-          },
-        },
-        check: [
-          {
-            result: true,
-            object: 'Ticket',
-            type: 'update',
-          },
-          {
-            result: true,
-            object: 'Ticket::Article',
-            type: 'create',
-          },
-          {
-            result: true,
-            object: 'Ticket',
-            type: 'create',
-          },
-          {
-            result: false,
-            object: 'User',
-            type: 'update',
-            o_id: current_user.id,
-          },
-        ]
-      },
-    ]
-    tickets = []
-    tests.each { |test|
-
-      ticket = Ticket.create(test[:create][:ticket])
-      test[:check][0][:o_id]          = ticket.id
-      test[:check][2][:o_id]          = ticket.id
-      test[:check][2][:created_at]    = ticket.created_at
-      test[:check][2][:created_by_id] = current_user.id
-      travel 2.seconds
-
-      test[:create][:article][:ticket_id] = ticket.id
-      article = Ticket::Article.create(test[:create][:article])
-      test[:check][1][:o_id]          = article.id
-      test[:check][1][:created_at]    = article.created_at
-      test[:check][1][:created_by_id] = current_user.id
-
-      assert_equal(ticket.class.to_s, 'Ticket')
-      assert_equal(article.class.to_s, 'Ticket::Article')
-
-      # update ticket
-      if test[:update][:ticket]
-        ticket.update_attributes(test[:update][:ticket])
-
-        # check updated user
-        test[:check][3][:o_id]          = current_user.id
-        test[:check][3][:created_at]    = ticket.created_at
-        test[:check][3][:created_by_id] = current_user.id
-      end
-      if test[:update2][:ticket]
-        ticket = Ticket.find(ticket.id)
-        ticket.update_attributes(test[:update2][:ticket])
-      end
-      if test[:update][:article]
-        article.update_attributes(test[:update][:article])
-      end
-
-      travel 1.second
-      if test[:update][:ticket]
-        ticket.update_attributes(test[:update][:ticket])
-      end
-      if test[:update2][:ticket]
-        ticket.update_attributes(test[:update2][:ticket])
-      end
+    ticket = Ticket.create(
+      group_id: Group.lookup(name: 'Users').id,
+      customer_id: current_user.id,
+      owner_id: User.lookup(login: '-').id,
+      title: 'Unit Test 1 (äöüß)!',
+      state_id: Ticket::State.lookup(name: 'new').id,
+      priority_id: Ticket::Priority.lookup(name: '2 normal').id,
+      updated_by_id: current_user.id,
+      created_by_id: current_user.id,
+    )
+    travel 2.seconds
+
+    article = Ticket::Article.create(
+      ticket_id: ticket.id,
+      updated_by_id: current_user.id,
+      created_by_id: current_user.id,
+      type_id: Ticket::Article::Type.lookup(name: 'phone').id,
+      sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id,
+      from: 'Unit Test <unittest@example.com>',
+      body: 'Unit Test 123',
+      internal: false,
+    )
 
-      # remember ticket
-      tickets.push ticket
+    travel 100.seconds
+    ticket.update_attributes(
+      title: 'Unit Test 1 (äöüß) - update!',
+      state_id: Ticket::State.lookup(name: 'open').id,
+      priority_id: Ticket::Priority.lookup(name: '1 low').id,
+    )
+    updated_at = ticket.updated_at
 
-      # check activity_stream
-      activity_stream_check(admin_user.activity_stream(3), test[:check])
-    }
+    travel 1.second
+    ticket.update_attributes(
+      title: 'Unit Test 2 (äöüß) - update!',
+      priority_id: Ticket::Priority.lookup(name: '2 normal').id,
+    )
 
-    # delete tickets
-    tickets.each { |ticket|
-      ticket_id = ticket.id
-      ticket.destroy
-      found = Ticket.where(id: ticket_id).first
-      assert_not(found, 'Ticket destroyed')
-    }
+    # check activity_stream
+    stream = admin_user.activity_stream(4)
+    assert_equal(stream[0]['group_id'], ticket.group_id)
+    assert_equal(stream[0]['o_id'], ticket.id)
+    assert_equal(stream[0]['created_by_id'], current_user.id)
+    assert_equal(stream[0]['created_at'].to_s, updated_at.to_s)
+    assert_equal(stream[0]['object'], 'Ticket')
+    assert_equal(stream[0]['type'], 'update')
+    assert_equal(stream[1]['group_id'], ticket.group_id)
+    assert_equal(stream[1]['o_id'], article.id)
+    assert_equal(stream[1]['created_by_id'], current_user.id)
+    assert_equal(stream[1]['created_at'].to_s, article.created_at.to_s)
+    assert_equal(stream[1]['object'], 'Ticket::Article')
+    assert_equal(stream[1]['type'], 'create')
+    assert_equal(stream[2]['group_id'], ticket.group_id)
+    assert_equal(stream[2]['o_id'], ticket.id)
+    assert_equal(stream[2]['created_by_id'], current_user.id)
+    assert_equal(stream[2]['created_at'].to_s, ticket.created_at.to_s)
+    assert_equal(stream[2]['object'], 'Ticket')
+    assert_equal(stream[2]['type'], 'create')
+    assert_not(stream[3])
+
+    stream = current_user.activity_stream(4)
+    assert(stream.empty?)
+
+    # cleanup
+    ticket.destroy
+    travel_back
   end
 
   test 'organization' do
-    tests = [
-
-      # test 1
-      {
-        create: {
-          organization: {
-            name: 'some name',
-            updated_by_id: current_user.id,
-            created_by_id: current_user.id,
-          },
-        },
-        update1: {
-          organization: {
-            name: 'some name (äöüß)',
-          },
-        },
-        update2: {
-          organization: {
-            name: 'some name 2 (äöüß)',
-          },
-        },
-        check: [
-          {
-            result: true,
-            object: 'Organization',
-            type: 'update',
-          },
-          {
-            result: true,
-            object: 'Organization',
-            type: 'create',
-          },
-        ]
-      },
-    ]
-    organizations = []
-    tests.each { |test|
-
-      organization = Organization.create(test[:create][:organization])
-      test[:check][0][:o_id]          = organization.id
-      test[:check][0][:created_at]    = organization.created_at
-      test[:check][0][:created_by_id] = current_user.id
-      travel 2.seconds
-
-      assert_equal(organization.class.to_s, 'Organization')
-
-      if test[:update1][:organization]
-        organization.update_attributes(test[:update1][:organization])
-        test[:check][1][:o_id]          = organization.id
-        test[:check][1][:updated_at]    = organization.updated_at
-        test[:check][1][:created_by_id] = current_user.id
-        travel 1.second
-      end
 
-      if test[:update2][:organization]
-        organization.update_attributes(test[:update2][:organization])
-      end
-
-      # remember organization
-      organizations.push organization
-
-      # check activity_stream
-      activity_stream_check(admin_user.activity_stream(2), test[:check])
-    }
-
-    # delete tickets
-    organizations.each { |organization|
-      organization_id = organization.id
-      organization.destroy
-      found = Organization.where(id: organization_id).first
-      assert( !found, 'Organization destroyed')
-    }
+    organization = Organization.create(
+      name: 'some name',
+      updated_by_id: current_user.id,
+      created_by_id: current_user.id,
+    )
+    travel 100.seconds
+    assert_equal(organization.class, Organization)
+
+    organization.update_attributes(name: 'some name (äöüß)')
+    updated_at = organization.updated_at
+
+    travel 10.seconds
+    organization.update_attributes(name: 'some name 2 (äöüß)')
+
+    # check activity_stream
+    stream = admin_user.activity_stream(3)
+    assert_not(stream[0]['group_id'])
+    assert_equal(stream[0]['o_id'], organization.id)
+    assert_equal(stream[0]['created_by_id'], current_user.id)
+    assert_equal(stream[0]['created_at'].to_s, updated_at.to_s)
+    assert_equal(stream[0]['object'], 'Organization')
+    assert_equal(stream[0]['type'], 'update')
+    assert_not(stream[1]['group_id'])
+    assert_equal(stream[1]['o_id'], organization.id)
+    assert_equal(stream[1]['created_by_id'], current_user.id)
+    assert_equal(stream[1]['created_at'].to_s, organization.created_at.to_s)
+    assert_equal(stream[1]['object'], 'Organization')
+    assert_equal(stream[1]['type'], 'create')
+    assert_not(stream[2])
+
+    stream = current_user.activity_stream(4)
+    assert(stream.empty?)
+
+    # cleanup
+    organization.destroy
+    travel_back
   end
 
   test 'user with update check false' do
-    tests = [
-
-      # test 1
-      {
-        create: {
-          user: {
-            login: 'someemail@example.com',
-            email: 'someemail@example.com',
-            firstname: 'Bob Smith II',
-            updated_by_id: current_user.id,
-            created_by_id: current_user.id,
-          },
-        },
-        update1: {
-          user: {
-            firstname: 'Bob U',
-            lastname: 'Smith U',
-          },
-        },
-        check: [
-          {
-            result: true,
-            object: 'User',
-            type: 'create',
-          },
-          {
-            result: false,
-            object: 'User',
-            type: 'update',
-          },
-        ]
-      },
-    ]
-    users = []
-    tests.each { |test|
-
-      user = User.create(test[:create][:user])
-      test[:check][0][:o_id]          = user.id
-      test[:check][0][:created_at]    = user.created_at
-      test[:check][0][:created_by_id] = current_user.id
-
-      assert_equal(user.class.to_s, 'User')
-
-      if test[:update1][:user]
-        user.update_attributes(test[:update1][:user])
-        test[:check][1][:o_id]          = user.id
-        test[:check][1][:updated_at]    = user.updated_at
-        test[:check][1][:created_by_id] = current_user.id
-      end
-
-      # remember organization
-      users.push user
-
-      # check activity_stream
-      activity_stream_check(admin_user.activity_stream(3), test[:check])
-    }
+    user = User.create(
+      login: 'someemail@example.com',
+      email: 'someemail@example.com',
+      firstname: 'Bob Smith II',
+      updated_by_id: current_user.id,
+      created_by_id: current_user.id,
+    )
+    assert_equal(user.class, User)
+    user.update_attributes(
+      firstname: 'Bob U',
+      lastname: 'Smith U',
+    )
 
-    # delete tickets
-    users.each { |user|
-      user_id = user.id
-      user.destroy
-      found = User.where( id: user_id ).first
-      assert_not(found, 'User destroyed')
-    }
+    # check activity_stream
+    stream = admin_user.activity_stream(3)
+    assert_not(stream[0]['group_id'])
+    assert_equal(stream[0]['o_id'], user.id)
+    assert_equal(stream[0]['created_by_id'], current_user.id)
+    assert_equal(stream[0]['created_at'].to_s, user.created_at.to_s)
+    assert_equal(stream[0]['object'], 'User')
+    assert_equal(stream[0]['type'], 'create')
+    assert_not(stream[1])
+
+    stream = current_user.activity_stream(4)
+    assert(stream.empty?)
+
+    # cleanup
+    user.destroy
+    travel_back
   end
 
   test 'user with update check true' do
-    tests = [
-
-      # test 1
-      {
-        create: {
-          user: {
-            login: 'someemail@example.com',
-            email: 'someemail@example.com',
-            firstname: 'Bob Smith II',
-            updated_by_id: current_user.id,
-            created_by_id: current_user.id,
-          },
-        },
-        update1: {
-          user: {
-            firstname: 'Bob U',
-            lastname: 'Smith U',
-          },
-        },
-        update2: {
-          user: {
-            firstname: 'Bob',
-            lastname: 'Smith',
-          },
-        },
-        check: [
-          {
-            result: true,
-            object: 'User',
-            type: 'update',
-          },
-          {
-            result: true,
-            object: 'User',
-            type: 'create',
-          },
-        ]
-      },
-    ]
-    users = []
-    tests.each { |test|
-
-      user = User.create(test[:create][:user])
-      test[:check][0][:o_id]          = user.id
-      test[:check][0][:created_at]    = user.created_at
-      test[:check][0][:created_by_id] = current_user.id
-
-      assert_equal(user.class.to_s, 'User')
 
-      if test[:update1][:user]
-        user.update_attributes(test[:update1][:user])
-        test[:check][1][:o_id]          = user.id
-        test[:check][1][:updated_at]    = user.updated_at
-        test[:check][1][:created_by_id] = current_user.id
-      end
-
-      # to verify update which need to be logged
-      travel 1.second
-
-      if test[:update2][:user]
-        user.update_attributes(test[:update2][:user])
-      end
-
-      # remember organization
-      users.push user
-
-      # check activity_stream
-      activity_stream_check(admin_user.activity_stream(2), test[:check])
-    }
+    user = User.create(
+      login: 'someemail@example.com',
+      email: 'someemail@example.com',
+      firstname: 'Bob Smith II',
+      updated_by_id: current_user.id,
+      created_by_id: current_user.id,
+    )
+    travel 100.seconds
+    assert_equal(user.class, User)
 
-    # delete tickets
-    users.each { |user|
-      user_id = user.id
-      user.destroy
-      found = User.where(id: user_id).first
-      assert(!found, 'User destroyed')
-    }
-  end
+    user.update_attributes(
+      firstname: 'Bob U',
+      lastname: 'Smith U',
+    )
+    updated_at = user.updated_at
 
-  def activity_stream_check(activity_stream_list, checks)
-    #activity_stream_list = activity_stream_list.reverse
-    #puts 'AS ' + activity_stream_list.inspect
-    check_count = 0
-    checks.each { |check_item|
-      check_count += 1
+    travel 10.seconds
+    user.update_attributes(
+      firstname: 'Bob',
+      lastname: 'Smith',
+    )
 
-      #puts '+++++++++++'
-      #puts check_item.inspect
-      check_list = 0
-      activity_stream_list.each { |item|
-        check_list += 1
-        next if check_list != check_count
-        #next if match
-        #puts '--------'
-        #puts item.inspect
-        #puts check_item.inspect
-        if check_item[:result]
-          assert_equal(check_item[:object], item['object'])
-          assert_equal(check_item[:type], item['type'])
-          assert_equal(check_item[:o_id], item['o_id'])
-        elsif check_item[:object] == item['object'] && check_item[:type] == item['type'] && check_item[:o_id] == item['o_id']
-          assert(false, "entry should not exist #{item['object']}/#{item['type']}/#{item['o_id']}")
-        end
-      }
-    }
+    # check activity_stream
+    stream = admin_user.activity_stream(3)
+    assert_not(stream[0]['group_id'])
+    assert_equal(stream[0]['o_id'], user.id)
+    assert_equal(stream[0]['created_by_id'], current_user.id)
+    assert_equal(stream[0]['created_at'].to_s, updated_at.to_s)
+    assert_equal(stream[0]['object'], 'User')
+    assert_equal(stream[0]['type'], 'update')
+    assert_not(stream[1]['group_id'])
+    assert_equal(stream[1]['o_id'], user.id)
+    assert_equal(stream[1]['created_by_id'], current_user.id)
+    assert_equal(stream[1]['created_at'].to_s, user.created_at.to_s)
+    assert_equal(stream[1]['object'], 'User')
+    assert_equal(stream[1]['type'], 'create')
+    assert_not(stream[2])
+
+    stream = current_user.activity_stream(4)
+    assert(stream.empty?)
+
+    # cleanup
+    user.destroy
+    travel_back
   end
 
 end

+ 23 - 9
test/unit/assets_test.rb

@@ -6,7 +6,7 @@ class AssetsTest < ActiveSupport::TestCase
 
     roles  = Role.where(name: %w(Agent Admin))
     groups = Group.all
-    org    = Organization.create_or_update(
+    org1   = Organization.create_or_update(
       name: 'some user org',
       updated_by_id: 1,
       created_by_id: 1,
@@ -21,7 +21,7 @@ class AssetsTest < ActiveSupport::TestCase
       active: true,
       updated_by_id: 1,
       created_by_id: 1,
-      organization_id: org.id,
+      organization_id: org1.id,
       roles: roles,
       groups: groups,
     )
@@ -54,10 +54,10 @@ class AssetsTest < ActiveSupport::TestCase
     user3 = User.find(user3.id)
     assets = user3.assets({})
 
-    org = Organization.find(org.id)
-    attributes = org.attributes_with_associations
+    org1 = Organization.find(org1.id)
+    attributes = org1.attributes_with_associations
     attributes.delete('user_ids')
-    assert( diff(attributes, assets[:Organization][org.id]), 'check assets')
+    assert( diff(attributes, assets[:Organization][org1.id]), 'check assets')
 
     user1 = User.find(user1.id)
     attributes = user1.attributes_with_associations
@@ -85,7 +85,7 @@ class AssetsTest < ActiveSupport::TestCase
 
     # touch org, check if user1 has changed
     travel 2.seconds
-    org2 = Organization.find(org.id)
+    org2 = Organization.find(org1.id)
     org2.note = "some note...#{rand(9_999_999_999_999)}"
     org2.save
 
@@ -105,7 +105,7 @@ class AssetsTest < ActiveSupport::TestCase
     assets = user3.assets({})
     attributes = org2.attributes_with_associations
     attributes.delete('user_ids')
-    assert( diff(attributes, assets[:Organization][org.id]), 'check assets')
+    assert( diff(attributes, assets[:Organization][org1.id]), 'check assets')
 
     user1 = User.find(user1.id)
     attributes = user1.attributes_with_associations
@@ -130,6 +130,13 @@ class AssetsTest < ActiveSupport::TestCase
     attributes.delete('token_ids')
     attributes.delete('authorization_ids')
     assert( diff(attributes, assets[:User][user3.id]), 'check assets' )
+    travel_back
+
+    user1.destroy
+    user2.destroy
+    user3.destroy
+    org1.destroy
+    org2.destroy
 
   end
 
@@ -148,8 +155,8 @@ class AssetsTest < ActiveSupport::TestCase
       roles: roles,
     )
 
-    roles  = Role.where( name: %w(Customer) )
-    org    = Organization.create_or_update(
+    roles = Role.where( name: %w(Customer) )
+    org   = Organization.create_or_update(
       name: 'some customer org',
       updated_by_id: admin1.id,
       created_by_id: 1,
@@ -261,6 +268,13 @@ class AssetsTest < ActiveSupport::TestCase
     attributes.delete('token_ids')
     attributes.delete('authorization_ids')
     assert( diff(attributes, assets[:User][user_new_2.id]), 'check assets' )
+    travel_back
+
+    user1.destroy
+    user2.destroy
+    user3.destroy
+    org.destroy
+    org_new.destroy
 
   end
 

+ 1 - 0
test/unit/calendar_test.rb

@@ -88,6 +88,7 @@ class CalendarTest < ActiveSupport::TestCase
 
     assert_equal(true, calendar2.default)
     assert_equal(false, calendar3.default)
+    travel_back
   end
 
 end

+ 1 - 1
test/unit/chat_test.rb

@@ -351,7 +351,7 @@ class ChatTest < ActiveSupport::TestCase
     assert_equal(1, agent_state[:seads_available])
     assert_equal(4, agent_state[:seads_total])
     assert_equal(false, agent_state[:active])
-
+    travel_back
   end
 
 end

Some files were not shown because too many files changed in this diff