From 3ba55da83ecc8d2b07f7fd3bf08c39ea60c6da41 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 24 Apr 2013 11:46:48 +0200 Subject: [PATCH] Fixed browser tests. --- .../_application_controller_form.js.coffee | 16 ++++++++++------ .../controllers/agent_ticket_create.js.coffee | 6 +++--- .../app/controllers/agent_ticket_zoom.js.coffee | 4 ++-- test/browser/agent_user_manage_test.rb | 8 +++++++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index 9625d714c..a94ca35a8 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -1162,17 +1162,21 @@ class App.ControllerForm extends App.Controller @params: (form) -> param = {} + # create jquery object if not already exists + if typeof form isnt 'function' + form = $(form) + # find form based on sub elements - if $(form).children()[0] - form = $(form).children().parents('form') + if form.children()[0] + form = form.children().parents('form') # find form based on parents next
- else if $(form).parents('form')[0] - form = $(form).parents('form') + else if form.parents('form')[0] + form = form.parents('form') # find form based on parents next , not really good! - else if $(form).parents().find('form')[0] - form = $(form).parents().find('form') + else if form.parents().find('form')[0] + form = form.parents().find('form') else App.Log.log 'ControllerForm', 'error', 'no form found!', form diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index ccfe2e6ba..0c75168a2 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -64,9 +64,9 @@ class App.TicketCreate extends App.Controller @title @article_attributes['title'] changed: => - formCurrent = @formParam( '.ticket-create' ) + formCurrent = @formParam( @el.find('.ticket-create') ) diff = difference( @formDefault, formCurrent ) - return false if !diff || _.isEmpty( diff ) + return false if !diff || _.isEmpty( diff ) return true release: => @@ -196,7 +196,7 @@ class App.TicketCreate extends App.Controller el: @el.find('[data-id="text_module"]'), ) - @formDefault = @formParam( '.ticket-create' ) + @formDefault = @formParam( @el.find('.ticket-create') ) localUserInfo: (params) => @userInfo( user_id: params.customer_id ) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee index 61380ef3b..0b87575d6 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee @@ -53,7 +53,7 @@ class App.TicketZoom extends App.Controller # @title 'Loading...' changed: => - formCurrent = @formParam( '.ticket-update' ) + formCurrent = @formParam( @el.find('.ticket-update') ) diff = difference( @formDefault, formCurrent ) return false if !diff || _.isEmpty( diff ) return true @@ -208,7 +208,7 @@ class App.TicketZoom extends App.Controller # show frontend times @frontendTimeUpdate() - @formDefault = @formParam( '.ticket-update' ) + @formDefault = @formParam( @el.find('.ticket-update') ) # scroll to article if given if @article_id && document.getElementById( 'article-' + @article_id ) diff --git a/test/browser/agent_user_manage_test.rb b/test/browser/agent_user_manage_test.rb index c679c6e9c..369a60de0 100644 --- a/test/browser/agent_user_manage_test.rb +++ b/test/browser/agent_user_manage_test.rb @@ -71,7 +71,13 @@ class AgentUserManageTest < TestCase # call new ticket screen again { :execute => 'click', - :css => '.taskbar a[data-type="close"]', + :css => '.taskbar span[data-type="close"]', + }, + + # accept task close warning + { + :execute => 'accept', + :element => :alert, }, { :execute => 'wait',