Fixes deleting LocalStorage item with user-id prefix
This commit is contained in:
parent
296a024c4b
commit
e4bd02e4d3
4 changed files with 49 additions and 1 deletions
|
@ -14,7 +14,7 @@ class App.LocalStorage
|
|||
@delete: (key, user_id) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _storeSingleton
|
||||
_instance.delete(key)
|
||||
_instance.delete(key, user_id)
|
||||
|
||||
@clear: ->
|
||||
if _instance == undefined
|
||||
|
|
17
app/views/tests/local_storage.html.erb
Normal file
17
app/views/tests/local_storage.html.erb
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
|
||||
<script src="/assets/tests/qunit-1.21.0.js"></script>
|
||||
<script src="/assets/tests/local_storage.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
|
||||
<div id="qunit" class="u-dontfold"></div>
|
||||
|
||||
|
|
@ -2,6 +2,7 @@ Zammad::Application.routes.draw do
|
|||
|
||||
match '/tests_core', to: 'tests#core', via: :get
|
||||
match '/tests_session', to: 'tests#session', via: :get
|
||||
match '/tests_local_storage', to: 'tests#local_storage', via: :get
|
||||
match '/tests_ui', to: 'tests#ui', via: :get
|
||||
match '/tests_model', to: 'tests#model', via: :get
|
||||
match '/tests_model_binding', to: 'tests#model_binding', via: :get
|
||||
|
|
30
public/assets/tests/local_storage.js
Normal file
30
public/assets/tests/local_storage.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
window.onload = function() {
|
||||
|
||||
test('Test item removal from local storage', function() {
|
||||
var key = 'test_key_1'
|
||||
var value = 'test_value_1'
|
||||
|
||||
App.LocalStorage.set(key, value)
|
||||
|
||||
equal(App.LocalStorage.get(key), value)
|
||||
|
||||
App.LocalStorage.delete(key)
|
||||
|
||||
equal(App.LocalStorage.get(key), undefined)
|
||||
});
|
||||
|
||||
test('Test user-specific item removal from local storage', function() {
|
||||
var key = 'test_key_2'
|
||||
var value = 'test_value_2'
|
||||
var user_id = 2
|
||||
|
||||
App.LocalStorage.set(key, value, user_id)
|
||||
|
||||
equal(App.LocalStorage.get(key, user_id), value)
|
||||
|
||||
App.LocalStorage.delete(key, user_id)
|
||||
|
||||
equal(App.LocalStorage.get(key, user_id), undefined)
|
||||
});
|
||||
|
||||
}
|
Loading…
Reference in a new issue