Merge branch 'develop' into feature/rails4

Conflicts:
	Gemfile
	app/controllers/application_controller.rb
This commit is contained in:
Martin Edenhofer 2013-08-27 23:17:46 +02:00
commit a0cdaf31e7
22 changed files with 189 additions and 223 deletions

View file

@ -136,9 +136,6 @@ class Index extends App.ControllerContent
relogin: (data, status, xhr) => relogin: (data, status, xhr) =>
@log 'notice', 'relogin:success', data @log 'notice', 'relogin:success', data
# login check
App.Auth.loginCheck()
# add notify # add notify
App.Event.trigger 'notify:removeall' App.Event.trigger 'notify:removeall'
# @notify # @notify

View file

@ -3,10 +3,10 @@ class App.Auth
@login: (params) -> @login: (params) ->
App.Log.notice 'Auth', 'login', params App.Log.notice 'Auth', 'login', params
App.Ajax.request( App.Ajax.request(
id: 'login', id: 'login'
type: 'POST', type: 'POST'
url: App.Config.get('api_path') + '/signin', url: App.Config.get('api_path') + '/signin'
data: JSON.stringify(params.data), data: JSON.stringify(params.data)
success: (data, status, xhr) => success: (data, status, xhr) =>
# set login (config, session, ...) # set login (config, session, ...)

View file

@ -11,7 +11,7 @@
</ul> </ul>
--> -->
<p> <p>
<form action="api/packages" method="post" enctype="multipart/form-data"> <form action="<%= App.Config.get('api_path') %>/packages" method="post" enctype="multipart/form-data">
<input type="file" name="file_upload"/> <input type="file" name="file_upload"/>
<button class="btn btn-primary" type="submit"><%- @T('Install Package') %></button> <button class="btn btn-primary" type="submit"><%- @T('Install Package') %></button>
</form> </form>

View file

@ -32,7 +32,7 @@
<% if article.attachments: %> <% if article.attachments: %>
<div> <div>
<% for attachment in article.attachments: %> <% for attachment in article.attachments: %>
<a href="api/ticket_attachment/<%= article.ticket_id %>/<%= article.id %>/<%= attachment.id %>" target="_blank" data-type="attachment" class="" title="<%= attachment.size %>"><%= attachment.filename %></a> <a href="<%= App.Config.get('api_path') %>/ticket_attachment/<%= article.ticket_id %>/<%= article.id %>/<%= attachment.id %>" target="_blank" data-type="attachment" class="" title="<%= attachment.size %>"><%= attachment.filename %></a>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>

View file

@ -76,7 +76,10 @@ class ApplicationController < ActionController::Base
# update session updated_at # update session updated_at
def session_update def session_update
session[:ping] = Time.now.utc.iso8601
# on many paralell requests, session got reinitialised if Time. is used, as workaround use DateTime.
#session[:ping] = Time.now.utc.iso8601
session[:ping] = DateTime.now.iso8601
# check if remote ip need to be updated # check if remote ip need to be updated
if !session[:remote_id] || session[:remote_id] != request.remote_ip if !session[:remote_id] || session[:remote_id] != request.remote_ip

View file

@ -14,7 +14,7 @@ class Observer::Session < ActiveRecord::Observer
def check(record) def check(record)
return if !record.data return if !record.data
return if record[:request_type]
# remember request type # remember request type
if record.data['request_type'] if record.data['request_type']
record[:request_type] = record.data['request_type'] record[:request_type] = record.data['request_type']

View file

@ -53,7 +53,7 @@ returns
end end
} }
if !organization_exists if !organization_exists
organizations.push organization organizations.push organization_by_user
end end
} }
end end

View file

