From 0ffcbe2ac0a70123a3accbe4d84dd48a89fd0987 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 21 Aug 2013 21:38:15 +0200 Subject: [PATCH 01/19] Added some comment. --- config/environments/development.rb | 3 +++ 1 file changed, 3 insertions(+) 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 From 5878b239dc7ba83c949fcb204b3b5fe8102870fc Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 22 Aug 2013 22:21:52 +0200 Subject: [PATCH 02/19] Renamed module name. --- app/controllers/rss_controller.rb | 2 +- lib/rss.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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/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 ) From fd003053cfa06bb254de50db13c91cc1e3799019 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 25 Aug 2013 22:47:22 +0200 Subject: [PATCH 03/19] Removed js error checks. --- test/browser_test_helper.rb | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index f07e7c4ef..db38b3424 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'] From b6398744b02aef9b01393c92a59de760899b0e3a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 25 Aug 2013 23:34:54 +0200 Subject: [PATCH 04/19] Fixed "lost session cookie" bug. --- app/controllers/application_controller.rb | 5 ++++- app/models/observer/session.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c37b92707..da33e0a65 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -79,7 +79,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/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'] From 5b7cd7e47893e33833179be5042d514d14c8356f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 25 Aug 2013 23:47:57 +0200 Subject: [PATCH 05/19] Updated api path. --- app/assets/javascripts/app/views/package.jst.eco | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/views/package.jst.eco b/app/assets/javascripts/app/views/package.jst.eco index e16c6acc1..d7b36ce12 100644 --- a/app/assets/javascripts/app/views/package.jst.eco +++ b/app/assets/javascripts/app/views/package.jst.eco @@ -11,7 +11,7 @@ -->

-

+
From 49896bbcef658c3a608ee5c86d6714fb7f08d657 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 26 Aug 2013 01:04:41 +0200 Subject: [PATCH 06/19] Moved escalation_calculation_get_sla to public. --- app/models/ticket/escalation.rb | 87 +++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 38 deletions(-) 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 From 990c37e16e41fc85414bc3bbaa1c90e8e12a1458 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 26 Aug 2013 01:14:23 +0200 Subject: [PATCH 07/19] Improved browser timing. --- test/browser/auth_customer_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/browser/auth_customer_test.rb b/test/browser/auth_customer_test.rb index ea923bbdd..745f20e76 100644 --- a/test/browser/auth_customer_test.rb +++ b/test/browser/auth_customer_test.rb @@ -152,7 +152,7 @@ class AuthCustomerTest < TestCase }, { :execute => 'wait', - :value => 3, + :value => 6, }, # check action From b6094a3e848f274453013e45707ac6fdd88a49c3 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 26 Aug 2013 01:23:10 +0200 Subject: [PATCH 08/19] Fixed module name. --- db/migrate/20130502000001_scheduler_update.rb | 2 +- db/migrate/20130826000001_update_scheduler2 | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20130826000001_update_scheduler2 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 b/db/migrate/20130826000001_update_scheduler2 new file mode 100644 index 000000000..1289d5fb2 --- /dev/null +++ b/db/migrate/20130826000001_update_scheduler2 @@ -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 From a7c2b33390c6b68a37b3e2efe9c55436b7322df9 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 26 Aug 2013 01:27:44 +0200 Subject: [PATCH 09/19] Renamed file name. --- ...01_update_scheduler2 => 20130826000001_update_scheduler2.rb} | 0 lib/sessions.rb | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename db/migrate/{20130826000001_update_scheduler2 => 20130826000001_update_scheduler2.rb} (100%) diff --git a/db/migrate/20130826000001_update_scheduler2 b/db/migrate/20130826000001_update_scheduler2.rb similarity index 100% rename from db/migrate/20130826000001_update_scheduler2 rename to db/migrate/20130826000001_update_scheduler2.rb diff --git a/lib/sessions.rb b/lib/sessions.rb index 4c6f98903..ddf97a92b 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 From e216d4a05662959304571f78592dc00dc555b6f6 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 26 Aug 2013 10:04:39 +0200 Subject: [PATCH 10/19] Fixed download api link. --- .../javascripts/app/views/ticket_zoom/article_view.jst.eco | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 31637ea78..c8c21c3fd 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 @@ -32,7 +32,7 @@ <% if article.attachments: %>
<% for attachment in article.attachments: %> - <%= attachment.filename %> + <%= attachment.filename %> <% end %>
<% end %> From 6b01ec8c44708988e76e33e28b3ba5e24026a769 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 26 Aug 2013 10:06:52 +0200 Subject: [PATCH 11/19] Fixed api link. --- app/assets/javascripts/app/views/package.jst.eco | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/views/package.jst.eco b/app/assets/javascripts/app/views/package.jst.eco index d7b36ce12..bed004d08 100644 --- a/app/assets/javascripts/app/views/package.jst.eco +++ b/app/assets/javascripts/app/views/package.jst.eco @@ -11,7 +11,7 @@ -->

