Browse Source

Removed not longer needed organization session collection tests.

Martin Edenhofer 8 years ago
parent
commit
d3a428cdca

+ 6 - 78
test/unit/session_basic_test.rb

@@ -2,6 +2,12 @@
 require 'test_helper'
 
 class SessionBasicTest < ActiveSupport::TestCase
+
+  user = User.lookup(id: 1)
+  roles = Role.where(name: %w(Agent Admin))
+  user.roles = roles
+  user.save
+
   test 'a cache' do
     Sessions::CacheIn.set('last_run_test', true, { expires_in: 2.seconds })
     result = Sessions::CacheIn.get('last_run_test')
@@ -179,84 +185,6 @@ class SessionBasicTest < ActiveSupport::TestCase
     assert_equal(result1, result2, 'check collections')
   end
 
-  user = User.lookup(id: 1)
-  roles = Role.where(name: %w(Agent Admin))
-  user.roles = roles
-  user.save
-
-  test 'c collections organization' do
-    require 'sessions/backend/collections/organization.rb'
-    UserInfo.current_user_id = 2
-
-    # create users
-    roles        = Role.where(name: ['Agent'])
-    groups       = Group.all
-    organization = Organization.create( name: "SomeOrg1::#{rand(999_999)}", active: true )
-
-    agent2 = User.create_or_update(
-      login: 'session-agent-2',
-      firstname: 'Session',
-      lastname: 'Agent 2',
-      email: 'session-agent2@example.com',
-      password: 'agentpw',
-      active: true,
-      roles: roles,
-      groups: groups,
-      organization: organization,
-    )
-    agent2.roles = roles
-    agent2.save
-
-    collection_client1 = Sessions::Backend::Collections::Organization.new(agent2, {}, false, '123-1', 3)
-    collection_client2 = Sessions::Backend::Collections::Organization.new(agent2, {}, false, '234-2', 3)
-
-    # get collection - should be nil, no chnaged org exists!
-    result1 = collection_client1.push
-    assert(!result1.empty?, 'check collections')
-    result2 = collection_client2.push
-    assert(!result2.empty?, 'check collections')
-    assert_equal(result1, result2, 'check collections')
-
-    # next check - should still be nil, no org exists!
-    result1 = collection_client1.push
-    assert(!result1, 'check collections - recall')
-    sleep 0.6
-    result2 = collection_client2.push
-    assert(!result2, 'check collections - recall')
-
-    # change collection
-    organization.name = "#{organization.name}-2"
-    organization.save
-    #organization = Organization.create(name: "SomeOrg2::#{rand(999_999)}", active: true)
-    sleep 4
-
-    # get collection
-    result1 = collection_client1.push
-    assert(!result1.empty?, 'check collections - after create')
-    result2 = collection_client2.push
-    assert(!result2.empty?, 'check collections - after create')
-    assert_equal(result1, result2, 'check collections')
-
-    sleep 4
-
-    # next check should be empty
-    result1 = collection_client1.push
-    assert(!result1, 'check collections - after create recall')
-    result2 = collection_client2.push
-    assert(!result2, 'check collections - after create recall')
-
-    organization = Organization.first
-    organization.touch
-    sleep 4
-
-    # get collection
-    result1 = collection_client1.push
-    assert(!result1.empty?, 'check collections - after touch')
-    result2 = collection_client2.push
-    assert(!result1.empty?, 'check collections - after touch')
-    assert_equal(result1, result2, 'check collections')
-  end
-
   test 'c rss' do
     user = User.lookup(id: 1)
     collection_client1 = Sessions::Backend::Rss.new(user, {}, false, '123-1')

+ 0 - 51
test/unit/session_collections_test.rb

@@ -109,57 +109,6 @@ class SessionCollectionsTest < ActiveSupport::TestCase
     assert(result3, 'check collections - after touch')
     assert(check_if_collection_exists(result3, :Group), 'check collections - after touch')
 