@ -150,6 +150,55 @@ returns
self.save self.save
end end
=begin
return sla for ticket
ticket = Ticket.find(123)
result = ticket.escalation_calculation_get_sla
returns
result = selected_sla
=end
def escalation_calculation_get_sla
sla_selected = nil
sla_list = Cache.get( 'SLA::List::Active' )
if sla_list == nil
sla_list = Sla.where( :active => true ).all
Cache.write( 'SLA::List::Active', sla_list, { :expires_in => 1.hour } )
end
sla_list.each {|sla|
if !sla.condition || sla.condition.empty?
sla_selected = sla
elsif sla.condition
hit = false
map = [
[ 'tickets.ticket_priority_id', 'ticket_priority_id' ],
[ 'tickets.group_id', 'group_id' ]
]
map.each {|item|
if sla.condition[ item[0] ]
if sla.condition[ item[0] ].class == String
sla.condition[ item[0] ] = [ sla.condition[ item[0] ] ]
end
if sla.condition[ item[0] ].include?( self[ item[1] ].to_s )
hit = true
else
hit = false
end
end
}
if hit
sla_selected = sla
end
end
}
sla_selected
end
private private
#type could be: #type could be:
@ -257,44 +306,6 @@ returns
diff diff
end end
def escalation_calculation_get_sla
sla_selected = nil
sla_list = Cache.get( 'SLA::List::Active' )
if sla_list == nil
sla_list = Sla.where( :active => true ).all
Cache.write( 'SLA::List::Active', sla_list, { :expires_in => 1.hour } )
end
sla_list.each {|sla|
if !sla.condition || sla.condition.empty?
sla_selected = sla
elsif sla.condition
hit = false
map = [
[ 'tickets.ticket_priority_id', 'ticket_priority_id' ],
[ 'tickets.group_id', 'group_id' ]
]
map.each {|item|
if sla.condition[ item[0] ]
if sla.condition[ item[0] ].class == String
sla.condition[ item[0] ] = [ sla.condition[ item[0] ] ]
end
if sla.condition[ item[0] ].include?( self[ item[1] ].to_s )
hit = true
else
hit = false
end
end
}
if hit
sla_selected = sla
end
end
}
return sla_selected
end
def calculation_higher_time(escalation_time, check_time, done_time) def calculation_higher_time(escalation_time, check_time, done_time)
return escalation_time if done_time return escalation_time if done_time
return check_time if !escalation_time return check_time if !escalation_time

View file

@ -1,5 +1,6 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'sso'
require 'digest/sha2' require 'digest/sha2'
require 'organization' require 'organization'

View file

