Merge branch 'develop' into feature/ui2

This commit is contained in:
Martin Edenhofer 2013-08-27 23:18:56 +02:00
commit b75a383d5f
26 changed files with 197 additions and 225 deletions

View file

@ -93,3 +93,4 @@ group :development, :test do
end
gem 'thin'
#gem 'puma'

View file

@ -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

View file

@ -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, ...)

View file

@ -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>

View file

@ -33,7 +33,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 %>

View file

@ -14,6 +14,7 @@ class ApplicationController < ActionController::Base
:mode_show_rendeder,
:model_index_render
skip_filter :verify_authenticity_token
before_filter :log_request, :set_user, :session_update
before_filter :cors_preflight_check
@ -79,7 +80,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

View file

@ -19,7 +19,7 @@ curl http://localhost/api/v1/rss_fetch.json -v -u #{login}:#{password} -H "Conte
=end
def fetch
items = RSS.fetch(params[:url], params[:limit])
items = Rss.fetch(params[:url], params[:limit])
if items == nil
render :json => { :message => "failed to fetch #{ params[:url] }", :status => :unprocessable_entity }
return

View file

@ -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']

View file

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

View file

@ -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

View file

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

View file

@ -32,6 +32,9 @@ Zammad::Application.configure do
# Do not compress assets
config.assets.compress = false
# Deliver all in one application.(js|css) file
#config.assets.debug = false
# Expands the lines which load the assets
config.assets.debug = true
end

View file

@ -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,

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

@ -1,4 +1,5 @@
module RSS
require 'simple-rss'
module Rss
def self.fetch(url, limit = 10)
cache_key = 'rss::' + url
items = Cache.get( cache_key )

View file

@ -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

View file

@ -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',
:value => 'Invitation sent',
:match_result => true,
:execute => 'watch_for',
:area => 'body',
:value => 'Invitation sent',
},
{
:execute => 'match',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -29,14 +29,9 @@ class PreferencesTest < TestCase
:css => '.content button[type="submit"]',
},
{
:execute => 'wait',
:value => 6,
},
{
:execute => 'match',
:css => 'body',
:value => 'Sprache',
:match_result => true,
:execute => 'watch_for',
:area => 'body',
:value => 'Sprache',
},
{
:execute => 'select',
@ -48,14 +43,9 @@ class PreferencesTest < TestCase
:css => '.content button[type="submit"]',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'match',
:css => 'body',
:value => 'Language',
:match_result => true,
:execute => 'watch_for',
:area => 'body',
:value => 'Language',
},
],
},

View file

@ -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
login = instance.find_element( { :css => '#login' } )
if !login
assert( false, "(#{test[:name]}) no login box found!" )
return
end
assert( true, "(#{test[:name]}) logout" )
(1..6).each {|loop|
login = instance.find_element( { :css => '#login' } )
if login
assert( true, "(#{test[:name]}) logout" )
return
end
}
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" )
return
end
assert( true, "(#{test[:name]}) ticket created" )
(1..14).each {|loop|
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
assert( true, "(#{test[:name]}) ticket created" )
return
end
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