Merge branch 'develop' of https://github.com/martini/zammad into feature/maintenance_message

This commit is contained in:
Johannes Nickel 2013-06-08 15:13:37 +02:00
commit 7365fab85c
3 changed files with 186 additions and 7 deletions

View file

@ -10,7 +10,7 @@ class History < ApplicationModel
@@cache_object = {} @@cache_object = {}
@@cache_attribute = {} @@cache_attribute = {}
def self.history_create(data) def self.history_create(data)
# lookups # lookups
if data[:history_type] if data[:history_type]
@ -179,7 +179,7 @@ class History < ApplicationModel
if item['history_object'] == 'User' if item['history_object'] == 'User'
users[ item['o_id'] ] = User.user_data_full( item['o_id'] ) users[ item['o_id'] ] = User.user_data_full( item['o_id'] )
end end
# load users # load users
if !users[ item['created_by_id'] ] if !users[ item['created_by_id'] ]
users[ item['created_by_id'] ] = User.user_data_full( item['created_by_id'] ) users[ item['created_by_id'] ] = User.user_data_full( item['created_by_id'] )
@ -227,7 +227,7 @@ class History < ApplicationModel
return history_type return history_type
end end
def self.history_object_lookup_id( id ) def self.history_object_lookup_id( id )
# use cache # use cache
return @@cache_object[ id ] if @@cache_object[ id ] return @@cache_object[ id ] if @@cache_object[ id ]
@ -238,7 +238,7 @@ class History < ApplicationModel
return history_object return history_object
end end
def self.history_object_lookup( name ) def self.history_object_lookup( name )
# use cache # use cache
return @@cache_object[ name ] if @@cache_object[ name ] return @@cache_object[ name ] if @@cache_object[ name ]
@ -258,7 +258,7 @@ class History < ApplicationModel
return history_object return history_object
end end
def self.history_attribute_lookup( name ) def self.history_attribute_lookup( name )
# use cache # use cache
return @@cache_attribute[ name ] if @@cache_attribute[ name ] return @@cache_attribute[ name ] if @@cache_attribute[ name ]

View file

@ -39,7 +39,7 @@ class Observer::History < ActiveRecord::Observer
# do not send anything if nothing has changed # do not send anything if nothing has changed
return if current.attributes == record.attributes return if current.attributes == record.attributes
puts "HISTORY OBSERVER, object will be updated #{ record.class.name.to_s}.find(#{ current.id.to_s })" puts "HISTORY OBSERVER, object will be updated #{ record.class.name.to_s}.find(#{ current.id.to_s })"
# puts 'current' # puts 'current'
# puts current.inspect # puts current.inspect
@ -169,4 +169,4 @@ class Observer::History < ActiveRecord::Observer
end end
h h
end end
end end

View file

@ -0,0 +1,179 @@
# encoding: utf-8
require 'browser_test_helper'
class TaskbarTest < TestCase
def test_current_session_a_same_agent
tests = [
{
:name => 'start',
:instance1 => browser_instance,
:instance2 => browser_instance,
:instance1_username => 'master@example.com',
:instance1_password => 'test',
:instance2_username => 'master@example.com',
:instance2_password => 'test',
:url => browser_url,
:action => [
{
:where => :instance1,
:execute => 'check',
:css => '#login',
:result => false,
},
{
:where => :instance2,
:execute => 'check',
:css => '#login',
:result => false,
},
{
:execute => 'wait',
:value => 5,
},
{
:where => :instance1,
:execute => 'match',
:css => 'body',
:value => 'Reload application',
:match_result => true,
},
{
:where => :instance2,
:execute => 'match',
:css => 'body',
:value => 'Reload application',
:match_result => false,
},
# {
# :execute => 'wait',
# :value => 1,
# },
],
},
]
browser_double_test(tests)
end
def test_current_session_b_different_agent
tests = [
{
:name => 'start',
:instance1 => browser_instance,
:instance2 => browser_instance,
:instance1_username => 'master@example.com',
:instance1_password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:url => browser_url,
:action => [
{
:where => :instance1,
:execute => 'check',
:css => '#login',
:result => false,
},
{
:where => :instance2,
:execute => 'check',
:css => '#login',
:result => false,
},
{
:execute => 'wait',
:value => 5,
},
{
:where => :instance1,
:execute => 'match',
:css => 'body',
:value => 'Reload application',
:match_result => false,
},
{
:where => :instance2,
:execute => 'match',
:css => 'body',
:value => 'Reload application',
:match_result => false,
},
# {
# :execute => 'wait',
# :value => 1,
# },
],
},
]
browser_double_test(tests)
end
def test_persistant_task_a
tests = [
{
:name => 'persistant task',
:action => [
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket_create/call_inbound"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '.active .ticket_create',
:result => true,
},
{
:execute => 'set',
:css => '.active .ticket_create input[name="subject"]',
:value => 'some test AAA',
},
{
:execute => 'wait',
:value => 20,
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
end
def test_persistant_task_b
tests = [
{
:name => 'persistant task',
:action => [
{
:execute => 'wait',
:value => 6,
},
{
:execute => 'click',
:css => '.task',
},
{
:execute => 'match',
:css => 'body',
:value => 'some test AAA',
:match_result => true,
},
{
:execute => 'click',
:css => '.taskbar [data-type="close"]',
},
{
:execute => 'match',
:css => 'body',
:value => 'some test AAA',
:match_result => false,
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'agent1@example.com' })
end
end