@ -23,7 +23,7 @@ class SchedulerUpdate < ActiveRecord::Migration
) )
Scheduler.create_or_update( Scheduler.create_or_update(
:name => 'Generate Session data', :name => 'Generate Session data',
:method => 'Session.jobs', :method => 'Sessions.jobs',
:period => 60, :period => 60,
:prio => 1, :prio => 1,
:active => true, :active => true,

View file

@ -0,0 +1,15 @@
class UpdateScheduler2 < ActiveRecord::Migration
def up
Scheduler.create_or_update(
:name => 'Generate Session data',
:method => 'Sessions.jobs',
:period => 60,
:prio => 1,
:active => true,
:updated_by_id => 1,
:created_by_id => 1,
)
end
def down
end
end

View file

@ -478,7 +478,7 @@ class UserState
cache_key = @cache_key + '_rss' cache_key = @cache_key + '_rss'
if CacheIn.expired(cache_key) if CacheIn.expired(cache_key)
url = 'http://www.heise.de/newsticker/heise-atom.xml' url = 'http://www.heise.de/newsticker/heise-atom.xml'
rss_items = RSS.fetch( url, 8 ) rss_items = Rss.fetch( url, 8 )
rss_items_cache = CacheIn.get( cache_key, { :re_expire => true } ) rss_items_cache = CacheIn.get( cache_key, { :re_expire => true } )
self.log 'notice', 'fetch rss - ' + cache_key self.log 'notice', 'fetch rss - ' + cache_key
if rss_items != rss_items_cache if rss_items != rss_items_cache

View file

@ -64,7 +64,6 @@ class AaaGettingStartedTest < TestCase
{ {
:name => 'getting started - agent 1', :name => 'getting started - agent 1',
:action => [ :action => [
{ {
:execute => 'match', :execute => 'match',
:css => 'body', :css => 'body',
@ -100,16 +99,9 @@ class AaaGettingStartedTest < TestCase
:result => '#getting_started', :result => '#getting_started',
}, },
{ {
:execute => 'wait', :execute => 'watch_for',
:value => 2, :area => 'body',
}, :value => 'Invitation sent',
# check action
{
:execute => 'match',
:css => 'body',
:value => 'Invitation sent',
:match_result => true,
}, },
{ {
:execute => 'match', :execute => 'match',

View file

@ -58,13 +58,12 @@ class AgentTicketActionLevel1Test < TestCase
}, },
{ {
:execute => 'wait', :execute => 'wait',
:value => 4, :value => 2,
}, },
{ {
:execute => 'match', :execute => 'watch_for',
:css => 'body', :area => 'body',
:value => 'some body 1234 äöüß', :value => 'some body 1234 äöüß',
:match_result => true,
}, },
{ {
:execute => 'click', :execute => 'click',

View file

@ -240,15 +240,10 @@ class AgentTicketActionsLevel2Test < TestCase
:css => '.active button', :css => '.active button',
}, },
{ {
:execute => 'wait', :where => :instance1,
:value => 4, :execute => 'watch_for',
}, :area => 'body',
{ :value => 'some update 4711',
:where => :instance1,
:execute => 'match',
:css => 'body',
:value => 'some update 4711',
:match_result => true,
}, },
# verify empty text in input body # verify empty text in input body

View file

@ -25,7 +25,7 @@ class AuthCustomerTest < TestCase
}, },
{ {
:execute => 'wait', :execute => 'wait',
:value => 3, :value => 5,
}, },
{ {
:execute => 'check', :execute => 'check',
@ -68,28 +68,22 @@ class AuthCustomerTest < TestCase
:result => false, :result => false,
}, },
{ {
:execute => 'match', :execute => 'watch_for',
:css => 'body', :area => 'body',
:value => 'nicole.braun@zammad.org', :value => 'nicole.braun@zammad.org',
:match_result => true,
}, },
{ {
:execute => 'reload', :execute => 'reload',
}, },
{ {
:execute => 'wait', :execute => 'watch_for',
:value => 3, :area => 'body',
:value => 'nicole.braun@zammad.org',
}, },
{ {
:execute => 'match', :execute => 'match',
:css => 'body', :element => :cookie,
:value => 'nicole.braun@zammad.org', :value => 'expires=>nil',
:match_result => true,
},
{
:execute => 'match',
:element => :cookie,
:value => 'expires=>nil',
}, },
], ],
}, },
@ -152,7 +146,7 @@ class AuthCustomerTest < TestCase
}, },
{ {
:execute => 'wait', :execute => 'wait',
:value => 3, :value => 6,
}, },
# check action # check action
@ -162,18 +156,17 @@ class AuthCustomerTest < TestCase
:result => false, :result => false,
}, },
{ {
:execute => 'match', :execute => 'watch_for',
:css => 'body', :area => 'body',
:value => 'nicole.braun@zammad.org', :value => 'nicole.braun@zammad.org',
:match_result => true,
}, },
{ {
:execute => 'match', :execute => 'match',
:element => :cookie, :element => :cookie,
:value => 'expires=>.+?\d{4}.+?,', :value => 'expires=>.+?\d{4}.+?,',
}, },
{ {
:execute => 'logout', :execute => 'logout',
}, },
], ],
}, },

View file

@ -25,7 +25,7 @@ class AuthMasterTest < TestCase
}, },
{ {
:execute => 'wait', :execute => 'wait',
:value => 3, :value => 5,
}, },
{ {
:execute => 'check', :execute => 'check',
@ -58,20 +58,19 @@ class AuthMasterTest < TestCase
}, },
{ {
:execute => 'wait', :execute => 'wait',
:value => 3, :value => 5,
}, },
# check action # check action
{ {
:execute => 'check', :execute => 'check',
:css => '#login', :css => '#login',
:result => false, :result => false,
}, },
{ {
:execute => 'match', :execute => 'watch_for',
:css => 'body', :area => 'body',
:value => 'master@example', :value => 'master@example',
:match_result => true,
}, },
], ],
}, },

View file

@ -74,14 +74,9 @@ class CustomerTicketCreateTest < TestCase
:type => 'submit', :type => 'submit',
}, },
{ {
:execute => 'wait', :execute => 'watch_for',
:value => 4, :area => 'body',
}, :value => 'some body 1234 äöüß',
{
:execute => 'match',
:css => 'body',
:value => 'some body 1234 äöüß',
:match_result => true,
}, },
], ],
}, },

