From 414d739ff85a827c6391ecfdb1d5b3ad0f7dad7c Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 6 Mar 2018 12:25:48 +0100 Subject: [PATCH 1/3] Fixed issue #1856 as a follow up of issue #949: Unpermitted customer field in customer create ticket view. --- app/assets/javascripts/app/lib/app_post/auth.coffee | 4 ---- .../javascripts/app/models/_application_model.coffee | 9 ++++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/auth.coffee b/app/assets/javascripts/app/lib/app_post/auth.coffee index 7f95f2375..c15c6b2e7 100644 --- a/app/assets/javascripts/app/lib/app_post/auth.coffee +++ b/app/assets/javascripts/app/lib/app_post/auth.coffee @@ -150,10 +150,6 @@ class App.Auth # clear all in-memory data of all App.Model's for model_key, model_object of App - if _.isFunction(model_object.resetCallbacks) - model_object.resetCallbacks() - if _.isFunction(model_object.resetAttributes) - model_object.resetAttributes() if _.isFunction(model_object.clearInMemory) model_object.clearInMemory() diff --git a/app/assets/javascripts/app/models/_application_model.coffee b/app/assets/javascripts/app/models/_application_model.coffee index ba5b442d3..ce05630e6 100644 --- a/app/assets/javascripts/app/models/_application_model.coffee +++ b/app/assets/javascripts/app/models/_application_model.coffee @@ -816,17 +816,16 @@ set new attributes of model (remove already available attributes) ) @clearInMemory: -> - return if !@className + # reset callbacks to session based functions + @resetCallbacks() # reset attributes to prevent cached forms on relogin - if !_.isEmpty(App[@className].org_configure_attributes) - App[@className].configure_attributes = App[@className].org_configure_attributes + @resetAttributes() # reset cached values of model - App[@className].deleteAll() + @deleteAll() @updateAttributes: (attributes) -> - return if !@className if _.isEmpty(@org_configure_attributes) # use jquery instead of ._clone() because we need a deep copy of the obj From 4d7db317ccf560b6b3e0a82310f4b5c64aacc8e1 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 6 Mar 2018 13:49:30 +0100 Subject: [PATCH 2/3] Added browser test to verify the fix. --- script/build/test_slice_tests.sh | 6 +++ .../customer_ticket_create_fields_test.rb | 48 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/browser/customer_ticket_create_fields_test.rb diff --git a/script/build/test_slice_tests.sh b/script/build/test_slice_tests.sh index 470d66942..7fd644c28 100755 --- a/script/build/test_slice_tests.sh +++ b/script/build/test_slice_tests.sh @@ -42,6 +42,7 @@ if [ "$LEVEL" == '1' ]; then rm test/browser/agent_user_profile_test.rb # test/browser/auth_test.rb rm test/browser/chat_test.rb + rm test/browser/customer_ticket_create_fields_test.rb rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb # test/browser/form_test.rb @@ -102,6 +103,7 @@ elif [ "$LEVEL" == '2' ]; then rm test/browser/agent_user_profile_test.rb rm test/browser/auth_test.rb rm test/browser/chat_test.rb + rm test/browser/customer_ticket_create_fields_test.rb rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/form_test.rb @@ -162,6 +164,7 @@ elif [ "$LEVEL" == '3' ]; then rm test/browser/agent_user_profile_test.rb rm test/browser/auth_test.rb rm test/browser/chat_test.rb + rm test/browser/customer_ticket_create_fields_test.rb rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/form_test.rb @@ -222,6 +225,7 @@ elif [ "$LEVEL" == '4' ]; then rm test/browser/agent_user_profile_test.rb rm test/browser/auth_test.rb rm test/browser/chat_test.rb + # test/browser/customer_ticket_create_fields_test.rb # test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/form_test.rb @@ -281,6 +285,7 @@ elif [ "$LEVEL" == '5' ]; then # test/browser/agent_user_profile_test.rb rm test/browser/auth_test.rb rm test/browser/chat_test.rb + rm test/browser/customer_ticket_create_fields_test.rb rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/form_test.rb @@ -343,6 +348,7 @@ elif [ "$LEVEL" == '6' ]; then rm test/browser/agent_user_profile_test.rb rm test/browser/auth_test.rb # test/browser/chat_test.rb + rm test/browser/customer_ticket_create_fields_test.rb rm test/browser/customer_ticket_create_test.rb # test/browser/first_steps_test.rb rm test/browser/form_test.rb diff --git a/test/browser/customer_ticket_create_fields_test.rb b/test/browser/customer_ticket_create_fields_test.rb new file mode 100644 index 000000000..a136beb7f --- /dev/null +++ b/test/browser/customer_ticket_create_fields_test.rb @@ -0,0 +1,48 @@ + +require 'browser_test_helper' + +class CustomerTicketCreateFieldsTest < TestCase + def test_customer_ticket_create + @browser = browser_instance + + # create agent session and fetch object attributes + login( + browser: browser, + username: 'master@example.com', + password: 'test', + url: browser_url, + ) + # remove local object attributes bound to the session + logout() + + # re-create agent session and fetch object attributes + login( + browser: browser, + username: 'master@example.com', + password: 'test', + url: browser_url, + ) + # re-remove local object attributes bound to the session + # there was an issue (#1856) where the old attribute values + # persisted and were stored as the original attributes + logout() + + # create customer session and fetch object attributes + login( + username: 'nicole.braun@zammad.org', + password: 'test', + url: browser_url, + ) + + # customer ticket create + click(css: 'a[href="#new"]', only_if_exists: true) + click(css: 'a[href="#customer_ticket_new"]') + sleep 2 + + # ensure that the object attributes of the agent session + # were removed properly and won't get displayed in the form + exists_not( + css: '.newTicket input[name="customer_id"]', + ) + end +end From 6b73ff3c24aa91a564874a9eef9c9464e9c135c0 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 6 Mar 2018 16:09:07 +0100 Subject: [PATCH 3/3] Fixed broken browser test. --- test/browser/customer_ticket_create_fields_test.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/browser/customer_ticket_create_fields_test.rb b/test/browser/customer_ticket_create_fields_test.rb index a136beb7f..1b7b59add 100644 --- a/test/browser/customer_ticket_create_fields_test.rb +++ b/test/browser/customer_ticket_create_fields_test.rb @@ -1,13 +1,11 @@ - require 'browser_test_helper' class CustomerTicketCreateFieldsTest < TestCase - def test_customer_ticket_create + def test_customer_ticket_create_fields @browser = browser_instance # create agent session and fetch object attributes login( - browser: browser, username: 'master@example.com', password: 'test', url: browser_url, @@ -17,7 +15,6 @@ class CustomerTicketCreateFieldsTest < TestCase # re-create agent session and fetch object attributes login( - browser: browser, username: 'master@example.com', password: 'test', url: browser_url,