-

+
From 084ffae3ec63bd05652cd8032182382117f98f75 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 26 Aug 2013 10:07:16 +0200 Subject: [PATCH 12/19] Improved browser timing. --- test/browser/auth_customer_test.rb | 2 +- test/browser/auth_master_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/browser/auth_customer_test.rb b/test/browser/auth_customer_test.rb index 745f20e76..1bc461b2f 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', diff --git a/test/browser/auth_master_test.rb b/test/browser/auth_master_test.rb index 392bb244f..1ddcf58c7 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,7 +58,7 @@ class AuthMasterTest < TestCase }, { :execute => 'wait', - :value => 3, + :value => 5, }, # check action From 21080c16626377268ae6cb0c295b58d47a0e4817 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 26 Aug 2013 12:25:17 +0200 Subject: [PATCH 13/19] Fixed syntax error. --- app/models/organization/search.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 0683c0b1bdf265b289490f54bd11c9fa253918d3 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 27 Aug 2013 22:29:26 +0200 Subject: [PATCH 14/19] Removed not needed login check. --- .../javascripts/app/controllers/getting_started.js.coffee | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/assets/javascripts/app/controllers/getting_started.js.coffee b/app/assets/javascripts/app/controllers/getting_started.js.coffee index a20266b72..a6da66198 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 From 568add6fcd9a504fa76e5ee7afedd3896c64d1ed Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 27 Aug 2013 22:31:24 +0200 Subject: [PATCH 15/19] Improved code style. --- app/assets/javascripts/app/lib/app_post/auth.js.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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, ...) From 212db28e5c3d800c52dbd7773f65d01ce7216336 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 27 Aug 2013 22:31:40 +0200 Subject: [PATCH 16/19] Added required module. --- app/models/user.rb | 1 + 1 file changed, 1 insertion(+) 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' From d49607b5a141c68a15e7ebb957e2ff02165a35d9 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 27 Aug 2013 23:05:33 +0200 Subject: [PATCH 17/19] Improved browser tests. --- test/browser/aaa_getting_started_test.rb | 14 ++---- .../agent_ticket_actions_level1_test.rb | 9 ++-- .../agent_ticket_actions_level2_test.rb | 13 ++--- test/browser/auth_customer_test.rb | 41 +++++++-------- test/browser/auth_master_test.rb | 13 +++-- test/browser/customer_ticket_create_test.rb | 11 ++-- test/browser/maintenance_message_test.rb | 32 ++++++------ test/browser/manage_test.rb | 44 +++++----------- test/browser/prefereces_test.rb | 22 +++----- test/browser_test_helper.rb | 50 +++++++++++++------ 10 files changed, 106 insertions(+), 143 deletions(-) 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 8d3df0f6d..7adee9666 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 7e391fd45..45ebe023e 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', }, { - :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 1bc461b2f..4f9646885 100644 --- a/test/browser/auth_customer_test.rb +++ b/test/browser/auth_customer_test.rb @@ -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', }, ], }, @@ -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 1ddcf58c7..571a984ee 100644 --- a/test/browser/auth_master_test.rb +++ b/test/browser/auth_master_test.rb @@ -63,15 +63,14 @@ class AuthMasterTest < TestCase # 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 4cba5d562..6ea644f9b 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 1d4ae7584..682abbea6 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 f010214f1..230a41030 100644 --- a/test/browser/prefereces_test.rb +++ b/test/browser/prefereces_test.rb @@ -34,14 +34,9 @@ class PreferencesTest < TestCase :css => '#language button', }, { - :execute => 'wait', - :value => 6, - }, - { - :execute => 'match', - :css => 'body', - :value => 'Sprache', - :match_result => true, + :execute => 'watch_for', + :area => 'body', + :value => 'Sprache', }, { :execute => 'select', @@ -53,14 +48,9 @@ class PreferencesTest < TestCase :css => '#language button', }, { - :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 db38b3424..cc5f4036a 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -161,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###' @@ -228,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 @@ -244,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' ) @@ -272,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 From 9bdc4a72545324f6850eb4820fd1457a599457f7 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 27 Aug 2013 23:13:58 +0200 Subject: [PATCH 18/19] Added skip_filter. --- app/controllers/application_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index da33e0a65..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 From 04a657b9aa8866b092b5b0e85fdf7a12cabeebba Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 27 Aug 2013 23:14:32 +0200 Subject: [PATCH 19/19] Added puma as alternative. --- Gemfile | 1 + 1 file changed, 1 insertion(+) 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'