diff --git a/Gemfile b/Gemfile index 5690a0b8f..271636bed 100644 --- a/Gemfile +++ b/Gemfile @@ -93,3 +93,4 @@ group :development, :test do end gem 'thin' +#gem 'puma' diff --git a/app/assets/javascripts/app/controllers/getting_started.js.coffee b/app/assets/javascripts/app/controllers/getting_started.js.coffee index edf8f1606..8a80fbd27 100644 --- a/app/assets/javascripts/app/controllers/getting_started.js.coffee +++ b/app/assets/javascripts/app/controllers/getting_started.js.coffee @@ -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 diff --git a/app/assets/javascripts/app/lib/app_post/auth.js.coffee b/app/assets/javascripts/app/lib/app_post/auth.js.coffee index 9a29ab087..af6aa6093 100644 --- a/app/assets/javascripts/app/lib/app_post/auth.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/auth.js.coffee @@ -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, ...) diff --git a/app/assets/javascripts/app/views/package.jst.eco b/app/assets/javascripts/app/views/package.jst.eco index e16c6acc1..bed004d08 100644 --- a/app/assets/javascripts/app/views/package.jst.eco +++ b/app/assets/javascripts/app/views/package.jst.eco @@ -11,7 +11,7 @@ -->

-

+
diff --git a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco index 6e0dc58bb..cf133925c 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco @@ -33,7 +33,7 @@ <% if article.attachments: %>
<% for attachment in article.attachments: %> - <%= attachment.filename %> + <%= attachment.filename %> <% end %>
<% end %> diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c37b92707..f146683fa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/rss_controller.rb b/app/controllers/rss_controller.rb index c249e61ba..3ec80406f 100644 --- a/app/controllers/rss_controller.rb +++ b/app/controllers/rss_controller.rb @@ -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 diff --git a/app/models/observer/session.rb b/app/models/observer/session.rb index 7847a20a9..fdd96c2f8 100644 --- a/app/models/observer/session.rb +++ b/app/models/observer/session.rb @@ -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'] diff --git a/app/models/organization/search.rb b/app/models/organization/search.rb index 9d048bb0d..c24969d29 100644 --- a/app/models/organization/search.rb +++ b/app/models/organization/search.rb @@ -53,7 +53,7 @@ returns end } if !organization_exists - organizations.push organization + organizations.push organization_by_user end } end diff --git a/app/models/ticket/escalation.rb b/app/models/ticket/escalation.rb index 085071369..9ec408d39 100644 --- a/app/models/ticket/escalation.rb +++ b/app/models/ticket/escalation.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 71418fc9f..b89a2aa88 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,6 @@ # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +require 'sso' require 'digest/sha2' require 'organization' diff --git a/config/environments/development.rb b/config/environments/development.rb index 01170151e..c9d05dbe1 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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 diff --git a/db/migrate/20130502000001_scheduler_update.rb b/db/migrate/20130502000001_scheduler_update.rb index 573cb4215..5ba8c9861 100644 --- a/db/migrate/20130502000001_scheduler_update.rb +++ b/db/migrate/20130502000001_scheduler_update.rb @@ -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, diff --git a/db/migrate/20130826000001_update_scheduler2.rb b/db/migrate/20130826000001_update_scheduler2.rb new file mode 100644 index 000000000..1289d5fb2 --- /dev/null +++ b/db/migrate/20130826000001_update_scheduler2.rb @@ -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 diff --git a/lib/rss.rb b/lib/rss.rb index 2925a8a2f..083f04bce 100644 --- a/lib/rss.rb +++ b/lib/rss.rb @@ -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 ) diff --git a/lib/sessions.rb b/lib/sessions.rb index c3eba8b72..e8d5402b0 100644 --- a/lib/sessions.rb +++ b/lib/sessions.rb @@ -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 diff --git a/test/browser/aaa_getting_started_test.rb b/test/browser/aaa_getting_started_test.rb index 899515f48..702d03e58 100644 --- a/test/browser/aaa_getting_started_test.rb +++ b/test/browser/aaa_getting_started_test.rb @@ -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', diff --git a/test/browser/agent_ticket_actions_level1_test.rb b/test/browser/agent_ticket_actions_level1_test.rb index 0a1046ae8..83e1c0eb3 100644 --- a/test/browser/agent_ticket_actions_level1_test.rb +++ b/test/browser/agent_ticket_actions_level1_test.rb @@ -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', diff --git a/test/browser/agent_ticket_actions_level2_test.rb b/test/browser/agent_ticket_actions_level2_test.rb index 9a47f6c0b..7a6525d19 100644 --- a/test/browser/agent_ticket_actions_level2_test.rb +++ b/test/browser/agent_ticket_actions_level2_test.rb @@ -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 diff --git a/test/browser/auth_customer_test.rb b/test/browser/auth_customer_test.rb index ea923bbdd..4f9646885 100644 --- a/test/browser/auth_customer_test.rb +++ b/test/browser/auth_customer_test.rb @@ -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', }, ], }, diff --git a/test/browser/auth_master_test.rb b/test/browser/auth_master_test.rb index 392bb244f..571a984ee 100644 --- a/test/browser/auth_master_test.rb +++ b/test/browser/auth_master_test.rb @@ -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', }, ], }, diff --git a/test/browser/customer_ticket_create_test.rb b/test/browser/customer_ticket_create_test.rb index d22f50045..4e07d65da 100644 --- a/test/browser/customer_ticket_create_test.rb +++ b/test/browser/customer_ticket_create_test.rb @@ -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 äöüß', }, ], }, diff --git a/test/browser/maintenance_message_test.rb b/test/browser/maintenance_message_test.rb index e33617a9d..297e8269e 100644 --- a/test/browser/maintenance_message_test.rb +++ b/test/browser/maintenance_message_test.rb @@ -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', diff --git a/test/browser/manage_test.rb b/test/browser/manage_test.rb index 1ece0ac39..7e2c267e0 100644 --- a/test/browser/manage_test.rb +++ b/test/browser/manage_test.rb @@ -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', diff --git a/test/browser/prefereces_test.rb b/test/browser/prefereces_test.rb index 59afd0918..a1c1f42fc 100644 --- a/test/browser/prefereces_test.rb +++ b/test/browser/prefereces_test.rb @@ -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', }, ], }, diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index f07e7c4ef..cc5f4036a 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -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