View file

@ -58,17 +58,16 @@ class MaintenanceMessageTest < TestCase
:match_result => false, :match_result => false,
}, },
{ {
:where => :instance2, :where => :instance2,
:execute => 'check', :execute => 'check',
:css => '.modal-header', :css => '.modal-header',
:result => true, :result => true,
}, },
{ {
:where => :instance2, :where => :instance2,
:execute => 'match', :execute => 'watch_for',
:css => 'body', :area => 'body',
:value => message, :value => message,
:match_result => true,
}, },
{ {
:where => :instance2, :where => :instance2,
@ -129,16 +128,15 @@ class MaintenanceMessageTest < TestCase
:result => false, :result => false,
}, },
{ {
:where => :instance2, :where => :instance2,
:execute => 'match', :execute => 'watch_for',
:css => 'body', :area => 'body',
:value => message + ' #2', :value => message + ' #2',
:match_result => true,
}, },
{ {
:where => :instance2, :where => :instance2,
:execute => 'click', :execute => 'click',
:css => 'div.modal-header .close', :css => 'div.modal-header .close',
}, },
{ {
:execute => 'wait', :execute => 'wait',

View file

@ -70,14 +70,9 @@ class ManageTest < TestCase
:css => '.modal button.submit', :css => '.modal button.submit',
}, },
{ {
:execute => 'wait', :execute => 'watch_for',
:value => 5, :area => 'body',
}, :value => random,
{
:execute => 'match',
:css => 'body',
:value => random,
:match_result => true,
}, },
{ {
:execute => 'click', :execute => 'click',
@ -97,14 +92,9 @@ class ManageTest < TestCase
:css => '.modal button.submit', :css => '.modal button.submit',
}, },
{ {
:execute => 'wait', :execute => 'watch_for',
:value => 5, :area => 'body',
}, :value => '2Manage Lastname' + random,
{
:execute => 'match',
:css => 'body',
:value => '2Manage Lastname' + random,
:match_result => true,
}, },
{ {
:execute => 'wait', :execute => 'wait',
@ -150,14 +140,9 @@ class ManageTest < TestCase
:css => '.modal button.submit', :css => '.modal button.submit',
}, },
{ {
:execute => 'wait', :execute => 'watch_for',
:value => 5, :area => 'body',
}, :value => random,
{
:execute => 'match',
:css => 'body',
:value => random,
:match_result => true,
}, },
{ {
:execute => 'click', :execute => 'click',
@ -182,14 +167,9 @@ class ManageTest < TestCase
:css => '.modal button.submit', :css => '.modal button.submit',
}, },
{ {
:execute => 'wait', :execute => 'watch_for',
:value => 5, :area => 'body',
}, :value => 'some sla update ' + random,
{
:execute => 'match',
:css => 'body',
:value => 'some sla update ' + random,
:match_result => true,
}, },
{ {
:execute => 'wait', :execute => 'wait',

View file

@ -34,14 +34,9 @@ class PreferencesTest < TestCase
:css => '#language button', :css => '#language button',
}, },
{ {
:execute => 'wait', :execute => 'watch_for',
:value => 6, :area => 'body',
}, :value => 'Sprache',
{
:execute => 'match',
:css => 'body',
:value => 'Sprache',
:match_result => true,
}, },
{ {
:execute => 'select', :execute => 'select',
@ -53,14 +48,9 @@ class PreferencesTest < TestCase
:css => '#language button', :css => '#language button',
}, },
{ {
:execute => 'wait', :execute => 'watch_for',
:value => 4, :area => 'body',
}, :value => 'Language',
{
:execute => 'match',
:css => 'body',
:value => 'Language',
:match_result => true,
}, },
], ],
}, },

View file

