Merge branch 'develop' into feature/rails4
Conflicts: Gemfile app/controllers/application_controller.rb
This commit is contained in:
commit
a0cdaf31e7
22 changed files with 189 additions and 223 deletions
|
@ -136,9 +136,6 @@ class Index extends App.ControllerContent
|
|||
relogin: (data, status, xhr) =>
|
||||
@log 'notice', 'relogin:success', data
|
||||
|
||||
# login check
|
||||
App.Auth.loginCheck()
|
||||
|
||||
# add notify
|
||||
App.Event.trigger 'notify:removeall'
|
||||
# @notify
|
||||
|
|
|
@ -3,10 +3,10 @@ class App.Auth
|
|||
@login: (params) ->
|
||||
App.Log.notice 'Auth', 'login', params
|
||||
App.Ajax.request(
|
||||
id: 'login',
|
||||
type: 'POST',
|
||||
url: App.Config.get('api_path') + '/signin',
|
||||
data: JSON.stringify(params.data),
|
||||
id: 'login'
|
||||
type: 'POST'
|
||||
url: App.Config.get('api_path') + '/signin'
|
||||
data: JSON.stringify(params.data)
|
||||
success: (data, status, xhr) =>
|
||||
|
||||
# set login (config, session, ...)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</ul>
|
||||
-->
|
||||
<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"/>
|
||||
<button class="btn btn-primary" type="submit"><%- @T('Install Package') %></button>
|
||||
</form>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<% if article.attachments: %>
|
||||
<div>
|
||||
<% 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 %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -76,7 +76,10 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
# update session updated_at
|
||||
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
|
||||
if !session[:remote_id] || session[:remote_id] != request.remote_ip
|
||||
|
|
|
@ -14,7 +14,7 @@ class Observer::Session < ActiveRecord::Observer
|
|||
|
||||
def check(record)
|
||||
return if !record.data
|
||||
|
||||
return if record[:request_type]
|
||||
# remember request type
|
||||
if record.data['request_type']
|
||||
record[:request_type] = record.data['request_type']
|
||||
|
|
|
@ -53,7 +53,7 @@ returns
|
|||
end
|
||||
}
|
||||
if !organization_exists
|
||||
organizations.push organization
|
||||
organizations.push organization_by_user
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
@ -150,6 +150,55 @@ returns
|
|||
self.save
|
||||
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
|
||||
|
||||
#type could be:
|
||||
|
@ -257,44 +306,6 @@ returns
|
|||
diff
|
||||
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)
|
||||
return escalation_time if done_time
|
||||
return check_time if !escalation_time
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
require 'sso'
|
||||
require 'digest/sha2'
|
||||
require 'organization'
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class SchedulerUpdate < ActiveRecord::Migration
|
|||
)
|
||||
Scheduler.create_or_update(
|
||||
:name => 'Generate Session data',
|
||||
:method => 'Session.jobs',
|
||||
:method => 'Sessions.jobs',
|
||||
:period => 60,
|
||||
:prio => 1,
|
||||
:active => true,
|
||||
|
|
15
db/migrate/20130826000001_update_scheduler2.rb
Normal file
15
db/migrate/20130826000001_update_scheduler2.rb
Normal 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
|
|
@ -478,7 +478,7 @@ class UserState
|
|||
cache_key = @cache_key + '_rss'
|
||||
if CacheIn.expired(cache_key)
|
||||
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 } )
|
||||
self.log 'notice', 'fetch rss - ' + cache_key
|
||||
if rss_items != rss_items_cache
|
||||
|
|
|
@ -64,7 +64,6 @@ class AaaGettingStartedTest < TestCase
|
|||
{
|
||||
:name => 'getting started - agent 1',
|
||||
:action => [
|
||||
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
|
@ -100,16 +99,9 @@ class AaaGettingStartedTest < TestCase
|
|||
:result => '#getting_started',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 2,
|
||||
},
|
||||
|
||||
# check action
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'Invitation sent',
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
|
|
|
@ -58,13 +58,12 @@ class AgentTicketActionLevel1Test < TestCase
|
|||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 4,
|
||||
:value => 2,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'some body 1234 äöüß',
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'click',
|
||||
|
|
|
@ -239,16 +239,11 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
:execute => 'click',
|
||||
:css => '.active button',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 4,
|
||||
},
|
||||
{
|
||||
:where => :instance1,
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'some update 4711',
|
||||
:match_result => true,
|
||||
},
|
||||
|
||||
# verify empty text in input body
|
||||
|
|
|
@ -25,7 +25,7 @@ class AuthCustomerTest < TestCase
|
|||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 3,
|
||||
:value => 5,
|
||||
},
|
||||
{
|
||||
:execute => 'check',
|
||||
|
@ -68,23 +68,17 @@ class AuthCustomerTest < TestCase
|
|||
:result => false,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'nicole.braun@zammad.org',
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'reload',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 3,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'nicole.braun@zammad.org',
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
|
@ -152,7 +146,7 @@ class AuthCustomerTest < TestCase
|
|||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 3,
|
||||
:value => 6,
|
||||
},
|
||||
|
||||
# check action
|
||||
|
@ -162,10 +156,9 @@ class AuthCustomerTest < TestCase
|
|||
:result => false,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'nicole.braun@zammad.org',
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
|
|
|
@ -25,7 +25,7 @@ class AuthMasterTest < TestCase
|
|||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 3,
|
||||
:value => 5,
|
||||
},
|
||||
{
|
||||
:execute => 'check',
|
||||
|
@ -58,7 +58,7 @@ class AuthMasterTest < TestCase
|
|||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 3,
|
||||
:value => 5,
|
||||
},
|
||||
|
||||
# check action
|
||||
|
@ -68,10 +68,9 @@ class AuthMasterTest < TestCase
|
|||
:result => false,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'master@example',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -74,14 +74,9 @@ class CustomerTicketCreateTest < TestCase
|
|||
:type => 'submit',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 4,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'some body 1234 äöüß',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -65,10 +65,9 @@ class MaintenanceMessageTest < TestCase
|
|||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => message,
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
|
@ -130,10 +129,9 @@ class MaintenanceMessageTest < TestCase
|
|||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => message + ' #2',
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
|
|
|
@ -70,14 +70,9 @@ class ManageTest < TestCase
|
|||
:css => '.modal button.submit',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 5,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => random,
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'click',
|
||||
|
@ -97,14 +92,9 @@ class ManageTest < TestCase
|
|||
:css => '.modal button.submit',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 5,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => '2Manage Lastname' + random,
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
|
@ -150,14 +140,9 @@ class ManageTest < TestCase
|
|||
:css => '.modal button.submit',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 5,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => random,
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'click',
|
||||
|
@ -182,14 +167,9 @@ class ManageTest < TestCase
|
|||
:css => '.modal button.submit',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 5,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'some sla update ' + random,
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
|
|
|
@ -34,14 +34,9 @@ class PreferencesTest < TestCase
|
|||
:css => '#language button',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 6,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'Sprache',
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'select',
|
||||
|
@ -53,14 +48,9 @@ class PreferencesTest < TestCase
|
|||
:css => '#language button',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 4,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => 'body',
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'Language',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -52,35 +52,11 @@ class TestCase < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
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
|
||||
|
||||
def teardown
|
||||
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
|
||||
# otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)"
|
||||
if !ENV['REMOTE_URL']
|
||||
|
@ -185,6 +161,13 @@ class TestCase < Test::Unit::TestCase
|
|||
|
||||
def browser_element_action(test, action, instance)
|
||||
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
|
||||
if action[:css]
|
||||
if action[:css].match '###stack###'
|
||||
|
@ -252,13 +235,26 @@ class TestCase < Test::Unit::TestCase
|
|||
instance.find_element( { :css => 'a[href="#current_user"]' } ).click
|
||||
sleep 0.1
|
||||
instance.find_element( { :css => 'a[href="#logout"]' } ).click
|
||||
sleep 2
|
||||
(1..6).each {|loop|
|
||||
login = instance.find_element( { :css => '#login' } )
|
||||
if !login
|
||||
assert( false, "(#{test[:name]}) no login box found!" )
|
||||
if login
|
||||
assert( true, "(#{test[:name]}) logout" )
|
||||
return
|
||||
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
|
||||
elsif action[:execute] == 'create_ticket'
|
||||
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!" )
|
||||
return
|
||||
end
|
||||
sleep 4
|
||||
sleep 2
|
||||
element = instance.find_element( { :css => '.active .ticket_create input[name="customer_id_autocompletion"]' } )
|
||||
element.clear
|
||||
element.send_keys( 'nico' )
|
||||
|
@ -296,12 +292,14 @@ class TestCase < Test::Unit::TestCase
|
|||
end
|
||||
sleep 0.1
|
||||
instance.find_element( { :css => '.active .form-actions button[type="submit"]' } ).click
|
||||
sleep 6
|
||||
if instance.current_url !~ /#{Regexp.quote('#ticket/zoom/')}/
|
||||
assert( true, "(#{test[:name]}) ticket creation failed, can't get zoom url" )
|
||||
(1..14).each {|loop|
|
||||
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
|
||||
assert( true, "(#{test[:name]}) ticket created" )
|
||||
return
|
||||
end
|
||||
assert( true, "(#{test[:name]}) ticket created" )
|
||||
sleep 0.5
|
||||
}
|
||||
assert( true, "(#{test[:name]}) ticket creation failed, can't get zoom url" )
|
||||
return
|
||||
elsif action[:execute] == 'close_all_tasks'
|
||||
for i in 1..100
|
||||
|
|
Loading…
Reference in a new issue