-    # change collection
-    organization = Organization.create(name: "SomeSessionOrg1::#{rand(999_999)}", active: true)
-
-    # get whole collections
-    result1 = collection_client1.push
-    assert(result1, 'check collections - after create')
-    assert(!check_if_collection_exists(result1, :Organization), 'check collections - after create')
-    result2 = collection_client2.push
-    assert(result2, 'check collections - after create')
-    assert(!check_if_collection_exists(result2, :Organization), 'check collections - after create')
-    result3 = collection_client3.push
-    assert(result3, 'check collections - after create')
-    assert(!check_if_collection_exists(result3, :Organization), 'check collections - after create')
-
-    # assigne new org to agent1
-    agent1.organization = organization
-    agent1.save
-    sleep 4
-
-    # user has new organization
-    result1 = collection_client1.push
-    assert(result1, 'check collections - after create')
-    assert(check_if_collection_exists(result1, :Organization, { id: organization.id, member_ids: [agent1.id] }), 'check collections - after create with attributes')
-    sleep 0.3
-
-    # users have no organization, so collection should be empty
-    result2 = collection_client2.push
-    assert(result2, 'check collections - after create')
-    assert(!check_if_collection_exists(result2, :Organization), 'check collections - after create')
-    result3 = collection_client3.push
-    assert(result3, 'check collections - after create')
-    assert(!check_if_collection_exists(result3, :Organization), 'check collections - after create')
-
-    # assigne new org to customer1
-    customer1.organization = organization
-    customer1.save
-    sleep 5
-
-    # users have no organization, so collection should be empty
-    result1 = collection_client1.push
-    assert(result1, 'check collections - after create')
-    assert(check_if_collection_exists(result1, :Organization, { id: organization.id, member_ids: [agent1.id, customer1.id] }), 'check collections - after create with attributes')
-    result2 = collection_client2.push
-    assert(result2, 'check collections - after create')
-    assert(!check_if_collection_exists(result2, :Organization), 'check collections - after create')
-
-    # user has new organization
-    result3 = collection_client3.push
-    assert(result3, 'check collections - after create')
-    assert(check_if_collection_exists(result3, :Organization, { id: organization.id, member_ids: [agent1.id, customer1.id] }), 'check collections - after create with attributes')
-
     # next check should be empty
     sleep 1
     result1 = collection_client1.push

+ 8 - 12
test/unit/session_enhanced_test.rb

@@ -239,18 +239,16 @@ class SessionEnhancedTest < ActiveSupport::TestCase
 
     # check collections
     collections = {
-      'Group'        => true,
-      'Organization' => true,
-      'User'         => nil,
+      'Group' => true,
+      'User'  => nil,
     }
     check_if_collection_reset_message_exists(client_id1_0, collections, 'init')
     check_if_collection_reset_message_exists(client_id1_1, collections, 'init')
     check_if_collection_reset_message_exists(client_id2, collections, 'init')
 
     collections = {
-      'Group'        => nil,
-      'Organization' => nil,
-      'User'         => nil,
+      'Group' => nil,
+      'User'  => nil,
     }
     check_if_collection_reset_message_exists(client_id1_0, collections, 'init2')
     check_if_collection_reset_message_exists(client_id1_1, collections, 'init2')
@@ -259,9 +257,8 @@ class SessionEnhancedTest < ActiveSupport::TestCase
     sleep 11
 
     collections = {
-      'Group'        => nil,
-      'Organization' => nil,
-      'User'         => nil,
+      'Group' => nil,
+      'User'  => nil,
     }
     check_if_collection_reset_message_exists(client_id1_0, collections, 'init3')
     check_if_collection_reset_message_exists(client_id1_1, collections, 'init3')
@@ -275,9 +272,8 @@ class SessionEnhancedTest < ActiveSupport::TestCase
 
     # check collections
     collections = {
-      'Group'        => true,
-      'Organization' => nil,
-      'User'         => nil,
+      'Group' => true,
+      'User'  => nil,
     }
     check_if_collection_reset_message_exists(client_id1_0, collections, 'update')
     check_if_collection_reset_message_exists(client_id1_1, collections, 'update')