@ -52,35 +52,11 @@ class TestCase < Test::Unit::TestCase
end end
end end
local_browser.manage.timeouts.implicit_wait = 3 # seconds local_browser.manage.timeouts.implicit_wait = 3 # seconds
browser_instance_js_on_start(local_browser)
end
def browser_instance_js_on_start(instance)
instance.execute_script('
window.jsErrors = [];
window.onerror = function(errorMessage) {
window.jsErrors.push(errorMessage);
};');
end
def browser_instance_js_on_teardown(instance)
result = instance.execute_script( 'return window.jsErrors;' )
if result
puts 'JS ERRORS: ' + result.inspect
else
puts 'JS ERRORS: -none-'
end
end end
def teardown def teardown
return if !@browsers return if !@browsers
# show js errors
@browsers.each{ |local_browser|
browser_instance_js_on_teardown(local_browser)
}
# only shut down browser type once on local webdriver tests # only shut down browser type once on local webdriver tests
# otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)" # otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)"
if !ENV['REMOTE_URL'] if !ENV['REMOTE_URL']
@ -185,6 +161,13 @@ class TestCase < Test::Unit::TestCase
def browser_element_action(test, action, instance) def browser_element_action(test, action, instance)
puts "NOTICE #{Time.now.to_s}: " + action.inspect puts "NOTICE #{Time.now.to_s}: " + action.inspect
if action[:execute] !~ /accept|dismiss/i
cookies = instance.manage.all_cookies
cookies.each {|cookie|
puts " COOKIE " + cookie.to_s
}
end
sleep 0.1 sleep 0.1
if action[:css] if action[:css]
if action[:css].match '###stack###' if action[:css].match '###stack###'
@ -252,13 +235,26 @@ class TestCase < Test::Unit::TestCase
instance.find_element( { :css => 'a[href="#current_user"]' } ).click instance.find_element( { :css => 'a[href="#current_user"]' } ).click
sleep 0.1 sleep 0.1
instance.find_element( { :css => 'a[href="#logout"]' } ).click instance.find_element( { :css => 'a[href="#logout"]' } ).click
sleep 2 (1..6).each {|loop|
login = instance.find_element( { :css => '#login' } ) login = instance.find_element( { :css => '#login' } )
if !login if login
assert( false, "(#{test[:name]}) no login box found!" ) assert( true, "(#{test[:name]}) logout" )
return return
end end
assert( true, "(#{test[:name]}) logout" ) }
assert( false, "(#{test[:name]}) no login box found!" )
return
elsif action[:execute] == 'watch_for'
(1..24).each { |loop|
element = instance.find_element( { :css => action[:area] } )
text = element.text
if text =~ /#{action[:value]}/i
assert( true, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" )
return
end
sleep 0.5
}
assert( false, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" )
return return
elsif action[:execute] == 'create_ticket' elsif action[:execute] == 'create_ticket'
instance.find_element( { :css => 'a[href="#new"]' } ).click instance.find_element( { :css => 'a[href="#new"]' } ).click
@ -268,7 +264,7 @@ class TestCase < Test::Unit::TestCase
assert( false, "(#{test[:name]}) no ticket create screen found!" ) assert( false, "(#{test[:name]}) no ticket create screen found!" )
return return
end end
sleep 4 sleep 2
element = instance.find_element( { :css => '.active .ticket_create input[name="customer_id_autocompletion"]' } ) element = instance.find_element( { :css => '.active .ticket_create input[name="customer_id_autocompletion"]' } )
element.clear element.clear
element.send_keys( 'nico' ) element.send_keys( 'nico' )
@ -296,12 +292,14 @@ class TestCase < Test::Unit::TestCase
end end
sleep 0.1 sleep 0.1
instance.find_element( { :css => '.active .form-actions button[type="submit"]' } ).click instance.find_element( { :css => '.active .form-actions button[type="submit"]' } ).click
sleep 6 (1..14).each {|loop|
if instance.current_url !~ /#{Regexp.quote('#ticket/zoom/')}/ if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
assert( true, "(#{test[:name]}) ticket creation failed, can't get zoom url" ) assert( true, "(#{test[:name]}) ticket created" )
return return
end end
assert( true, "(#{test[:name]}) ticket created" ) sleep 0.5
}
assert( true, "(#{test[:name]}) ticket creation failed, can't get zoom url" )
return return
elsif action[:execute] == 'close_all_tasks' elsif action[:execute] == 'close_all_tasks'
for i in 1..100 for i in 1..100