Merge branch 'develop' of github.com:martini/zammad into develop
This commit is contained in:
commit
132419b276
95 changed files with 1120 additions and 1061 deletions
4
Gemfile
4
Gemfile
|
@ -2,7 +2,7 @@ source 'https://rubygems.org'
|
||||||
|
|
||||||
ruby '2.2.3'
|
ruby '2.2.3'
|
||||||
|
|
||||||
gem 'rails', '4.2.5.1'
|
gem 'rails', '4.2.5.2'
|
||||||
gem 'rails-observers'
|
gem 'rails-observers'
|
||||||
gem 'activerecord-session_store'
|
gem 'activerecord-session_store'
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ group :development, :test do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
gem 'puma'
|
gem 'puma', '< 3.0'
|
||||||
|
|
||||||
# load onw gem's
|
# load onw gem's
|
||||||
local_gemfile = File.join(File.dirname(__FILE__), 'Gemfile.local')
|
local_gemfile = File.join(File.dirname(__FILE__), 'Gemfile.local')
|
||||||
|
|
133
Gemfile.lock
133
Gemfile.lock
|
@ -1,41 +1,40 @@
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
abstract_type (0.0.7)
|
actionmailer (4.2.5.2)
|
||||||
actionmailer (4.2.5.1)
|
actionpack (= 4.2.5.2)
|
||||||
actionpack (= 4.2.5.1)
|
actionview (= 4.2.5.2)
|
||||||
actionview (= 4.2.5.1)
|
activejob (= 4.2.5.2)
|
||||||
activejob (= 4.2.5.1)
|
|
||||||
mail (~> 2.5, >= 2.5.4)
|
mail (~> 2.5, >= 2.5.4)
|
||||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||||
actionpack (4.2.5.1)
|
actionpack (4.2.5.2)
|
||||||
actionview (= 4.2.5.1)
|
actionview (= 4.2.5.2)
|
||||||
activesupport (= 4.2.5.1)
|
activesupport (= 4.2.5.2)
|
||||||
rack (~> 1.6)
|
rack (~> 1.6)
|
||||||
rack-test (~> 0.6.2)
|
rack-test (~> 0.6.2)
|
||||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||||
actionview (4.2.5.1)
|
actionview (4.2.5.2)
|
||||||
activesupport (= 4.2.5.1)
|
activesupport (= 4.2.5.2)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubis (~> 2.7.0)
|
erubis (~> 2.7.0)
|
||||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||||
activejob (4.2.5.1)
|
activejob (4.2.5.2)
|
||||||
activesupport (= 4.2.5.1)
|
activesupport (= 4.2.5.2)
|
||||||
globalid (>= 0.3.0)
|
globalid (>= 0.3.0)
|
||||||
activemodel (4.2.5.1)
|
activemodel (4.2.5.2)
|
||||||
activesupport (= 4.2.5.1)
|
activesupport (= 4.2.5.2)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
activerecord (4.2.5.1)
|
activerecord (4.2.5.2)
|
||||||
activemodel (= 4.2.5.1)
|
activemodel (= 4.2.5.2)
|
||||||
activesupport (= 4.2.5.1)
|
activesupport (= 4.2.5.2)
|
||||||
arel (~> 6.0)
|
arel (~> 6.0)
|
||||||
activerecord-session_store (0.1.2)
|
activerecord-session_store (0.1.2)
|
||||||
actionpack (>= 4.0.0, < 5)
|
actionpack (>= 4.0.0, < 5)
|
||||||
activerecord (>= 4.0.0, < 5)
|
activerecord (>= 4.0.0, < 5)
|
||||||
railties (>= 4.0.0, < 5)
|
railties (>= 4.0.0, < 5)
|
||||||
activesupport (4.2.5.1)
|
activesupport (4.2.5.2)
|
||||||
i18n (~> 0.7)
|
i18n (~> 0.7)
|
||||||
json (~> 1.7, >= 1.7.7)
|
json (~> 1.7, >= 1.7.7)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
|
@ -44,23 +43,18 @@ GEM
|
||||||
addressable (2.4.0)
|
addressable (2.4.0)
|
||||||
arel (6.0.3)
|
arel (6.0.3)
|
||||||
ast (2.2.0)
|
ast (2.2.0)
|
||||||
autoprefixer-rails (6.3.1)
|
autoprefixer-rails (6.3.3.1)
|
||||||
execjs
|
execjs
|
||||||
json
|
biz (1.3.4)
|
||||||
biz (1.3.3)
|
|
||||||
abstract_type (~> 0.0.0)
|
|
||||||
clavius (~> 1.0)
|
clavius (~> 1.0)
|
||||||
equalizer (~> 0.0.0)
|
|
||||||
memoizable (~> 0.4.0)
|
|
||||||
tzinfo
|
tzinfo
|
||||||
browser (1.1.0)
|
browser (2.0.2)
|
||||||
buftok (0.2.0)
|
buftok (0.2.0)
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
childprocess (0.5.9)
|
childprocess (0.5.9)
|
||||||
ffi (~> 1.0, >= 1.0.11)
|
ffi (~> 1.0, >= 1.0.11)
|
||||||
clavius (1.0.1)
|
clavius (1.0.2)
|
||||||
memoizable (~> 0.4.0)
|
coderay (1.1.1)
|
||||||
coderay (1.1.0)
|
|
||||||
coffee-rails (4.1.1)
|
coffee-rails (4.1.1)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
railties (>= 4.0.0, < 5.1.x)
|
railties (>= 4.0.0, < 5.1.x)
|
||||||
|
@ -72,7 +66,7 @@ GEM
|
||||||
coffee-script
|
coffee-script
|
||||||
execjs
|
execjs
|
||||||
json
|
json
|
||||||
concurrent-ruby (1.0.0)
|
concurrent-ruby (1.0.1)
|
||||||
daemons (1.2.3)
|
daemons (1.2.3)
|
||||||
delayed_job (4.1.1)
|
delayed_job (4.1.1)
|
||||||
activesupport (>= 3.0, < 5.0)
|
activesupport (>= 3.0, < 5.0)
|
||||||
|
@ -80,9 +74,9 @@ GEM
|
||||||
activerecord (>= 3.0, < 5)
|
activerecord (>= 3.0, < 5)
|
||||||
delayed_job (>= 3.0, < 5)
|
delayed_job (>= 3.0, < 5)
|
||||||
diffy (3.1.0)
|
diffy (3.1.0)
|
||||||
dnsruby (1.59.1)
|
dnsruby (1.59.2)
|
||||||
docile (1.1.5)
|
docile (1.1.5)
|
||||||
domain_name (0.5.25)
|
domain_name (0.5.20160216)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
eco (1.0.0)
|
eco (1.0.0)
|
||||||
coffee-script
|
coffee-script
|
||||||
|
@ -114,7 +108,7 @@ GEM
|
||||||
shellany (~> 0.0)
|
shellany (~> 0.0)
|
||||||
thor (>= 0.18.1)
|
thor (>= 0.18.1)
|
||||||
guard-compat (1.2.1)
|
guard-compat (1.2.1)
|
||||||
guard-livereload (2.5.1)
|
guard-livereload (2.5.2)
|
||||||
em-websocket (~> 0.5)
|
em-websocket (~> 0.5)
|
||||||
guard (~> 2.8)
|
guard (~> 2.8)
|
||||||
guard-compat (~> 1.0)
|
guard-compat (~> 1.0)
|
||||||
|
@ -134,15 +128,15 @@ GEM
|
||||||
icalendar (2.3.0)
|
icalendar (2.3.0)
|
||||||
inflection (1.0.0)
|
inflection (1.0.0)
|
||||||
json (1.8.3)
|
json (1.8.3)
|
||||||
jwt (1.5.2)
|
jwt (1.5.1)
|
||||||
koala (2.2.0)
|
koala (2.2.0)
|
||||||
addressable
|
addressable
|
||||||
faraday
|
faraday
|
||||||
multi_json
|
multi_json
|
||||||
libv8 (3.16.14.13)
|
libv8 (3.16.14.13)
|
||||||
listen (3.0.5)
|
listen (3.0.6)
|
||||||
rb-fsevent (>= 0.9.3)
|
rb-fsevent (>= 0.9.3)
|
||||||
rb-inotify (>= 0.9)
|
rb-inotify (>= 0.9.7)
|
||||||
loofah (2.0.3)
|
loofah (2.0.3)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
lumberjack (1.0.10)
|
lumberjack (1.0.10)
|
||||||
|
@ -151,7 +145,7 @@ GEM
|
||||||
memoizable (0.4.2)
|
memoizable (0.4.2)
|
||||||
thread_safe (~> 0.3, >= 0.3.1)
|
thread_safe (~> 0.3, >= 0.3.1)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
mime-types (2.99)
|
mime-types (2.99.1)
|
||||||
mini_portile2 (2.0.0)
|
mini_portile2 (2.0.0)
|
||||||
minitest (5.8.4)
|
minitest (5.8.4)
|
||||||
multi_json (1.11.2)
|
multi_json (1.11.2)
|
||||||
|
@ -159,27 +153,26 @@ GEM
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
mysql2 (0.3.20)
|
mysql2 (0.3.20)
|
||||||
naught (1.1.0)
|
naught (1.1.0)
|
||||||
nenv (0.2.0)
|
nenv (0.3.0)
|
||||||
net-ldap (0.13.0)
|
net-ldap (0.14.0)
|
||||||
nokogiri (1.6.7.2)
|
nokogiri (1.6.7.2)
|
||||||
mini_portile2 (~> 2.0.0.rc2)
|
mini_portile2 (~> 2.0.0.rc2)
|
||||||
notiffany (0.0.8)
|
notiffany (0.0.8)
|
||||||
nenv (~> 0.1)
|
nenv (~> 0.1)
|
||||||
shellany (~> 0.0)
|
shellany (~> 0.0)
|
||||||
oauth (0.4.7)
|
oauth (0.5.1)
|
||||||
oauth2 (1.0.0)
|
oauth2 (1.1.0)
|
||||||
faraday (>= 0.8, < 0.10)
|
faraday (>= 0.8, < 0.10)
|
||||||
jwt (~> 1.0)
|
jwt (~> 1.0, < 1.5.2)
|
||||||
multi_json (~> 1.3)
|
multi_json (~> 1.3)
|
||||||
multi_xml (~> 0.5)
|
multi_xml (~> 0.5)
|
||||||
rack (~> 1.2)
|
rack (>= 1.2, < 3)
|
||||||
omniauth (1.3.1)
|
omniauth (1.3.1)
|
||||||
hashie (>= 1.2, < 4)
|
hashie (>= 1.2, < 4)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
omniauth-facebook (3.0.0)
|
omniauth-facebook (3.0.0)
|
||||||
omniauth-oauth2 (~> 1.2)
|
omniauth-oauth2 (~> 1.2)
|
||||||
omniauth-google-oauth2 (0.3.0)
|
omniauth-google-oauth2 (0.3.1)
|
||||||
addressable (~> 2.3)
|
|
||||||
jwt (~> 1.0)
|
jwt (~> 1.0)
|
||||||
multi_json (~> 1.3)
|
multi_json (~> 1.3)
|
||||||
omniauth (>= 1.1.1)
|
omniauth (>= 1.1.1)
|
||||||
|
@ -195,12 +188,12 @@ GEM
|
||||||
omniauth-twitter (1.2.1)
|
omniauth-twitter (1.2.1)
|
||||||
json (~> 1.3)
|
json (~> 1.3)
|
||||||
omniauth-oauth (~> 1.1)
|
omniauth-oauth (~> 1.1)
|
||||||
parser (2.3.0.2)
|
parser (2.3.0.6)
|
||||||
ast (~> 2.2)
|
ast (~> 2.2)
|
||||||
pluginator (1.3.0)
|
pluginator (1.3.0)
|
||||||
power_assert (0.2.7)
|
power_assert (0.2.7)
|
||||||
powerpack (0.1.1)
|
powerpack (0.1.1)
|
||||||
pre-commit (0.26.0)
|
pre-commit (0.27.0)
|
||||||
pluginator (~> 1.1)
|
pluginator (~> 1.1)
|
||||||
pry (0.10.3)
|
pry (0.10.3)
|
||||||
coderay (~> 1.1.0)
|
coderay (~> 1.1.0)
|
||||||
|
@ -212,16 +205,16 @@ GEM
|
||||||
rack
|
rack
|
||||||
rack-test (0.6.3)
|
rack-test (0.6.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (4.2.5.1)
|
rails (4.2.5.2)
|
||||||
actionmailer (= 4.2.5.1)
|
actionmailer (= 4.2.5.2)
|
||||||
actionpack (= 4.2.5.1)
|
actionpack (= 4.2.5.2)
|
||||||
actionview (= 4.2.5.1)
|
actionview (= 4.2.5.2)
|
||||||
activejob (= 4.2.5.1)
|
activejob (= 4.2.5.2)
|
||||||
activemodel (= 4.2.5.1)
|
activemodel (= 4.2.5.2)
|
||||||
activerecord (= 4.2.5.1)
|
activerecord (= 4.2.5.2)
|
||||||
activesupport (= 4.2.5.1)
|
activesupport (= 4.2.5.2)
|
||||||
bundler (>= 1.3.0, < 2.0)
|
bundler (>= 1.3.0, < 2.0)
|
||||||
railties (= 4.2.5.1)
|
railties (= 4.2.5.2)
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
rails-deprecated_sanitizer (1.0.3)
|
rails-deprecated_sanitizer (1.0.3)
|
||||||
activesupport (>= 4.2.0.alpha)
|
activesupport (>= 4.2.0.alpha)
|
||||||
|
@ -233,24 +226,25 @@ GEM
|
||||||
loofah (~> 2.0)
|
loofah (~> 2.0)
|
||||||
rails-observers (0.1.2)
|
rails-observers (0.1.2)
|
||||||
activemodel (~> 4.0)
|
activemodel (~> 4.0)
|
||||||
railties (4.2.5.1)
|
railties (4.2.5.2)
|
||||||
actionpack (= 4.2.5.1)
|
actionpack (= 4.2.5.2)
|
||||||
activesupport (= 4.2.5.1)
|
activesupport (= 4.2.5.2)
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.18.1, < 2.0)
|
||||||
rainbow (2.1.0)
|
rainbow (2.1.0)
|
||||||
rake (10.5.0)
|
rake (10.5.0)
|
||||||
rb-fsevent (0.9.7)
|
rb-fsevent (0.9.7)
|
||||||
rb-inotify (0.9.5)
|
rb-inotify (0.9.7)
|
||||||
ffi (>= 0.5.0)
|
ffi (>= 0.5.0)
|
||||||
ref (2.0.0)
|
ref (2.0.0)
|
||||||
rubocop (0.36.0)
|
rubocop (0.37.2)
|
||||||
parser (>= 2.3.0.0, < 3.0)
|
parser (>= 2.3.0.4, < 3.0)
|
||||||
powerpack (~> 0.1)
|
powerpack (~> 0.1)
|
||||||
rainbow (>= 1.99.1, < 3.0)
|
rainbow (>= 1.99.1, < 3.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
|
unicode-display_width (~> 0.3)
|
||||||
ruby-progressbar (1.7.5)
|
ruby-progressbar (1.7.5)
|
||||||
rubyzip (1.1.7)
|
rubyzip (1.2.0)
|
||||||
sass (3.4.21)
|
sass (3.4.21)
|
||||||
sass-rails (5.0.4)
|
sass-rails (5.0.4)
|
||||||
railties (>= 4.0.0, < 5.0)
|
railties (>= 4.0.0, < 5.0)
|
||||||
|
@ -259,7 +253,7 @@ GEM
|
||||||
sprockets-rails (>= 2.0, < 4.0)
|
sprockets-rails (>= 2.0, < 4.0)
|
||||||
tilt (>= 1.1, < 3)
|
tilt (>= 1.1, < 3)
|
||||||
scrub_rb (1.0.1)
|
scrub_rb (1.0.1)
|
||||||
selenium-webdriver (2.50.0)
|
selenium-webdriver (2.52.0)
|
||||||
childprocess (~> 0.5)
|
childprocess (~> 0.5)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
rubyzip (~> 1.0)
|
rubyzip (~> 1.0)
|
||||||
|
@ -267,7 +261,7 @@ GEM
|
||||||
shellany (0.0.1)
|
shellany (0.0.1)
|
||||||
simple-rss (1.3.1)
|
simple-rss (1.3.1)
|
||||||
simple_oauth (0.3.1)
|
simple_oauth (0.3.1)
|
||||||
simplecov (0.11.1)
|
simplecov (0.11.2)
|
||||||
docile (~> 1.1.0)
|
docile (~> 1.1.0)
|
||||||
json (~> 1.8)
|
json (~> 1.8)
|
||||||
simplecov-html (~> 0.10.0)
|
simplecov-html (~> 0.10.0)
|
||||||
|
@ -275,11 +269,11 @@ GEM
|
||||||
simplecov-rcov (0.2.3)
|
simplecov-rcov (0.2.3)
|
||||||
simplecov (>= 0.4.1)
|
simplecov (>= 0.4.1)
|
||||||
slop (3.6.0)
|
slop (3.6.0)
|
||||||
spring (1.6.2)
|
spring (1.6.4)
|
||||||
sprockets (3.5.2)
|
sprockets (3.5.2)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
rack (> 1, < 3)
|
rack (> 1, < 3)
|
||||||
sprockets-rails (3.0.1)
|
sprockets-rails (3.0.3)
|
||||||
actionpack (>= 4.0)
|
actionpack (>= 4.0)
|
||||||
activesupport (>= 4.0)
|
activesupport (>= 4.0)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
|
@ -310,7 +304,8 @@ GEM
|
||||||
json (>= 1.8.0)
|
json (>= 1.8.0)
|
||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
unf_ext (0.0.7.1)
|
unf_ext (0.0.7.2)
|
||||||
|
unicode-display_width (0.3.1)
|
||||||
websocket (1.2.2)
|
websocket (1.2.2)
|
||||||
writeexcel (1.0.5)
|
writeexcel (1.0.5)
|
||||||
zendesk_api (1.13.4)
|
zendesk_api (1.13.4)
|
||||||
|
@ -357,9 +352,9 @@ DEPENDENCIES
|
||||||
omniauth-linkedin
|
omniauth-linkedin
|
||||||
omniauth-twitter
|
omniauth-twitter
|
||||||
pre-commit
|
pre-commit
|
||||||
puma
|
puma (< 3.0)
|
||||||
rack-livereload
|
rack-livereload
|
||||||
rails (= 4.2.5.1)
|
rails (= 4.2.5.2)
|
||||||
rails-observers
|
rails-observers
|
||||||
rb-fsevent
|
rb-fsevent
|
||||||
rubocop
|
rubocop
|
||||||
|
|
0
LICENSE-ICONS-3RD-PARTY.json
Executable file → Normal file
0
LICENSE-ICONS-3RD-PARTY.json
Executable file → Normal file
|
@ -7,7 +7,7 @@ class App.DashboardFirstSteps extends App.Controller
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
@interval(@load, 35000)
|
@interval(@load, 25000)
|
||||||
|
|
||||||
load: =>
|
load: =>
|
||||||
return if @lastData && !@el.is(':visible')
|
return if @lastData && !@el.is(':visible')
|
||||||
|
|
|
@ -23,6 +23,11 @@ class App.TicketOverview extends App.Controller
|
||||||
|
|
||||||
@html elLocal
|
@html elLocal
|
||||||
|
|
||||||
|
@bind 'overview:fetch', =>
|
||||||
|
update = =>
|
||||||
|
App.OverviewListCollection.fetch(@view)
|
||||||
|
@delay(update, 2800, 'overview:fetch')
|
||||||
|
|
||||||
active: (state) =>
|
active: (state) =>
|
||||||
@activeState = state
|
@activeState = state
|
||||||
|
|
||||||
|
@ -197,16 +202,16 @@ class Table extends App.Controller
|
||||||
super
|
super
|
||||||
|
|
||||||
if @view
|
if @view
|
||||||
@bindId = App.OverviewCollection.bind(@view, @render)
|
@bindId = App.OverviewListCollection.bind(@view, @render)
|
||||||
|
|
||||||
# rerender view, e. g. on langauge change
|
# rerender view, e. g. on langauge change
|
||||||
@bind 'ui:rerender', =>
|
@bind 'ui:rerender', =>
|
||||||
return if !@authenticate(true)
|
return if !@authenticate(true)
|
||||||
@render(App.OverviewCollection.get(@view))
|
@render(App.OverviewListCollection.get(@view))
|
||||||
|
|
||||||
release: =>
|
release: =>
|
||||||
if @bindId
|
if @bindId
|
||||||
App.OverviewCollection.unbind(@bindId)
|
App.OverviewListCollection.unbind(@bindId)
|
||||||
|
|
||||||
update: (params) =>
|
update: (params) =>
|
||||||
for key, value of params
|
for key, value of params
|
||||||
|
@ -219,24 +224,20 @@ class Table extends App.Controller
|
||||||
|
|
||||||
if @view
|
if @view
|
||||||
if @bindId
|
if @bindId
|
||||||
App.OverviewCollection.unbind(@bindId)
|
App.OverviewListCollection.unbind(@bindId)
|
||||||
@bindId = App.OverviewCollection.bind(@view, @render)
|
@bindId = App.OverviewListCollection.bind(@view, @render)
|
||||||
|
|
||||||
render: (data) =>
|
render: (data) =>
|
||||||
return if !data
|
return if !data
|
||||||
|
|
||||||
# use cache
|
# use cache
|
||||||
overview = data.overview
|
overview = data.overview
|
||||||
tickets_count = data.tickets_count
|
tickets = data.tickets
|
||||||
ticket_ids = data.ticket_ids
|
|
||||||
|
|
||||||
# use cache if no local change
|
|
||||||
App.Overview.refresh(overview, { clear: true })
|
|
||||||
|
|
||||||
# get ticket list
|
# get ticket list
|
||||||
ticket_list_show = []
|
ticket_list_show = []
|
||||||
for ticket_id in ticket_ids
|
for ticket in tickets
|
||||||
ticket_list_show.push App.Ticket.fullLocal(ticket_id)
|
ticket_list_show.push App.Ticket.fullLocal(ticket.id)
|
||||||
|
|
||||||
# if customer and no ticket exists, show the following message only
|
# if customer and no ticket exists, show the following message only
|
||||||
if !ticket_list_show[0] && @isRole('Customer')
|
if !ticket_list_show[0] && @isRole('Customer')
|
||||||
|
@ -622,8 +623,7 @@ class BulkForm extends App.Controller
|
||||||
@hide()
|
@hide()
|
||||||
|
|
||||||
# fetch overview data again
|
# fetch overview data again
|
||||||
App.OverviewIndexCollection.fetch()
|
App.Event.trigger('overview:fetch')
|
||||||
App.OverviewCollection.fetch(@view)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@holder.find('.table-overview').find('[name="bulk"]:checked').prop('checked', false)
|
@holder.find('.table-overview').find('[name="bulk"]:checked').prop('checked', false)
|
||||||
|
@ -761,11 +761,10 @@ class App.OverviewSettings extends App.ControllerModal
|
||||||
|
|
||||||
# fetch overview data again
|
# fetch overview data again
|
||||||
if @reload_needed
|
if @reload_needed
|
||||||
App.OverviewIndexCollection.fetch()
|
App.OverviewListCollection.fetch(@overview.link)
|
||||||
App.OverviewCollection.fetch(@overview.link)
|
|
||||||
else
|
else
|
||||||
App.OverviewIndexCollection.trigger()
|
App.OverviewIndexCollection.trigger()
|
||||||
App.OverviewCollection.trigger(@overview.link)
|
App.OverviewListCollection.trigger(@overview.link)
|
||||||
|
|
||||||
# close modal
|
# close modal
|
||||||
@close()
|
@close()
|
||||||
|
|
|
@ -350,15 +350,15 @@ class App.TicketZoom extends App.Controller
|
||||||
|
|
||||||
# rerender whole sidebar if customer or organization has changed
|
# rerender whole sidebar if customer or organization has changed
|
||||||
if @ticketLastAttributes.customer_id isnt @ticket.customer_id || @ticketLastAttributes.organization_id isnt @ticket.organization_id
|
if @ticketLastAttributes.customer_id isnt @ticket.customer_id || @ticketLastAttributes.organization_id isnt @ticket.organization_id
|
||||||
new App.WidgetAvatar(
|
|
||||||
el: @$('.ticketZoom-header .js-avatar')
|
|
||||||
user_id: @ticket.customer_id
|
|
||||||
size: 50
|
|
||||||
)
|
|
||||||
if elLocal
|
if elLocal
|
||||||
el = elLocal
|
el = elLocal
|
||||||
else
|
else
|
||||||
el = @el
|
el = @el
|
||||||
|
new App.WidgetAvatar(
|
||||||
|
el: el.find('.ticketZoom-header .js-avatar')
|
||||||
|
user_id: @ticket.customer_id
|
||||||
|
size: 50
|
||||||
|
)
|
||||||
@sidebar = new App.TicketZoomSidebar(
|
@sidebar = new App.TicketZoomSidebar(
|
||||||
el: el.find('.tabsSidebar')
|
el: el.find('.tabsSidebar')
|
||||||
sidebarState: @sidebarState
|
sidebarState: @sidebarState
|
||||||
|
@ -381,12 +381,12 @@ class App.TicketZoom extends App.Controller
|
||||||
)
|
)
|
||||||
|
|
||||||
# scroll to article if given
|
# scroll to article if given
|
||||||
if @article_id && document.getElementById( 'article-' + @article_id )
|
if @article_id && document.getElementById('article-' + @article_id)
|
||||||
offset = document.getElementById( 'article-' + @article_id ).offsetTop
|
offset = document.getElementById('article-' + @article_id).offsetTop
|
||||||
offset = offset - 45
|
offset = offset - 45
|
||||||
scrollTo = ->
|
scrollTo = ->
|
||||||
@scrollTo( 0, offset )
|
@scrollTo(0, offset)
|
||||||
@delay( scrollTo, 100, false )
|
@delay(scrollTo, 100, false)
|
||||||
|
|
||||||
@ticketLastAttributes = @ticket.attributes()
|
@ticketLastAttributes = @ticket.attributes()
|
||||||
|
|
||||||
|
@ -476,8 +476,8 @@ class App.TicketZoom extends App.Controller
|
||||||
resetButton = @$('.js-reset')
|
resetButton = @$('.js-reset')
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
params.ticket = @formParam( ticketForm )
|
params.ticket = @formParam(ticketForm)
|
||||||
params.article = @formParam( articleForm )
|
params.article = @formParam(articleForm)
|
||||||
#console.log('markFormDiff', diff, params)
|
#console.log('markFormDiff', diff, params)
|
||||||
|
|
||||||
# clear all changes
|
# clear all changes
|
||||||
|
@ -618,25 +618,25 @@ class App.TicketZoom extends App.Controller
|
||||||
if @overview_id
|
if @overview_id
|
||||||
current_position = 0
|
current_position = 0
|
||||||
overview = App.Overview.find(@overview_id)
|
overview = App.Overview.find(@overview_id)
|
||||||
list = App.OverviewCollection.get(overview.link)
|
list = App.OverviewListCollection.get(overview.link)
|
||||||
for ticket_id in list.ticket_ids
|
for ticket in list.tickets
|
||||||
current_position += 1
|
current_position += 1
|
||||||
if ticket_id is @ticket_id
|
if ticket.id is @ticket_id
|
||||||
next = list.ticket_ids[current_position]
|
next = list.tickets[current_position]
|
||||||
if next
|
if next
|
||||||
# close task
|
# close task
|
||||||
App.TaskManager.remove(@task_key)
|
App.TaskManager.remove(@task_key)
|
||||||
|
|
||||||
# open task via task manager to get overview information
|
# open task via task manager to get overview information
|
||||||
App.TaskManager.execute(
|
App.TaskManager.execute(
|
||||||
key: 'Ticket-' + next
|
key: 'Ticket-' + next.id
|
||||||
controller: 'TicketZoom'
|
controller: 'TicketZoom'
|
||||||
params:
|
params:
|
||||||
ticket_id: next
|
ticket_id: next.id
|
||||||
overview_id: @overview_id
|
overview_id: @overview_id
|
||||||
show: true
|
show: true
|
||||||
)
|
)
|
||||||
@navigate "ticket/zoom/#{next}"
|
@navigate "ticket/zoom/#{next.id}"
|
||||||
return
|
return
|
||||||
|
|
||||||
# fallback, close task
|
# fallback, close task
|
||||||
|
@ -658,6 +658,8 @@ class App.TicketZoom extends App.Controller
|
||||||
|
|
||||||
# enable form
|
# enable form
|
||||||
@formEnable(e)
|
@formEnable(e)
|
||||||
|
|
||||||
|
App.Event.trigger('overview:fetch')
|
||||||
)
|
)
|
||||||
|
|
||||||
bookmark: (e) ->
|
bookmark: (e) ->
|
||||||
|
@ -731,6 +733,6 @@ class TicketZoomRouter extends App.ControllerPermanent
|
||||||
show: true
|
show: true
|
||||||
)
|
)
|
||||||
|
|
||||||
App.Config.set( 'ticket/zoom/:ticket_id', TicketZoomRouter, 'Routes' )
|
App.Config.set('ticket/zoom/:ticket_id', TicketZoomRouter, 'Routes')
|
||||||
App.Config.set( 'ticket/zoom/:ticket_id/nav/:nav', TicketZoomRouter, 'Routes' )
|
App.Config.set('ticket/zoom/:ticket_id/nav/:nav', TicketZoomRouter, 'Routes')
|
||||||
App.Config.set( 'ticket/zoom/:ticket_id/:article_id', TicketZoomRouter, 'Routes' )
|
App.Config.set('ticket/zoom/:ticket_id/:article_id', TicketZoomRouter, 'Routes')
|
||||||
|
|
|
@ -12,12 +12,12 @@ class App.TicketZoomOverviewNavigator extends App.Controller
|
||||||
@delay(@render, 2600, 'overview-navigator')
|
@delay(@render, 2600, 'overview-navigator')
|
||||||
|
|
||||||
@overview = App.Overview.find(@overview_id)
|
@overview = App.Overview.find(@overview_id)
|
||||||
@bindId = App.OverviewCollection.bind(@overview.link, lateUpdate, false)
|
@bindId = App.OverviewListCollection.bind(@overview.link, lateUpdate, false)
|
||||||
|
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
release: =>
|
release: =>
|
||||||
App.OverviewCollection.unbind(@bindId)
|
App.OverviewListCollection.unbind(@bindId)
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
if !@overview_id
|
if !@overview_id
|
||||||
|
@ -25,17 +25,17 @@ class App.TicketZoomOverviewNavigator extends App.Controller
|
||||||
return
|
return
|
||||||
|
|
||||||
# get overview data
|
# get overview data
|
||||||
overview = App.OverviewCollection.get(@overview.link)
|
overview = App.OverviewListCollection.get(@overview.link)
|
||||||
return if !overview
|
return if !overview
|
||||||
current_position = 0
|
current_position = 0
|
||||||
found = false
|
found = false
|
||||||
next = false
|
item_next = false
|
||||||
previous = false
|
item_previous = false
|
||||||
for ticket_id in overview.ticket_ids
|
for ticket in overview.tickets
|
||||||
current_position += 1
|
current_position += 1
|
||||||
next = overview.ticket_ids[current_position]
|
item_next = overview.tickets[current_position]
|
||||||
previous = overview.ticket_ids[current_position-2]
|
item_previous = overview.tickets[current_position-2]
|
||||||
if ticket_id is @ticket_id
|
if ticket.id is @ticket_id
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -44,10 +44,10 @@ class App.TicketZoomOverviewNavigator extends App.Controller
|
||||||
return
|
return
|
||||||
|
|
||||||
# get next/previous ticket
|
# get next/previous ticket
|
||||||
if next
|
if item_next
|
||||||
next = App.Ticket.find(next)
|
next = App.Ticket.find(item_next.id)
|
||||||
if previous
|
if item_previous
|
||||||
previous = App.Ticket.find(previous)
|
previous = App.Ticket.find(item_previous.id)
|
||||||
|
|
||||||
@html App.view('ticket_zoom/overview_navigator')(
|
@html App.view('ticket_zoom/overview_navigator')(
|
||||||
title: overview.overview.name
|
title: overview.overview.name
|
||||||
|
|
|
@ -53,5 +53,7 @@ class App.TicketZoomTitle extends App.Controller
|
||||||
# update taskbar with new meta data
|
# update taskbar with new meta data
|
||||||
@metaTaskUpdate()
|
@metaTaskUpdate()
|
||||||
|
|
||||||
|
App.Event.trigger('overview:fetch')
|
||||||
|
|
||||||
release: =>
|
release: =>
|
||||||
App.Ticket.unsubscribe(@subscribeId)
|
App.Ticket.unsubscribe(@subscribeId)
|
||||||
|
|
|
@ -44,6 +44,10 @@ class App._CollectionSingletonBase
|
||||||
delete @callbacks[counter]
|
delete @callbacks[counter]
|
||||||
|
|
||||||
fetch: =>
|
fetch: =>
|
||||||
|
if App.WebSocket.support()
|
||||||
|
App.WebSocket.send(event: @event)
|
||||||
|
return
|
||||||
|
|
||||||
return if @fetchActive
|
return if @fetchActive
|
||||||
@fetchActive = true
|
@fetchActive = true
|
||||||
App.Ajax.request(
|
App.Ajax.request(
|
||||||
|
|
|
@ -1,5 +1,75 @@
|
||||||
class App.OverviewCollection
|
class _Singleton
|
||||||
_instance = undefined # Must be declared here to force the closure on the class
|
constructor: ->
|
||||||
|
@overview = {}
|
||||||
|
@callbacks = {}
|
||||||
|
@fetchActive = {}
|
||||||
|
@counter = 0
|
||||||
|
|
||||||
|
App.Event.bind 'ticket_overview_list', (data) =>
|
||||||
|
if !@overview[data.overview.view]
|
||||||
|
@overview[data.overview.view] = {}
|
||||||
|
@overview[data.overview.view] = data
|
||||||
|
@callback(data.overview.view, data)
|
||||||
|
|
||||||
|
get: (view) ->
|
||||||
|
@overview[view]
|
||||||
|
|
||||||
|
bind: (view, callback, init = true) ->
|
||||||
|
@counter += 1
|
||||||
|
@callbacks[@counter] =
|
||||||
|
view: view
|
||||||
|
callback: callback
|
||||||
|
|
||||||
|
# start init call if needed
|
||||||
|
if init
|
||||||
|
if @overview[view] is undefined
|
||||||
|
@fetch(view)
|
||||||
|
else
|
||||||
|
@callback(view, @overview[view])
|
||||||
|
|
||||||
|
@counter
|
||||||
|
|
||||||
|
unbind: (counter) ->
|
||||||
|
delete @callbacks[counter]
|
||||||
|
|
||||||
|
fetch: (view) =>
|
||||||
|
if App.WebSocket.support()
|
||||||
|
App.WebSocket.send(
|
||||||
|
event: 'ticket_overview_list'
|
||||||
|
view: view
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
App.OverviewIndexCollection.fetch()
|
||||||
|
return if @fetchActive[view]
|
||||||
|
@fetchActive[view] = true
|
||||||
|
App.Ajax.request(
|
||||||
|
id: 'ticket_overview_' + view
|
||||||
|
type: 'GET',
|
||||||
|
url: App.Config.get('api_path') + '/ticket_overviews',
|
||||||
|
data:
|
||||||
|
view: view
|
||||||
|
processData: true,
|
||||||
|
success: (data) =>
|
||||||
|
@fetchActive[view] = false
|
||||||
|
if data.assets
|
||||||
|
App.Collection.loadAssets(data.assets)
|
||||||
|
@overview[data.index.overview.view] = data.index
|
||||||
|
@callback(view, data.index)
|
||||||
|
error: =>
|
||||||
|
@fetchActive[view] = false
|
||||||
|
)
|
||||||
|
|
||||||
|
trigger: (view) =>
|
||||||
|
@callback(view, @get(view))
|
||||||
|
|
||||||
|
callback: (view, data) =>
|
||||||
|
for counter, meta of @callbacks
|
||||||
|
if meta.view is view
|
||||||
|
meta.callback(data)
|
||||||
|
|
||||||
|
class App.OverviewListCollection
|
||||||
|
_instance = new _Singleton
|
||||||
|
|
||||||
@get: (view) ->
|
@get: (view) ->
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
|
@ -25,79 +95,3 @@ class App.OverviewCollection
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
_instance ?= new _Singleton
|
_instance ?= new _Singleton
|
||||||
_instance.trigger(view)
|
_instance.trigger(view)
|
||||||
|
|
||||||
# The actual Singleton class
|
|
||||||
class _Singleton
|
|
||||||
constructor: ->
|
|
||||||
@overview = {}
|
|
||||||
@callbacks = {}
|
|
||||||
@fetchActive = {}
|
|
||||||
@counter = 0
|
|
||||||
|
|
||||||
# websocket updates
|
|
||||||
App.Event.bind 'ticket_overview_rebuild', (data) =>
|
|
||||||
if !@overview[data.view]
|
|
||||||
@overview[data.view] = {}
|
|
||||||
|
|
||||||
# proccess assets, delete them later
|
|
||||||
if data.assets
|
|
||||||
App.Collection.loadAssets( data.assets )
|
|
||||||
delete data.assets
|
|
||||||
|
|
||||||
@overview[data.view] = data
|
|
||||||
|
|
||||||
@callback(data.view, data)
|
|
||||||
|
|
||||||
get: (view) ->
|
|
||||||
@overview[view]
|
|
||||||
|
|
||||||
bind: (view, callback, init = true) ->
|
|
||||||
@counter += 1
|
|
||||||
@callbacks[@counter] =
|
|
||||||
view: view
|
|
||||||
callback: callback
|
|
||||||
|
|
||||||
# start init call if needed
|
|
||||||
if init
|
|
||||||
if @overview[view] is undefined
|
|
||||||
@fetch(view)
|
|
||||||
else
|
|
||||||
@callback(view, @overview[view])
|
|
||||||
|
|
||||||
@counter
|
|
||||||
|
|
||||||
unbind: (counter) ->
|
|
||||||
delete @callbacks[counter]
|
|
||||||
|
|
||||||
fetch: (view) =>
|
|
||||||
return if @fetchActive[view]
|
|
||||||
@fetchActive[view] = true
|
|
||||||
App.Ajax.request(
|
|
||||||
id: 'ticket_overview_' + view
|
|
||||||
type: 'GET',
|
|
||||||
url: App.Config.get('api_path') + '/ticket_overviews',
|
|
||||||
data:
|
|
||||||
view: view
|
|
||||||
processData: true,
|
|
||||||
success: (data) =>
|
|
||||||
@fetchActive[view] = false
|
|
||||||
|
|
||||||
# proccess assets, delete them later
|
|
||||||
if data.assets
|
|
||||||
App.Collection.loadAssets( data.assets )
|
|
||||||
delete data.assets
|
|
||||||
|
|
||||||
@overview[data.view] = data
|
|
||||||
|
|
||||||
@callback(view, data)
|
|
||||||
error: =>
|
|
||||||
@fetchActive[view] = false
|
|
||||||
)
|
|
||||||
|
|
||||||
trigger: (view) =>
|
|
||||||
@callback(view, @get(view))
|
|
||||||
|
|
||||||
callback: (view, data) =>
|
|
||||||
for counter, meta of @callbacks
|
|
||||||
if meta.view is view
|
|
||||||
meta.callback(data)
|
|
|
@ -1,38 +1,38 @@
|
||||||
class App.TaskManager
|
class App.TaskManager
|
||||||
_instance = undefined
|
_instance = undefined
|
||||||
|
|
||||||
@init: ( params ) ->
|
@init: (params) ->
|
||||||
_instance ?= new _taskManagerSingleton( params )
|
_instance ?= new _taskManagerSingleton(params)
|
||||||
|
|
||||||
@all: ->
|
@all: ->
|
||||||
_instance.all()
|
_instance.all()
|
||||||
|
|
||||||
@execute: ( params ) ->
|
@execute: (params) ->
|
||||||
_instance.execute( params )
|
_instance.execute(params)
|
||||||
|
|
||||||
@get: ( key ) ->
|
@get: (key) ->
|
||||||
_instance.get( key )
|
_instance.get(key)
|
||||||
|
|
||||||
@update: ( key, params ) ->
|
@update: (key, params) ->
|
||||||
_instance.update( key, params )
|
_instance.update(key, params)
|
||||||
|
|
||||||
@remove: (key, rerender = true) ->
|
@remove: (key, rerender = true) ->
|
||||||
_instance.remove(key, rerender)
|
_instance.remove(key, rerender)
|
||||||
|
|
||||||
@notify: ( key ) ->
|
@notify: (key) ->
|
||||||
_instance.notify( key )
|
_instance.notify(key)
|
||||||
|
|
||||||
@mute: ( key ) ->
|
@mute: (key) ->
|
||||||
_instance.mute( key )
|
_instance.mute(key)
|
||||||
|
|
||||||
@reorder: ( order ) ->
|
@reorder: (order) ->
|
||||||
_instance.reorder( order )
|
_instance.reorder(order)
|
||||||
|
|
||||||
@reset: ->
|
@reset: ->
|
||||||
_instance.reset()
|
_instance.reset()
|
||||||
|
|
||||||
@worker: ( key ) ->
|
@worker: (key) ->
|
||||||
_instance.worker( key )
|
_instance.worker(key)
|
||||||
|
|
||||||
@nextTaskUrl: ->
|
@nextTaskUrl: ->
|
||||||
_instance.nextTaskUrl()
|
_instance.nextTaskUrl()
|
||||||
|
@ -181,7 +181,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
if task.key isnt params.key
|
if task.key isnt params.key
|
||||||
if task.active
|
if task.active
|
||||||
task.active = false
|
task.active = false
|
||||||
@taskUpdate( task )
|
@taskUpdate(task)
|
||||||
else
|
else
|
||||||
changed = false
|
changed = false
|
||||||
if !task.active
|
if !task.active
|
||||||
|
@ -191,7 +191,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
changed = true
|
changed = true
|
||||||
task.notify = false
|
task.notify = false
|
||||||
if changed
|
if changed
|
||||||
@taskUpdate( task )
|
@taskUpdate(task)
|
||||||
|
|
||||||
# start worker for task if not exists
|
# start worker for task if not exists
|
||||||
@startController(params)
|
@startController(params)
|
||||||
|
@ -405,12 +405,12 @@ class _taskManagerSingleton extends App.Controller
|
||||||
return if @offlineModus
|
return if @offlineModus
|
||||||
for key of @tasksToUpdate
|
for key of @tasksToUpdate
|
||||||
continue if !key
|
continue if !key
|
||||||
task = @get( key )
|
task = @get(key)
|
||||||
continue if !task
|
continue if !task
|
||||||
if @tasksToUpdate[ task.key ] is 'toUpdate'
|
if @tasksToUpdate[ task.key ] is 'toUpdate'
|
||||||
@tasksToUpdate[ task.key ] = 'inProgress'
|
@tasksToUpdate[ task.key ] = 'inProgress'
|
||||||
taskUpdate = new App.Taskbar
|
taskUpdate = new App.Taskbar
|
||||||
taskUpdate.load( task )
|
taskUpdate.load(task)
|
||||||
if taskUpdate.isOnline()
|
if taskUpdate.isOnline()
|
||||||
ui = @
|
ui = @
|
||||||
taskUpdate.save(
|
taskUpdate.save(
|
||||||
|
@ -456,11 +456,11 @@ class _taskManagerSingleton extends App.Controller
|
||||||
|
|
||||||
# initial load of permanent tasks
|
# initial load of permanent tasks
|
||||||
authentication = App.Session.get('id')
|
authentication = App.Session.get('id')
|
||||||
permanentTask = App.Config.get( 'permanentTask' )
|
permanentTask = App.Config.get('permanentTask')
|
||||||
task_count = 0
|
task_count = 0
|
||||||
if permanentTask
|
if permanentTask
|
||||||
for key, config of permanentTask
|
for key, config of permanentTask
|
||||||
if !config.authentication || ( config.authentication && authentication )
|
if !config.authentication || (config.authentication && authentication)
|
||||||
task_count += 1
|
task_count += 1
|
||||||
do (key, config, task_count) =>
|
do (key, config, task_count) =>
|
||||||
App.Delay.set(
|
App.Delay.set(
|
||||||
|
|
|
@ -30,6 +30,11 @@ class App.WebSocket
|
||||||
_instance ?= new _webSocketSingleton
|
_instance ?= new _webSocketSingleton
|
||||||
_instance.spool()
|
_instance.spool()
|
||||||
|
|
||||||
|
@support: ->
|
||||||
|
if _instance == undefined
|
||||||
|
_instance ?= new _webSocketSingleton
|
||||||
|
_instance.support()
|
||||||
|
|
||||||
# The actual Singleton class
|
# The actual Singleton class
|
||||||
class _webSocketSingleton extends App.Controller
|
class _webSocketSingleton extends App.Controller
|
||||||
@include App.LogInclude
|
@include App.LogInclude
|
||||||
|
@ -103,6 +108,9 @@ class _webSocketSingleton extends App.Controller
|
||||||
channel: ->
|
channel: ->
|
||||||
@backend
|
@backend
|
||||||
|
|
||||||
|
support: ->
|
||||||
|
@supported
|
||||||
|
|
||||||
send: (data) =>
|
send: (data) =>
|
||||||
if @backend is 'ajax'
|
if @backend is 'ajax'
|
||||||
@_ajaxSend(data)
|
@_ajaxSend(data)
|
||||||
|
@ -180,6 +188,7 @@ class _webSocketSingleton extends App.Controller
|
||||||
connect: =>
|
connect: =>
|
||||||
|
|
||||||
if !window.WebSocket
|
if !window.WebSocket
|
||||||
|
@supported = false
|
||||||
@backend = 'ajax'
|
@backend = 'ajax'
|
||||||
@log 'debug', 'no support of websocket, use ajax long polling'
|
@log 'debug', 'no support of websocket, use ajax long polling'
|
||||||
@_ajaxInit()
|
@_ajaxInit()
|
||||||
|
|
|
@ -10,80 +10,42 @@ class TicketOverviewsController < ApplicationController
|
||||||
|
|
||||||
# get navbar overview data
|
# get navbar overview data
|
||||||
if !params[:view]
|
if !params[:view]
|
||||||
result = Ticket::Overviews.list(
|
index_and_lists = Ticket::Overviews.index(current_user)
|
||||||
current_user: current_user,
|
indexes = []
|
||||||
)
|
index_and_lists.each { |index|
|
||||||
render json: result
|
assets = {}
|
||||||
return
|
overview = Overview.lookup(id: index[:overview][:id])
|
||||||
end
|
meta = {
|
||||||
|
name: overview.name,
|
||||||
# get real overview data
|
prio: overview.prio,
|
||||||
if params[:array]
|
link: overview.link,
|
||||||
overview = Ticket::Overviews.list(
|
count: index[:count],
|
||||||
view: params[:view],
|
}
|
||||||
current_user: current_user,
|
indexes.push meta
|
||||||
array: true,
|
|
||||||
)
|
|
||||||
tickets = []
|
|
||||||
overview[:tickets].each {|ticket_id|
|
|
||||||
data = { id: ticket_id }
|
|
||||||
tickets.push data
|
|
||||||
}
|
}
|
||||||
|
render json: indexes
|
||||||
# return result
|
|
||||||
render json: {
|
|
||||||
overview: overview[:overview],
|
|
||||||
tickets: tickets,
|
|
||||||
tickets_count: overview[:tickets_count],
|
|
||||||
}
|
|
||||||
return
|
|
||||||
end
|
|
||||||
overview = Ticket::Overviews.list(
|
|
||||||
view: params[:view],
|
|
||||||
current_user: current_user,
|
|
||||||
array: true,
|
|
||||||
)
|
|
||||||
if !overview
|
|
||||||
render json: { error: "No such view #{params[:view]}!" }, status: :unprocessable_entity
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# get related users
|
index_and_lists = Ticket::Overviews.index(current_user)
|
||||||
|
|
||||||
assets = {}
|
assets = {}
|
||||||
overview[:ticket_ids].each {|ticket_id|
|
result = {}
|
||||||
ticket = Ticket.lookup( id: ticket_id )
|
index_and_lists.each { |index|
|
||||||
assets = ticket.assets(assets)
|
next if index[:overview][:view] != params[:view]
|
||||||
}
|
|
||||||
|
|
||||||
# get groups
|
overview = Overview.lookup(id: index[:overview][:id])
|
||||||
group_ids = []
|
assets = overview.assets(assets)
|
||||||
Group.where( active: true ).each { |group|
|
index[:tickets].each {|ticket_meta|
|
||||||
group_ids.push group.id
|
ticket = Ticket.lookup(id: ticket_meta[:id])
|
||||||
}
|
assets = ticket.assets(assets)
|
||||||
agents = {}
|
|
||||||
User.of_role('Agent').each { |user|
|
|
||||||
agents[ user.id ] = 1
|
|
||||||
}
|
|
||||||
groups_users = {}
|
|
||||||
group_ids.each {|group_id|
|
|
||||||
groups_users[ group_id ] = []
|
|
||||||
Group.find(group_id).users.each {|user|
|
|
||||||
next if !agents[ user.id ]
|
|
||||||
groups_users[ group_id ].push user.id
|
|
||||||
assets = user.assets( assets )
|
|
||||||
}
|
}
|
||||||
|
result = index
|
||||||
}
|
}
|
||||||
|
|
||||||
# return result
|
|
||||||
render json: {
|
render json: {
|
||||||
view: params[:view],
|
|
||||||
overview: overview[:overview],
|
|
||||||
ticket_ids: overview[:ticket_ids],
|
|
||||||
tickets_count: overview[:tickets_count],
|
|
||||||
bulk: {
|
|
||||||
group_id__owner_id: groups_users,
|
|
||||||
},
|
|
||||||
assets: assets,
|
assets: assets,
|
||||||
|
index: result,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,7 @@ class TicketsController < ApplicationController
|
||||||
def stats
|
def stats
|
||||||
|
|
||||||
if !params[:user_id] && !params[:organization_id]
|
if !params[:user_id] && !params[:organization_id]
|
||||||
fail 'Need user_id or organization_id as param'
|
raise 'Need user_id or organization_id as param'
|
||||||
end
|
end
|
||||||
|
|
||||||
# permission check
|
# permission check
|
||||||
|
|
|
@ -34,7 +34,7 @@ add a new activity entry for an object
|
||||||
if data[:role]
|
if data[:role]
|
||||||
role = Role.lookup(name: data[:role])
|
role = Role.lookup(name: data[:role])
|
||||||
if !role
|
if !role
|
||||||
fail "No such Role #{data[:role]}"
|
raise "No such Role #{data[:role]}"
|
||||||
end
|
end
|
||||||
role_id = role.id
|
role_id = role.id
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,7 +71,7 @@ returns
|
||||||
def self.param_cleanup(params, newObject = false)
|
def self.param_cleanup(params, newObject = false)
|
||||||
|
|
||||||
if params.nil?
|
if params.nil?
|
||||||
fail "No params for #{self}!"
|
raise "No params for #{self}!"
|
||||||
end
|
end
|
||||||
|
|
||||||
# ignore id for new objects
|
# ignore id for new objects
|
||||||
|
@ -377,7 +377,7 @@ returns
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
fail 'Need name, id, login or email for lookup()'
|
raise 'Need name, id, login or email for lookup()'
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -535,7 +535,7 @@ returns
|
||||||
record.save
|
record.save
|
||||||
return record
|
return record
|
||||||
else
|
else
|
||||||
fail 'Need name, login, email or locale for create_or_update()'
|
raise 'Need name, login, email or locale for create_or_update()'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,7 @@ returns
|
||||||
if location =~ /^http/i
|
if location =~ /^http/i
|
||||||
result = UserAgent.get(location)
|
result = UserAgent.get(location)
|
||||||
if !result.success?
|
if !result.success?
|
||||||
fail result.error
|
raise result.error
|
||||||
end
|
end
|
||||||
cal_file = result.body
|
cal_file = result.body
|
||||||
else
|
else
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Channel::Driver::Facebook
|
||||||
access_token = page['access_token']
|
access_token = page['access_token']
|
||||||
}
|
}
|
||||||
if !access_token
|
if !access_token
|
||||||
fail "No access_token found for fb_object_id: #{fb_object_id}"
|
raise "No access_token found for fb_object_id: #{fb_object_id}"
|
||||||
end
|
end
|
||||||
client = Facebook.new(access_token)
|
client = Facebook.new(access_token)
|
||||||
client.from_article(article)
|
client.from_article(article)
|
||||||
|
|
|
@ -184,7 +184,7 @@ returns
|
||||||
|
|
||||||
def stream
|
def stream
|
||||||
sync = @channel.options['sync']
|
sync = @channel.options['sync']
|
||||||
fail 'Need channel.options[\'sync\'] for account, but no params found' if !sync
|
raise 'Need channel.options[\'sync\'] for account, but no params found' if !sync
|
||||||
|
|
||||||
filter = {}
|
filter = {}
|
||||||
if sync['search']
|
if sync['search']
|
||||||
|
@ -315,7 +315,7 @@ returns
|
||||||
def check_external_credential(options)
|
def check_external_credential(options)
|
||||||
if options[:auth] && options[:auth][:external_credential_id]
|
if options[:auth] && options[:auth][:external_credential_id]
|
||||||
external_credential = ExternalCredential.find_by(id: options[:auth][:external_credential_id])
|
external_credential = ExternalCredential.find_by(id: options[:auth][:external_credential_id])
|
||||||
fail "No such ExternalCredential.find(#{options[:auth][:external_credential_id]})" if !external_credential
|
raise "No such ExternalCredential.find(#{options[:auth][:external_credential_id]})" if !external_credential
|
||||||
options[:auth][:consumer_key] = external_credential.credentials['consumer_key']
|
options[:auth][:consumer_key] = external_credential.credentials['consumer_key']
|
||||||
options[:auth][:consumer_secret] = external_credential.credentials['consumer_secret']
|
options[:auth][:consumer_secret] = external_credential.credentials['consumer_secret']
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,8 +26,8 @@ class Locale < ApplicationModel
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
fail "Can't load locales from #{url}" if !result
|
raise "Can't load locales from #{url}" if !result
|
||||||
fail "Can't load locales from #{url}: #{result.error}" if !result.success?
|
raise "Can't load locales from #{url}: #{result.error}" if !result.success?
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
result.data.each {|locale|
|
result.data.each {|locale|
|
||||||
|
|
|
@ -12,9 +12,9 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
|
||||||
|
|
||||||
# send email
|
# send email
|
||||||
if !ticket.group.email_address_id
|
if !ticket.group.email_address_id
|
||||||
fail "Can't send email, no email address definde for group id '#{ticket.group.id}'"
|
raise "Can't send email, no email address definde for group id '#{ticket.group.id}'"
|
||||||
elsif !ticket.group.email_address.channel_id
|
elsif !ticket.group.email_address.channel_id
|
||||||
fail "Can't send email, no channel definde for email_address id '#{ticket.group.email_address_id}'"
|
raise "Can't send email, no channel definde for email_address id '#{ticket.group.email_address_id}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
channel = ticket.group.email_address.channel
|
channel = ticket.group.email_address.channel
|
||||||
|
|
|
@ -20,15 +20,15 @@ class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
|
||||||
return if type['name'] !~ /\Afacebook/
|
return if type['name'] !~ /\Afacebook/
|
||||||
|
|
||||||
ticket = Ticket.lookup(id: record.ticket_id)
|
ticket = Ticket.lookup(id: record.ticket_id)
|
||||||
fail "Can't find ticket.preferences for Ticket.find(#{record.ticket_id})" if !ticket.preferences
|
raise "Can't find ticket.preferences for Ticket.find(#{record.ticket_id})" if !ticket.preferences
|
||||||
fail "Can't find ticket.preferences['channel_id'] for Ticket.find(#{record.ticket_id})" if !ticket.preferences['channel_id']
|
raise "Can't find ticket.preferences['channel_id'] for Ticket.find(#{record.ticket_id})" if !ticket.preferences['channel_id']
|
||||||
channel = Channel.lookup(id: ticket.preferences['channel_id'])
|
channel = Channel.lookup(id: ticket.preferences['channel_id'])
|
||||||
fail "Channel.find(#{channel.id}) isn't a twitter channel!" if channel.options[:adapter] !~ /\Afacebook/i
|
raise "Channel.find(#{channel.id}) isn't a twitter channel!" if channel.options[:adapter] !~ /\Afacebook/i
|
||||||
|
|
||||||
# check source object id
|
# check source object id
|
||||||
ticket = record.ticket
|
ticket = record.ticket
|
||||||
if !ticket.preferences['channel_fb_object_id']
|
if !ticket.preferences['channel_fb_object_id']
|
||||||
fail "fb object id is missing in ticket.preferences['channel_fb_object_id'] for Ticket.find(#{ticket.id})"
|
raise "fb object id is missing in ticket.preferences['channel_fb_object_id'] for Ticket.find(#{ticket.id})"
|
||||||
end
|
end
|
||||||
|
|
||||||
# fill in_reply_to
|
# fill in_reply_to
|
||||||
|
|
|
@ -18,11 +18,11 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
|
||||||
return if type['name'] !~ /\Atwitter/i
|
return if type['name'] !~ /\Atwitter/i
|
||||||
|
|
||||||
ticket = Ticket.lookup(id: record.ticket_id)
|
ticket = Ticket.lookup(id: record.ticket_id)
|
||||||
fail "Can't find ticket.preferences for Ticket.find(#{record.ticket_id})" if !ticket.preferences
|
raise "Can't find ticket.preferences for Ticket.find(#{record.ticket_id})" if !ticket.preferences
|
||||||
fail "Can't find ticket.preferences['channel_id'] for Ticket.find(#{record.ticket_id})" if !ticket.preferences['channel_id']
|
raise "Can't find ticket.preferences['channel_id'] for Ticket.find(#{record.ticket_id})" if !ticket.preferences['channel_id']
|
||||||
channel = Channel.lookup(id: ticket.preferences['channel_id'])
|
channel = Channel.lookup(id: ticket.preferences['channel_id'])
|
||||||
fail "No such channel id #{ticket.preferences['channel_id']}" if !channel
|
raise "No such channel id #{ticket.preferences['channel_id']}" if !channel
|
||||||
fail "Channel.find(#{channel.id}) isn't a twitter channel!" if channel.options[:adapter] !~ /\Atwitter/i
|
raise "Channel.find(#{channel.id}) isn't a twitter channel!" if channel.options[:adapter] !~ /\Atwitter/i
|
||||||
tweet = channel.deliver(
|
tweet = channel.deliver(
|
||||||
type: type['name'],
|
type: type['name'],
|
||||||
to: record.to,
|
to: record.to,
|
||||||
|
@ -54,7 +54,7 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
|
||||||
record.preferences[:twitter_mention_ids] = twitter_mention_ids
|
record.preferences[:twitter_mention_ids] = twitter_mention_ids
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
fail "Unknown tweet type '#{tweet.class}'"
|
raise "Unknown tweet type '#{tweet.class}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
record.message_id = tweet.id
|
record.message_id = tweet.id
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
|
||||||
# set sender
|
# set sender
|
||||||
email_address = ticket.group.email_address
|
email_address = ticket.group.email_address
|
||||||
if !email_address
|
if !email_address
|
||||||
fail "No email address found for group '#{ticket.group.name}'"
|
raise "No email address found for group '#{ticket.group.name}'"
|
||||||
end
|
end
|
||||||
system_sender = "#{email_address.realname} <#{email_address.email}>"
|
system_sender = "#{email_address.realname} <#{email_address.email}>"
|
||||||
if Setting.get('ticket_define_email_from') == 'AgentNameSystemAddressName'
|
if Setting.get('ticket_define_email_from') == 'AgentNameSystemAddressName'
|
||||||
|
|
|
@ -105,7 +105,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
fail "unknown object for notification #{event[:name]}"
|
raise "unknown object for notification #{event[:name]}"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
list_objects
|
list_objects
|
||||||
|
|
|
@ -162,7 +162,7 @@ class Observer::Ticket::Notification::BackgroundJob
|
||||||
elsif @p[:type] == 'escalation_warning'
|
elsif @p[:type] == 'escalation_warning'
|
||||||
template = 'ticket_escalation_warning'
|
template = 'ticket_escalation_warning'
|
||||||
else
|
else
|
||||||
fail "unknown type for notification #{@p[:type]}"
|
raise "unknown type for notification #{@p[:type]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
NotificationFactory.notification(
|
NotificationFactory.notification(
|
||||||
|
|
|
@ -10,6 +10,8 @@ class Overview < ApplicationModel
|
||||||
before_create :fill_link
|
before_create :fill_link
|
||||||
before_update :fill_link
|
before_update :fill_link
|
||||||
|
|
||||||
|
latest_change_support
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# fill link
|
# fill link
|
||||||
|
|
|
@ -103,7 +103,7 @@ note: will not take down package migrations, use Package.unlink instead
|
||||||
package = entry.sub(%r{^.*/(.+?)\.szpm$}, '\1')
|
package = entry.sub(%r{^.*/(.+?)\.szpm$}, '\1')
|
||||||
end
|
end
|
||||||
if package == false
|
if package == false
|
||||||
fail "Can't link package, '#{package_base_dir}' is no package source directory!"
|
raise "Can't link package, '#{package_base_dir}' is no package source directory!"
|
||||||
end
|
end
|
||||||
logger.debug package.inspect
|
logger.debug package.inspect
|
||||||
package
|
package
|
||||||
|
@ -184,7 +184,7 @@ link files + execute migration up
|
||||||
if File.file?(entry.to_s) && (File.file?(dest.to_s) && !File.symlink?(dest.to_s))
|
if File.file?(entry.to_s) && (File.file?(dest.to_s) && !File.symlink?(dest.to_s))
|
||||||
backup_file = dest.to_s + '.link_backup'
|
backup_file = dest.to_s + '.link_backup'
|
||||||
if File.exist?(backup_file)
|
if File.exist?(backup_file)
|
||||||
fail "Can't link #{entry} -> #{dest}, destination and .link_backup already exists!"
|
raise "Can't link #{entry} -> #{dest}, destination and .link_backup already exists!"
|
||||||
else
|
else
|
||||||
logger.info "Create backup file of #{dest} -> #{backup_file}."
|
logger.info "Create backup file of #{dest} -> #{backup_file}."
|
||||||
File.rename(dest.to_s, backup_file)
|
File.rename(dest.to_s, backup_file)
|
||||||
|
@ -243,10 +243,10 @@ returns
|
||||||
if package_db
|
if package_db
|
||||||
if !data[:reinstall]
|
if !data[:reinstall]
|
||||||
if Gem::Version.new(package_db.version) == Gem::Version.new(meta[:version])
|
if Gem::Version.new(package_db.version) == Gem::Version.new(meta[:version])
|
||||||
fail "Package '#{meta[:name]}-#{meta[:version]}' already installed!"
|
raise "Package '#{meta[:name]}-#{meta[:version]}' already installed!"
|
||||||
end
|
end
|
||||||
if Gem::Version.new(package_db.version) > Gem::Version.new(meta[:version])
|
if Gem::Version.new(package_db.version) > Gem::Version.new(meta[:version])
|
||||||
fail "Newer version (#{package_db.version}) of package '#{meta[:name]}-#{meta[:version]}' already installed!"
|
raise "Newer version (#{package_db.version}) of package '#{meta[:name]}-#{meta[:version]}' already installed!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ returns
|
||||||
def self.reinstall(package_name)
|
def self.reinstall(package_name)
|
||||||
package = Package.find_by(name: package_name)
|
package = Package.find_by(name: package_name)
|
||||||
if !package
|
if !package
|
||||||
fail "No such package '#{package_name}'"
|
raise "No such package '#{package_name}'"
|
||||||
end
|
end
|
||||||
file = _get_bin(package.name, package.version)
|
file = _get_bin(package.name, package.version)
|
||||||
install(string: file, reinstall: true)
|
install(string: file, reinstall: true)
|
||||||
|
@ -367,7 +367,7 @@ returns
|
||||||
version: version,
|
version: version,
|
||||||
)
|
)
|
||||||
if !package
|
if !package
|
||||||
fail "No such package '#{name}' version '#{version}'"
|
raise "No such package '#{name}' version '#{version}'"
|
||||||
end
|
end
|
||||||
list = Store.list(
|
list = Store.list(
|
||||||
object: 'Package',
|
object: 'Package',
|
||||||
|
@ -376,10 +376,10 @@ returns
|
||||||
|
|
||||||
# find file
|
# find file
|
||||||
if !list || !list.first
|
if !list || !list.first
|
||||||
fail "No such file in storage list #{name} #{version}"
|
raise "No such file in storage list #{name} #{version}"
|
||||||
end
|
end
|
||||||
if !list.first.content
|
if !list.first.content
|
||||||
fail "No such file in storage #{name} #{version}"
|
raise "No such file in storage #{name} #{version}"
|
||||||
end
|
end
|
||||||
list.first.content
|
list.first.content
|
||||||
end
|
end
|
||||||
|
@ -497,7 +497,7 @@ returns
|
||||||
name = $2
|
name = $2
|
||||||
end
|
end
|
||||||
if !version || !name
|
if !version || !name
|
||||||
fail "Invalid package migration '#{migration}'"
|
raise "Invalid package migration '#{migration}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
# down
|
# down
|
||||||
|
|
|
@ -33,7 +33,7 @@ set config setting
|
||||||
def self.set(name, value)
|
def self.set(name, value)
|
||||||
setting = Setting.find_by( name: name )
|
setting = Setting.find_by( name: name )
|
||||||
if !setting
|
if !setting
|
||||||
fail "Can't find config setting '#{name}'"
|
raise "Can't find config setting '#{name}'"
|
||||||
end
|
end
|
||||||
setting.state_current = { value: value }
|
setting.state_current = { value: value }
|
||||||
setting.save
|
setting.save
|
||||||
|
@ -68,7 +68,7 @@ reset config setting to default
|
||||||
def self.reset(name)
|
def self.reset(name)
|
||||||
setting = Setting.find_by( name: name )
|
setting = Setting.find_by( name: name )
|
||||||
if !setting
|
if !setting
|
||||||
fail "Can't find config setting '#{name}'"
|
raise "Can't find config setting '#{name}'"
|
||||||
end
|
end
|
||||||
setting.state_current = setting.state_initial
|
setting.state_current = setting.state_initial
|
||||||
setting.save
|
setting.save
|
||||||
|
|
|
@ -142,7 +142,7 @@ returns
|
||||||
def content
|
def content
|
||||||
file = Store::File.find_by(id: store_file_id)
|
file = Store::File.find_by(id: store_file_id)
|
||||||
if !file
|
if !file
|
||||||
fail "No such file #{store_file_id}!"
|
raise "No such file #{store_file_id}!"
|
||||||
end
|
end
|
||||||
file.content
|
file.content
|
||||||
end
|
end
|
||||||
|
@ -150,7 +150,7 @@ returns
|
||||||
def provider
|
def provider
|
||||||
file = Store::File.find_by(id: store_file_id)
|
file = Store::File.find_by(id: store_file_id)
|
||||||
if !file
|
if !file
|
||||||
fail "No such file #{store_file_id}!"
|
raise "No such file #{store_file_id}!"
|
||||||
end
|
end
|
||||||
file.provider
|
file.provider
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,7 @@ do also verify of written data
|
||||||
# load backend based on config
|
# load backend based on config
|
||||||
adapter_name = Setting.get('storage_provider') || 'DB'
|
adapter_name = Setting.get('storage_provider') || 'DB'
|
||||||
if !adapter_name
|
if !adapter_name
|
||||||
fail 'Missing storage_provider setting option'
|
raise 'Missing storage_provider setting option'
|
||||||
end
|
end
|
||||||
adapter = load_adapter("Store::Provider::#{adapter_name}")
|
adapter = load_adapter("Store::Provider::#{adapter_name}")
|
||||||
adapter.add(data, sha)
|
adapter.add(data, sha)
|
||||||
|
@ -40,7 +40,7 @@ do also verify of written data
|
||||||
read_data = adapter.get(sha)
|
read_data = adapter.get(sha)
|
||||||
read_sha = Digest::SHA256.hexdigest(read_data)
|
read_sha = Digest::SHA256.hexdigest(read_data)
|
||||||
if sha != read_sha
|
if sha != read_sha
|
||||||
fail "Content not written correctly (provider #{adapter_name})."
|
raise "Content not written correctly (provider #{adapter_name})."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Store::Provider::File
|
||||||
# check sha
|
# check sha
|
||||||
local_sha = Digest::SHA256.hexdigest(get(sha))
|
local_sha = Digest::SHA256.hexdigest(get(sha))
|
||||||
if sha != local_sha
|
if sha != local_sha
|
||||||
fail "ERROR: Corrupt file in fs #{location}, sha should be #{sha} but is #{local_sha}"
|
raise "ERROR: Corrupt file in fs #{location}, sha should be #{sha} but is #{local_sha}"
|
||||||
end
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -29,7 +29,7 @@ class Store::Provider::File
|
||||||
location = get_location(sha)
|
location = get_location(sha)
|
||||||
Rails.logger.debug "read from fs #{location}"
|
Rails.logger.debug "read from fs #{location}"
|
||||||
if !File.exist?(location)
|
if !File.exist?(location)
|
||||||
fail "ERROR: No such file #{location}"
|
raise "ERROR: No such file #{location}"
|
||||||
end
|
end
|
||||||
data = File.open(location, 'rb')
|
data = File.open(location, 'rb')
|
||||||
content = data.read
|
content = data.read
|
||||||
|
@ -37,7 +37,7 @@ class Store::Provider::File
|
||||||
# check sha
|
# check sha
|
||||||
local_sha = Digest::SHA256.hexdigest(content)
|
local_sha = Digest::SHA256.hexdigest(content)
|
||||||
if local_sha != sha
|
if local_sha != sha
|
||||||
fail "ERROR: Corrupt file in fs #{location}, sha should be #{sha} but is #{local_sha}"
|
raise "ERROR: Corrupt file in fs #{location}, sha should be #{sha} but is #{local_sha}"
|
||||||
end
|
end
|
||||||
content
|
content
|
||||||
end
|
end
|
||||||
|
|
|
@ -367,7 +367,7 @@ get count of tickets and tickets which match on selector
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.selectors(selectors, limit = 10, current_user = nil)
|
def self.selectors(selectors, limit = 10, current_user = nil)
|
||||||
fail 'no selectors given' if !selectors
|
raise 'no selectors given' if !selectors
|
||||||
query, bind_params, tables = selector2sql(selectors, current_user)
|
query, bind_params, tables = selector2sql(selectors, current_user)
|
||||||
return [] if !query
|
return [] if !query
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ condition example
|
||||||
tables += ', users owners'
|
tables += ', users owners'
|
||||||
query += 'tickets.owner_id = owners.id'
|
query += 'tickets.owner_id = owners.id'
|
||||||
else
|
else
|
||||||
fail "invalid selector #{attribute.inspect}->#{selector.inspect}"
|
raise "invalid selector #{attribute.inspect}->#{selector.inspect}"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,10 +462,10 @@ condition example
|
||||||
selectors.each {|attribute, selector_raw|
|
selectors.each {|attribute, selector_raw|
|
||||||
|
|
||||||
# validation
|
# validation
|
||||||
fail "Invalid selector #{selector_raw.inspect}" if !selector_raw
|
raise "Invalid selector #{selector_raw.inspect}" if !selector_raw
|
||||||
fail "Invalid selector #{selector_raw.inspect}" if !selector_raw.respond_to?(:key?)
|
raise "Invalid selector #{selector_raw.inspect}" if !selector_raw.respond_to?(:key?)
|
||||||
selector = selector_raw.stringify_keys
|
selector = selector_raw.stringify_keys
|
||||||
fail "Invalid selector, operator missing #{selector.inspect}" if !selector['operator']
|
raise "Invalid selector, operator missing #{selector.inspect}" if !selector['operator']
|
||||||
|
|
||||||
# validate value / allow empty but only if pre_condition exists
|
# validate value / allow empty but only if pre_condition exists
|
||||||
if (selector['value'].class == String || selector['value'].class == Array) && (selector['value'].respond_to?(:empty?) && selector['value'].empty?)
|
if (selector['value'].class == String || selector['value'].class == Array) && (selector['value'].respond_to?(:empty?) && selector['value'].empty?)
|
||||||
|
@ -492,11 +492,11 @@ condition example
|
||||||
query += "#{attribute} IS NOT NULL"
|
query += "#{attribute} IS NOT NULL"
|
||||||
end
|
end
|
||||||
elsif selector['pre_condition'] == 'current_user.id'
|
elsif selector['pre_condition'] == 'current_user.id'
|
||||||
fail "Use current_user.id in selector, but no current_user is set #{selector.inspect}" if !current_user_id
|
raise "Use current_user.id in selector, but no current_user is set #{selector.inspect}" if !current_user_id
|
||||||
query += "#{attribute} IN (?)"
|
query += "#{attribute} IN (?)"
|
||||||
bind_params.push current_user_id
|
bind_params.push current_user_id
|
||||||
elsif selector['pre_condition'] == 'current_user.organization_id'
|
elsif selector['pre_condition'] == 'current_user.organization_id'
|
||||||
fail "Use current_user.id in selector, but no current_user is set #{selector.inspect}" if !current_user_id
|
raise "Use current_user.id in selector, but no current_user is set #{selector.inspect}" if !current_user_id
|
||||||
query += "#{attribute} IN (?)"
|
query += "#{attribute} IN (?)"
|
||||||
user = User.lookup(id: current_user_id)
|
user = User.lookup(id: current_user_id)
|
||||||
bind_params.push user.organization_id
|
bind_params.push user.organization_id
|
||||||
|
@ -563,7 +563,7 @@ condition example
|
||||||
elsif selector['range'] == 'year'
|
elsif selector['range'] == 'year'
|
||||||
time = Time.zone.now - selector['value'].to_i.years
|
time = Time.zone.now - selector['value'].to_i.years
|
||||||
else
|
else
|
||||||
fail "Unknown selector attributes '#{selector.inspect}'"
|
raise "Unknown selector attributes '#{selector.inspect}'"
|
||||||
end
|
end
|
||||||
bind_params.push time
|
bind_params.push time
|
||||||
elsif selector['operator'] == 'within next (relative)'
|
elsif selector['operator'] == 'within next (relative)'
|
||||||
|
@ -580,7 +580,7 @@ condition example
|
||||||
elsif selector['range'] == 'year'
|
elsif selector['range'] == 'year'
|
||||||
time = Time.zone.now + selector['value'].to_i.years
|
time = Time.zone.now + selector['value'].to_i.years
|
||||||
else
|
else
|
||||||
fail "Unknown selector attributes '#{selector.inspect}'"
|
raise "Unknown selector attributes '#{selector.inspect}'"
|
||||||
end
|
end
|
||||||
bind_params.push time
|
bind_params.push time
|
||||||
elsif selector['operator'] == 'before (relative)'
|
elsif selector['operator'] == 'before (relative)'
|
||||||
|
@ -597,7 +597,7 @@ condition example
|
||||||
elsif selector['range'] == 'year'
|
elsif selector['range'] == 'year'
|
||||||
time = Time.zone.now - selector['value'].to_i.years
|
time = Time.zone.now - selector['value'].to_i.years
|
||||||
else
|
else
|
||||||
fail "Unknown selector attributes '#{selector.inspect}'"
|
raise "Unknown selector attributes '#{selector.inspect}'"
|
||||||
end
|
end
|
||||||
bind_params.push time
|
bind_params.push time
|
||||||
elsif selector['operator'] == 'after (relative)'
|
elsif selector['operator'] == 'after (relative)'
|
||||||
|
@ -614,11 +614,11 @@ condition example
|
||||||
elsif selector['range'] == 'year'
|
elsif selector['range'] == 'year'
|
||||||
time = Time.zone.now + selector['value'].to_i.years
|
time = Time.zone.now + selector['value'].to_i.years
|
||||||
else
|
else
|
||||||
fail "Unknown selector attributes '#{selector.inspect}'"
|
raise "Unknown selector attributes '#{selector.inspect}'"
|
||||||
end
|
end
|
||||||
bind_params.push time
|
bind_params.push time
|
||||||
else
|
else
|
||||||
fail "Invalid operator '#{selector['operator']}' for '#{selector['value'].inspect}'"
|
raise "Invalid operator '#{selector['operator']}' for '#{selector['value'].inspect}'"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
[query, bind_params, tables]
|
[query, bind_params, tables]
|
||||||
|
|
|
@ -84,7 +84,7 @@ returns
|
||||||
}
|
}
|
||||||
config.hours = hours
|
config.hours = hours
|
||||||
if !hours || hours.empty?
|
if !hours || hours.empty?
|
||||||
fail "No congifure hours found in calendar #{calendar.inspect}"
|
raise "No congifure hours found in calendar #{calendar.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# get holidays
|
# get holidays
|
||||||
|
|
|
@ -23,7 +23,7 @@ returns
|
||||||
ticket = Ticket.find_by( number: number )
|
ticket = Ticket.find_by( number: number )
|
||||||
return number if !ticket
|
return number if !ticket
|
||||||
}
|
}
|
||||||
fail "Can't generate new ticket number!"
|
raise "Can't generate new ticket number!"
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -47,11 +47,11 @@ returns
|
||||||
# load backend based on config
|
# load backend based on config
|
||||||
adapter_name = Setting.get('ticket_number')
|
adapter_name = Setting.get('ticket_number')
|
||||||
if !adapter_name
|
if !adapter_name
|
||||||
fail 'Missing ticket_number setting option'
|
raise 'Missing ticket_number setting option'
|
||||||
end
|
end
|
||||||
adapter = load_adapter(adapter_name)
|
adapter = load_adapter(adapter_name)
|
||||||
if !adapter
|
if !adapter
|
||||||
fail "Can't load ticket_number adapter '#{adapter_name}'"
|
raise "Can't load ticket_number adapter '#{adapter_name}'"
|
||||||
end
|
end
|
||||||
adapter
|
adapter
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,10 @@ module Ticket::Overviews
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
all overview by user
|
all overviews by user
|
||||||
|
|
||||||
result = Ticket::Overviews.all(
|
result = Ticket::Overviews.all(
|
||||||
:current_user => User.find(123),
|
current_user: User.find(123),
|
||||||
)
|
)
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
@ -15,137 +15,105 @@ returns
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.all (data)
|
def self.all(data)
|
||||||
|
|
||||||
# get customer overviews
|
# get customer overviews
|
||||||
if data[:current_user].role?('Customer')
|
if data[:current_user].role?('Customer')
|
||||||
role = Role.find_by( name: 'Customer' )
|
role = Role.find_by(name: 'Customer')
|
||||||
overviews = if data[:current_user].organization_id && data[:current_user].organization.shared
|
overviews = if data[:current_user].organization_id && data[:current_user].organization.shared
|
||||||
Overview.where( role_id: role.id, active: true )
|
Overview.where(role_id: role.id, active: true)
|
||||||
else
|
else
|
||||||
Overview.where( role_id: role.id, organization_shared: false, active: true )
|
Overview.where(role_id: role.id, organization_shared: false, active: true)
|
||||||
end
|
end
|
||||||
return overviews
|
return overviews
|
||||||
end
|
end
|
||||||
|
|
||||||
# get agent overviews
|
# get agent overviews
|
||||||
return if !data[:current_user].role?( 'Agent' )
|
return if !data[:current_user].role?('Agent')
|
||||||
role = Role.find_by( name: 'Agent' )
|
role = Role.find_by(name: 'Agent')
|
||||||
Overview.where( role_id: role.id, active: true )
|
Overview.where(role_id: role.id, active: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
selected overview by user
|
result = Ticket::Overviews.index(User.find(123))
|
||||||
|
|
||||||
result = Ticket::Overviews.list(
|
|
||||||
current_user: User.find(123),
|
|
||||||
view: 'some_view_url',
|
|
||||||
)
|
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
|
||||||
result = {
|
[
|
||||||
tickets: tickets, # [ticket1, ticket2, ticket3]
|
{
|
||||||
tickets_count: tickets_count, # count of tickets
|
overview: {
|
||||||
overview: overview_selected_raw, # overview attributes
|
id: 123,
|
||||||
|
updated_at: ...,
|
||||||
|
},
|
||||||
|
count: 3,
|
||||||
|
tickets: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
updated_at: ...,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
updated_at: ...,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
updated_at: ...,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.list (data)
|
def self.index(user)
|
||||||
|
overviews = Ticket::Overviews.all(
|
||||||
overviews = all(data)
|
current_user: user,
|
||||||
return if !overviews
|
)
|
||||||
|
|
||||||
# build up attributes hash
|
|
||||||
overview_selected = nil
|
|
||||||
overview_selected_raw = nil
|
|
||||||
|
|
||||||
overviews.each { |overview|
|
|
||||||
|
|
||||||
# remember selected view
|
|
||||||
if data[:view] && data[:view] == overview.link
|
|
||||||
overview_selected = overview
|
|
||||||
overview_selected_raw = Marshal.load( Marshal.dump(overview.attributes) )
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
if data[:view] && !overview_selected
|
|
||||||
fail "No such view '#{data[:view]}'"
|
|
||||||
end
|
|
||||||
|
|
||||||
# get only tickets with permissions
|
# get only tickets with permissions
|
||||||
access_condition = Ticket.access_condition( data[:current_user] )
|
access_condition = Ticket.access_condition(user)
|
||||||
|
|
||||||
# overview meta for navbar
|
list = []
|
||||||
if !overview_selected
|
overviews.each {|overview|
|
||||||
|
query_condition, bind_condition = Ticket.selector2sql(overview.condition, user)
|
||||||
|
|
||||||
# loop each overview
|
order_by = "#{overview.order[:by]} #{overview.order[:direction]}"
|
||||||
result = []
|
if overview.group_by && !overview.group_by.empty?
|
||||||
overviews.each { |overview|
|
order_by = "#{overview.group_by}_id, #{order_by}"
|
||||||
|
|
||||||
query_condition, bind_condition = Ticket.selector2sql(overview.condition, data[:current_user])
|
|
||||||
|
|
||||||
# get count
|
|
||||||
count = Ticket.where( access_condition ).where( query_condition, *bind_condition ).count()
|
|
||||||
|
|
||||||
# get meta info
|
|
||||||
all = {
|
|
||||||
name: overview.name,
|
|
||||||
prio: overview.prio,
|
|
||||||
link: overview.link,
|
|
||||||
}
|
|
||||||
|
|
||||||
# push to result data
|
|
||||||
result.push all.merge( { count: count } )
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
# get result list
|
|
||||||
if data[:array]
|
|
||||||
order_by = overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s
|
|
||||||
if overview_selected.group_by && !overview_selected.group_by.empty?
|
|
||||||
order_by = overview_selected.group_by + '_id, ' + order_by
|
|
||||||
end
|
end
|
||||||
|
|
||||||
query_condition, bind_condition = Ticket.selector2sql(overview_selected.condition, data[:current_user])
|
ticket_result = Ticket.select('id, updated_at')
|
||||||
|
.where(access_condition)
|
||||||
|
.where(query_condition, *bind_condition)
|
||||||
|
.order(order_by)
|
||||||
|
.limit(500)
|
||||||
|
|
||||||
tickets = Ticket.select('id')
|
tickets = []
|
||||||
.where( access_condition )
|
ticket_result.each { |ticket|
|
||||||
.where( query_condition, *bind_condition )
|
ticket_item = {
|
||||||
.order( order_by )
|
id: ticket.id,
|
||||||
.limit( 500 )
|
updated_at: ticket.updated_at,
|
||||||
|
}
|
||||||
ticket_ids = []
|
tickets.push ticket_item
|
||||||
tickets.each { |ticket|
|
}
|
||||||
ticket_ids.push ticket.id
|
count = Ticket.where(access_condition).where(query_condition, *bind_condition).count()
|
||||||
|
item = {
|
||||||
|
overview: {
|
||||||
|
id: overview.id,
|
||||||
|
view: overview.link,
|
||||||
|
updated_at: overview.updated_at,
|
||||||
|
},
|
||||||
|
tickets: tickets,
|
||||||
|
count: count,
|
||||||
}
|
}
|
||||||
|
|
||||||
tickets_count = Ticket.where( access_condition ).where( query_condition, *bind_condition ).count()
|
list.push item
|
||||||
|
|
||||||
return {
|
|
||||||
ticket_ids: ticket_ids,
|
|
||||||
tickets_count: tickets_count,
|
|
||||||
overview: overview_selected_raw,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# get tickets for overview
|
|
||||||
data[:start_page] ||= 1
|
|
||||||
query_condition, bind_condition = Ticket.selector2sql(overview_selected.condition, data[:current_user])
|
|
||||||
tickets = Ticket.where( access_condition )
|
|
||||||
.where( query_condition, *bind_condition )
|
|
||||||
.order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )
|
|
||||||
|
|
||||||
tickets_count = Ticket.where( access_condition ).where( query_condition, *bind_condition ).count()
|
|
||||||
|
|
||||||
{
|
|
||||||
tickets: tickets,
|
|
||||||
tickets_count: tickets_count,
|
|
||||||
overview: overview_selected_raw,
|
|
||||||
}
|
}
|
||||||
|
list
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,7 @@ returns:
|
||||||
state_type_id: Ticket::StateType.where( name: %w(closed) )
|
state_type_id: Ticket::StateType.where( name: %w(closed) )
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
fail "Unknown category '#{category}'"
|
raise "Unknown category '#{category}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
|
@ -44,7 +44,7 @@ dedicated:
|
||||||
read_timeout: 16,
|
read_timeout: 16,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
fail "Can't load translations from #{url}: #{result.error}" if !result.success?
|
raise "Can't load translations from #{url}: #{result.error}" if !result.success?
|
||||||
|
|
||||||
translations = Translation.where(locale: locale).all
|
translations = Translation.where(locale: locale).all
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
|
@ -120,7 +120,7 @@ push translations to online
|
||||||
read_timeout: 16,
|
read_timeout: 16,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
fail "Can't push translations to #{url}: #{result.error}" if !result.success?
|
raise "Can't push translations to #{url}: #{result.error}" if !result.success?
|
||||||
|
|
||||||
# set new translator_key if given
|
# set new translator_key if given
|
||||||
if result.data['translator_key']
|
if result.data['translator_key']
|
||||||
|
|
|
@ -21,6 +21,11 @@ store device for user
|
||||||
|
|
||||||
def self.add(user_agent, ip, user_id, fingerprint, type)
|
def self.add(user_agent, ip, user_id, fingerprint, type)
|
||||||
|
|
||||||
|
# since gem browser 2 is not handling nil for user_agent, set it to ''
|
||||||
|
if user_agent.nil?
|
||||||
|
user_agent = ''
|
||||||
|
end
|
||||||
|
|
||||||
# get location info
|
# get location info
|
||||||
location_details = Service::GeoIp.location(ip)
|
location_details = Service::GeoIp.location(ip)
|
||||||
location = 'unknown'
|
location = 'unknown'
|
||||||
|
@ -49,7 +54,7 @@ store device for user
|
||||||
end
|
end
|
||||||
|
|
||||||
# get browser details
|
# get browser details
|
||||||
browser = Browser.new(ua: user_agent, accept_language: 'en-us')
|
browser = Browser.new(user_agent, accept_language: 'en-us')
|
||||||
browser = {
|
browser = {
|
||||||
plattform: browser.platform.to_s.camelize,
|
plattform: browser.platform.to_s.camelize,
|
||||||
name: browser.name,
|
name: browser.name,
|
||||||
|
@ -58,6 +63,9 @@ store device for user
|
||||||
}
|
}
|
||||||
|
|
||||||
# generate device name
|
# generate device name
|
||||||
|
if browser[:name] == 'Generic Browser'
|
||||||
|
browser[:name] = user_agent
|
||||||
|
end
|
||||||
name = ''
|
name = ''
|
||||||
if browser[:plattform] && browser[:plattform] != 'Other'
|
if browser[:plattform] && browser[:plattform] != 'Other'
|
||||||
name = browser[:plattform]
|
name = browser[:plattform]
|
||||||
|
|
|
@ -54,7 +54,7 @@ returns
|
||||||
adapter = adapter.constantize
|
adapter = adapter.constantize
|
||||||
|
|
||||||
if !adapter
|
if !adapter
|
||||||
fail "Can't load adapter '#{adapter_name}'"
|
raise "Can't load adapter '#{adapter_name}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
adapter
|
adapter
|
||||||
|
|
|
@ -32,7 +32,7 @@ returns
|
||||||
|
|
||||||
def self.data
|
def self.data
|
||||||
auto_wizard_file_location = file_location
|
auto_wizard_file_location = file_location
|
||||||
fail "So such file #{auto_wizard_file_location}" if !File.file?(auto_wizard_file_location)
|
raise "So such file #{auto_wizard_file_location}" if !File.file?(auto_wizard_file_location)
|
||||||
JSON.parse( File.read(auto_wizard_file_location) )
|
JSON.parse( File.read(auto_wizard_file_location) )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ class ExternalCredential::Facebook
|
||||||
state = rand(999_999_999_999).to_s
|
state = rand(999_999_999_999).to_s
|
||||||
{
|
{
|
||||||
request_token: state,
|
request_token: state,
|
||||||
|
#authorize_url: oauth.url_for_oauth_code(permissions: 'publish_pages, manage_pages, user_posts', state: state),
|
||||||
authorize_url: oauth.url_for_oauth_code(permissions: 'publish_pages, manage_pages', state: state),
|
authorize_url: oauth.url_for_oauth_code(permissions: 'publish_pages, manage_pages', state: state),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -30,7 +31,7 @@ class ExternalCredential::Facebook
|
||||||
def self.link_account(_request_token, params)
|
def self.link_account(_request_token, params)
|
||||||
# fail if request_token.params[:oauth_token] != params[:state]
|
# fail if request_token.params[:oauth_token] != params[:state]
|
||||||
external_credential = ExternalCredential.find_by(name: 'facebook')
|
external_credential = ExternalCredential.find_by(name: 'facebook')
|
||||||
fail 'No such account' if !external_credential
|
raise 'No such account' if !external_credential
|
||||||
oauth = Koala::Facebook::OAuth.new(
|
oauth = Koala::Facebook::OAuth.new(
|
||||||
external_credential.credentials['application_id'],
|
external_credential.credentials['application_id'],
|
||||||
external_credential.credentials['application_secret'],
|
external_credential.credentials['application_secret'],
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ExternalCredential::Twitter
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.link_account(request_token, params)
|
def self.link_account(request_token, params)
|
||||||
fail if request_token.params[:oauth_token] != params[:oauth_token]
|
raise if request_token.params[:oauth_token] != params[:oauth_token]
|
||||||
external_credential = ExternalCredential.find_by(name: 'twitter')
|
external_credential = ExternalCredential.find_by(name: 'twitter')
|
||||||
access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
|
access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
|
||||||
client = Twitter::REST::Client.new(
|
client = Twitter::REST::Client.new(
|
||||||
|
|
|
@ -309,7 +309,7 @@ result
|
||||||
Rails.logger.debug 'Create feed comment from article...'
|
Rails.logger.debug 'Create feed comment from article...'
|
||||||
post = @client.put_comment(article[:in_reply_to], article[:body])
|
post = @client.put_comment(article[:in_reply_to], article[:body])
|
||||||
else
|
else
|
||||||
fail "Can't handle unknown facebook article type '#{article[:type]}'."
|
raise "Can't handle unknown facebook article type '#{article[:type]}'."
|
||||||
end
|
end
|
||||||
Rails.logger.debug post.inspect
|
Rails.logger.debug post.inspect
|
||||||
@client.get_object(post['id'])
|
@client.get_object(post['id'])
|
||||||
|
|
|
@ -23,14 +23,14 @@ module Import::OTRS
|
||||||
def self.request_json(data, data_only = false)
|
def self.request_json(data, data_only = false)
|
||||||
response = post(data)
|
response = post(data)
|
||||||
if !response
|
if !response
|
||||||
fail "Can't connect to Zammad Migrator"
|
raise "Can't connect to Zammad Migrator"
|
||||||
end
|
end
|
||||||
if !response.success?
|
if !response.success?
|
||||||
fail "Can't connect to Zammad Migrator"
|
raise "Can't connect to Zammad Migrator"
|
||||||
end
|
end
|
||||||
result = json(response)
|
result = json(response)
|
||||||
if !result
|
if !result
|
||||||
fail 'Invalid response'
|
raise 'Invalid response'
|
||||||
end
|
end
|
||||||
if data_only
|
if data_only
|
||||||
result['Result']
|
result['Result']
|
||||||
|
@ -303,12 +303,12 @@ module Import::OTRS
|
||||||
|
|
||||||
# check if system is in import mode
|
# check if system is in import mode
|
||||||
if !Setting.get('import_mode')
|
if !Setting.get('import_mode')
|
||||||
fail 'System is not in import mode!'
|
raise 'System is not in import mode!'
|
||||||
end
|
end
|
||||||
|
|
||||||
result = request_json({})
|
result = request_json({})
|
||||||
if !result['Success']
|
if !result['Success']
|
||||||
fail 'API key not valid!'
|
raise 'API key not valid!'
|
||||||
end
|
end
|
||||||
|
|
||||||
# set settings
|
# set settings
|
||||||
|
@ -495,7 +495,7 @@ module Import::OTRS
|
||||||
|
|
||||||
# check if system is in import mode
|
# check if system is in import mode
|
||||||
if !Setting.get('import_mode')
|
if !Setting.get('import_mode')
|
||||||
fail 'System is not in import mode!'
|
raise 'System is not in import mode!'
|
||||||
end
|
end
|
||||||
|
|
||||||
# create states
|
# create states
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Import::Zendesk
|
||||||
|
|
||||||
# check if system is in import mode
|
# check if system is in import mode
|
||||||
if !Setting.get('import_mode')
|
if !Setting.get('import_mode')
|
||||||
fail 'System is not in import mode!'
|
raise 'System is not in import mode!'
|
||||||
end
|
end
|
||||||
|
|
||||||
initialize_client
|
initialize_client
|
||||||
|
|
|
@ -215,7 +215,7 @@ returns
|
||||||
if force
|
if force
|
||||||
total = references_total(object_name, object_id_to_merge)
|
total = references_total(object_name, object_id_to_merge)
|
||||||
if total > 1000
|
if total > 1000
|
||||||
fail "Can't merge object because object has more then 1000 (#{total}) references, please contact your system administrator."
|
raise "Can't merge object because object has more then 1000 (#{total}) references, please contact your system administrator."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -314,17 +314,18 @@ returns
|
||||||
template_body = ''
|
template_body = ''
|
||||||
locale = data[:locale] || 'en'
|
locale = data[:locale] || 'en'
|
||||||
template = data[:template]
|
template = data[:template]
|
||||||
location = "app/views/mailer/#{template}/#{locale}.html.erb"
|
root = Rails.root
|
||||||
|
location = "#{root}/app/views/mailer/#{template}/#{locale}.html.erb"
|
||||||
|
|
||||||
# as fallback, use 2 char locale
|
# as fallback, use 2 char locale
|
||||||
if !File.exist?(location)
|
if !File.exist?(location)
|
||||||
locale = locale[0, 2]
|
locale = locale[0, 2]
|
||||||
location = "app/views/mailer/#{template}/#{locale}.html.erb"
|
location = "#{root}/app/views/mailer/#{template}/#{locale}.html.erb"
|
||||||
end
|
end
|
||||||
|
|
||||||
# as fallback, use en
|
# as fallback, use en
|
||||||
if !File.exist?(location)
|
if !File.exist?(location)
|
||||||
location = "app/views/mailer/#{template}/en.html.erb"
|
location = "#{root}/app/views/mailer/#{template}/en.html.erb"
|
||||||
end
|
end
|
||||||
|
|
||||||
File.open(location, 'r:UTF-8').each do |line|
|
File.open(location, 'r:UTF-8').each do |line|
|
||||||
|
@ -340,7 +341,7 @@ returns
|
||||||
|
|
||||||
if !data[:raw]
|
if !data[:raw]
|
||||||
application_template = nil
|
application_template = nil
|
||||||
File.open('app/views/mailer/application.html.erb', 'r:UTF-8') do |file|
|
File.open("#{root}/app/views/mailer/application.html.erb", 'r:UTF-8') do |file|
|
||||||
application_template = file.read
|
application_template = file.read
|
||||||
end
|
end
|
||||||
data[:objects][:message] = message_body
|
data[:objects][:message] = message_body
|
||||||
|
|
|
@ -98,9 +98,9 @@ class Report::Base
|
||||||
).count
|
).count
|
||||||
end
|
end
|
||||||
|
|
||||||
fail "UNKOWN params (#{params.inspect})!"
|
raise "UNKOWN params (#{params.inspect})!"
|
||||||
end
|
end
|
||||||
fail "UNKOWN :type (#{params[:type]})!"
|
raise "UNKOWN :type (#{params[:type]})!"
|
||||||
end
|
end
|
||||||
|
|
||||||
# :object
|
# :object
|
||||||
|
@ -219,7 +219,7 @@ class Report::Base
|
||||||
ticket_ids: ticket_ids,
|
ticket_ids: ticket_ids,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
fail "UNKOWN :type (#{data[:type]})!"
|
raise "UNKOWN :type (#{data[:type]})!"
|
||||||
end
|
end
|
||||||
|
|
||||||
# :type
|
# :type
|
||||||
|
|
|
@ -56,16 +56,16 @@ returns
|
||||||
(1..stop_interval).each {|_counter|
|
(1..stop_interval).each {|_counter|
|
||||||
match = false
|
match = false
|
||||||
if !result_es
|
if !result_es
|
||||||
fail "Invalid es result #{result_es.inspect}"
|
raise "Invalid es result #{result_es.inspect}"
|
||||||
end
|
end
|
||||||
if !result_es['aggregations']
|
if !result_es['aggregations']
|
||||||
fail "Invalid es result, no aggregations #{result_es.inspect}"
|
raise "Invalid es result, no aggregations #{result_es.inspect}"
|
||||||
end
|
end
|
||||||
if !result_es['aggregations']['time_buckets']
|
if !result_es['aggregations']['time_buckets']
|
||||||
fail "Invalid es result, no time_buckets #{result_es.inspect}"
|
raise "Invalid es result, no time_buckets #{result_es.inspect}"
|
||||||
end
|
end
|
||||||
if !result_es['aggregations']['time_buckets']['buckets']
|
if !result_es['aggregations']['time_buckets']['buckets']
|
||||||
fail "Invalid es result, no buckets #{result_es.inspect}"
|
raise "Invalid es result, no buckets #{result_es.inspect}"
|
||||||
end
|
end
|
||||||
result_es['aggregations']['time_buckets']['buckets'].each {|item|
|
result_es['aggregations']['time_buckets']['buckets'].each {|item|
|
||||||
if params[:interval] == 'minute'
|
if params[:interval] == 'minute'
|
||||||
|
|
|
@ -160,6 +160,6 @@ returns
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
fail "Unknown selector params '#{selector.inspect}'"
|
raise "Unknown selector params '#{selector.inspect}'"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Rss
|
||||||
Rails.logger.info "fetch rss... #{url}"
|
Rails.logger.info "fetch rss... #{url}"
|
||||||
response = UserAgent.request(url)
|
response = UserAgent.request(url)
|
||||||
if !response.success?
|
if !response.success?
|
||||||
fail "Can't fetch '#{url}', http code: #{response.code}"
|
raise "Can't fetch '#{url}', http code: #{response.code}"
|
||||||
end
|
end
|
||||||
rss = SimpleRSS.parse response.body
|
rss = SimpleRSS.parse response.body
|
||||||
items = []
|
items = []
|
||||||
|
|
|
@ -59,7 +59,7 @@ create/update/delete index
|
||||||
)
|
)
|
||||||
Rails.logger.info "# #{response.code}"
|
Rails.logger.info "# #{response.code}"
|
||||||
return true if response.success?
|
return true if response.success?
|
||||||
fail response.inspect
|
raise response.inspect
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -91,7 +91,7 @@ add new object to search index
|
||||||
)
|
)
|
||||||
Rails.logger.info "# #{response.code}"
|
Rails.logger.info "# #{response.code}"
|
||||||
return true if response.success?
|
return true if response.success?
|
||||||
fail response.inspect
|
raise response.inspect
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -270,7 +270,7 @@ get count of tickets and tickets which match on selector
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.selectors(index = nil, selectors = nil, limit = 10, current_user = nil, aggs_interval = nil)
|
def self.selectors(index = nil, selectors = nil, limit = 10, current_user = nil, aggs_interval = nil)
|
||||||
fail 'no selectors given' if !selectors
|
raise 'no selectors given' if !selectors
|
||||||
|
|
||||||
url = build_url()
|
url = build_url()
|
||||||
return if !url
|
return if !url
|
||||||
|
@ -303,7 +303,7 @@ get count of tickets and tickets which match on selector
|
||||||
|
|
||||||
Rails.logger.info "# #{response.code}"
|
Rails.logger.info "# #{response.code}"
|
||||||
if !response.success?
|
if !response.success?
|
||||||
fail "ERROR: #{response.inspect}"
|
raise "ERROR: #{response.inspect}"
|
||||||
end
|
end
|
||||||
Rails.logger.debug response.data.to_json
|
Rails.logger.debug response.data.to_json
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ get count of tickets and tickets which match on selector
|
||||||
elsif data['operator'] == 'contains not'
|
elsif data['operator'] == 'contains not'
|
||||||
query_must_not.push t
|
query_must_not.push t
|
||||||
else
|
else
|
||||||
fail "unknown operator '#{data['operator']}'"
|
raise "unknown operator '#{data['operator']}'"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Service::GeoCalendar::Zammad
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if !response.success? && response.code.to_s !~ /^40.$/
|
if !response.success? && response.code.to_s !~ /^40.$/
|
||||||
fail "ERROR: #{response.code}/#{response.body}"
|
raise "ERROR: #{response.code}/#{response.body}"
|
||||||
end
|
end
|
||||||
|
|
||||||
data = response.data
|
data = response.data
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Service::GeoIp::Zammad
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if !response.success? && response.code.to_s !~ /^40.$/
|
if !response.success? && response.code.to_s !~ /^40.$/
|
||||||
fail "ERROR: #{response.code}/#{response.body}"
|
raise "ERROR: #{response.code}/#{response.body}"
|
||||||
end
|
end
|
||||||
|
|
||||||
data = response.data
|
data = response.data
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
class Sessions::Backend::ActivityStream
|
class Sessions::Backend::ActivityStream
|
||||||
|
|
||||||
def initialize( user, client = nil, client_id = nil, ttl = 30 )
|
def initialize(user, asset_lookup, client = nil, client_id = nil, ttl = 25)
|
||||||
@user = user
|
@user = user
|
||||||
@client = client
|
@client = client
|
||||||
@client_id = client_id
|
@client_id = client_id
|
||||||
@ttl = ttl
|
@ttl = ttl
|
||||||
@last_change = nil
|
@asset_lookup = asset_lookup
|
||||||
|
@last_change = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load
|
||||||
|
|
||||||
# get whole collection
|
# get whole collection
|
||||||
activity_stream = @user.activity_stream( 25 )
|
activity_stream = @user.activity_stream(25)
|
||||||
if activity_stream && !activity_stream.first
|
if activity_stream && !activity_stream.first
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -25,7 +26,7 @@ class Sessions::Backend::ActivityStream
|
||||||
@last_change = activity_stream.first['created_at']
|
@last_change = activity_stream.first['created_at']
|
||||||
end
|
end
|
||||||
|
|
||||||
@user.activity_stream( 25, true )
|
@user.activity_stream(25, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_key
|
def client_key
|
||||||
|
@ -35,11 +36,11 @@ class Sessions::Backend::ActivityStream
|
||||||
def push
|
def push
|
||||||
|
|
||||||
# check timeout
|
# check timeout
|
||||||
timeout = Sessions::CacheIn.get( client_key )
|
timeout = Sessions::CacheIn.get(client_key)
|
||||||
return if timeout
|
return if timeout
|
||||||
|
|
||||||
# set new timeout
|
# set new timeout
|
||||||
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
|
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
|
||||||
|
|
||||||
data = load
|
data = load
|
||||||
|
|
||||||
|
|
23
lib/sessions/backend/base.rb
Normal file
23
lib/sessions/backend/base.rb
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
class Sessions::Backend::Base
|
||||||
|
def initialize(user, asset_lookup, client, client_id, ttl = 30)
|
||||||
|
@user = user
|
||||||
|
@client = client
|
||||||
|
@client_id = client_id
|
||||||
|
@ttl = ttl
|
||||||
|
@asset_lookup = asset_lookup
|
||||||
|
@last_change = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def asset_needed?(record)
|
||||||
|
class_name = record.class.to_s
|
||||||
|
if !@asset_lookup || !@asset_lookup[class_name] || !@asset_lookup[class_name][record.id] || @asset_lookup[class_name][record.id] < record.updated_at
|
||||||
|
if !@asset_lookup[class_name]
|
||||||
|
@asset_lookup[class_name] = {}
|
||||||
|
end
|
||||||
|
@asset_lookup[class_name][record.id] = record.updated_at
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,11 +1,12 @@
|
||||||
class Sessions::Backend::Collections
|
class Sessions::Backend::Collections < Sessions::Backend::Base
|
||||||
|
|
||||||
def initialize( user, client, client_id, ttl = 10 )
|
def initialize(user, asset_lookup, client, client_id, ttl = 10)
|
||||||
@user = user
|
@user = user
|
||||||
@client = client
|
@client = client
|
||||||
@client_id = client_id
|
@client_id = client_id
|
||||||
@ttl = ttl
|
@ttl = ttl
|
||||||
@backends = backend
|
@asset_lookup = asset_lookup
|
||||||
|
@backends = backend
|
||||||
end
|
end
|
||||||
|
|
||||||
def push
|
def push
|
||||||
|
@ -28,14 +29,14 @@ class Sessions::Backend::Collections
|
||||||
|
|
||||||
# load collections to deliver from external files
|
# load collections to deliver from external files
|
||||||
dir = File.expand_path('../../../../', __FILE__)
|
dir = File.expand_path('../../../../', __FILE__)
|
||||||
files = Dir.glob( "#{dir}/lib/sessions/backend/collections/*.rb" )
|
files = Dir.glob("#{dir}/lib/sessions/backend/collections/*.rb")
|
||||||
files.each { |file|
|
files.each { |file|
|
||||||
file.gsub!("#{dir}/lib/", '')
|
file.gsub!("#{dir}/lib/", '')
|
||||||
file.gsub!(/\.rb$/, '')
|
file.gsub!(/\.rb$/, '')
|
||||||
next if file.classify == 'Sessions::Backend::Collections::Base'
|
next if file.classify == 'Sessions::Backend::Collections::Base'
|
||||||
#puts "LOAD #{file.classify}---"
|
#puts "LOAD #{file.classify}---"
|
||||||
#next if file == ''
|
#next if file == ''
|
||||||
backend = file.classify.constantize.new(@user, @client, @client_id, @ttl)
|
backend = file.classify.constantize.new(@user, @asset_lookup, @client, @client_id, @ttl)
|
||||||
if backend
|
if backend
|
||||||
backends.push backend
|
backends.push backend
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
class Sessions::Backend::Collections::Base
|
class Sessions::Backend::Collections::Base < Sessions::Backend::Base
|
||||||
class << self; attr_accessor :model, :roles, :not_roles end
|
class << self; attr_accessor :model, :roles, :not_roles end
|
||||||
|
|
||||||
def initialize( user, client, client_id, ttl )
|
def initialize(user, asset_lookup, client, client_id, ttl)
|
||||||
@user = user
|
@user = user
|
||||||
@client = client
|
@client = client
|
||||||
@client_id = client_id
|
@client_id = client_id
|
||||||
@ttl = ttl
|
@ttl = ttl
|
||||||
@last_change = nil
|
@asset_lookup = asset_lookup
|
||||||
|
@last_change = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load
|
||||||
|
@ -42,11 +43,11 @@ class Sessions::Backend::Collections::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
# check timeout
|
# check timeout
|
||||||
timeout = Sessions::CacheIn.get( client_key )
|
timeout = Sessions::CacheIn.get(client_key)
|
||||||
return if timeout
|
return if timeout
|
||||||
|
|
||||||
# set new timeout
|
# set new timeout
|
||||||
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
|
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
|
||||||
|
|
||||||
# check if update has been done
|
# check if update has been done
|
||||||
last_change = self.class.model.constantize.latest_change
|
last_change = self.class.model.constantize.latest_change
|
||||||
|
@ -67,6 +68,7 @@ class Sessions::Backend::Collections::Base
|
||||||
# collect assets
|
# collect assets
|
||||||
assets = {}
|
assets = {}
|
||||||
items.each {|item|
|
items.each {|item|
|
||||||
|
next if !asset_needed?(item)
|
||||||
assets = item.assets(assets)
|
assets = item.assets(assets)
|
||||||
}
|
}
|
||||||
if !@client
|
if !@client
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Sessions::Backend::Collections::Organization < Sessions::Backend::Collecti
|
||||||
if !@user.role?('Customer')
|
if !@user.role?('Customer')
|
||||||
all = Organization.all
|
all = Organization.all
|
||||||
elsif @user.organization_id
|
elsif @user.organization_id
|
||||||
all = Organization.where( id: @user.organization_id )
|
all = Organization.where(id: @user.organization_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
all
|
all
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
require 'rss'
|
require 'rss'
|
||||||
|
|
||||||
class Sessions::Backend::Rss
|
class Sessions::Backend::Rss < Sessions::Backend::Base
|
||||||
|
|
||||||
def initialize( user, client, client_id, ttl = 30 )
|
|
||||||
@user = user
|
|
||||||
@client = client
|
|
||||||
@ttl = ttl
|
|
||||||
@client_id = client_id
|
|
||||||
end
|
|
||||||
|
|
||||||
def collection_key
|
def collection_key
|
||||||
"rss::load::#{self.class}::#{@user.id}"
|
"rss::load::#{self.class}::#{@user.id}"
|
||||||
|
@ -16,14 +9,14 @@ class Sessions::Backend::Rss
|
||||||
def load
|
def load
|
||||||
|
|
||||||
# check timeout
|
# check timeout
|
||||||
cache = Sessions::CacheIn.get( collection_key )
|
cache = Sessions::CacheIn.get(collection_key)
|
||||||
return cache if cache
|
return cache if cache
|
||||||
|
|
||||||
url = 'http://www.heise.de/newsticker/heise-atom.xml'
|
url = 'http://www.heise.de/newsticker/heise-atom.xml'
|
||||||
rss_items = Rss.fetch( url, 8 )
|
rss_items = Rss.fetch(url, 8)
|
||||||
|
|
||||||
# set new timeout
|
# set new timeout
|
||||||
Sessions::CacheIn.set( collection_key, rss_items, { expires_in: 1.hour } )
|
Sessions::CacheIn.set(collection_key, rss_items, { expires_in: 1.hour })
|
||||||
|
|
||||||
rss_items
|
rss_items
|
||||||
end
|
end
|
||||||
|
@ -35,11 +28,11 @@ class Sessions::Backend::Rss
|
||||||
def push
|
def push
|
||||||
|
|
||||||
# check timeout
|
# check timeout
|
||||||
timeout = Sessions::CacheIn.get( client_key )
|
timeout = Sessions::CacheIn.get(client_key)
|
||||||
return if timeout
|
return if timeout
|
||||||
|
|
||||||
# set new timeout
|
# set new timeout
|
||||||
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
|
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
|
||||||
|
|
||||||
data = load
|
data = load
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
class Sessions::Backend::TicketCreate
|
class Sessions::Backend::TicketCreate < Sessions::Backend::Base
|
||||||
def initialize( user, client = nil, client_id = nil, ttl = 30 )
|
|
||||||
@user = user
|
|
||||||
@client = client
|
|
||||||
@client_id = client_id
|
|
||||||
@ttl = ttl
|
|
||||||
@last_change = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def load
|
def load
|
||||||
|
|
||||||
|
@ -33,11 +26,11 @@ class Sessions::Backend::TicketCreate
|
||||||
def push
|
def push
|
||||||
|
|
||||||
# check timeout
|
# check timeout
|
||||||
timeout = Sessions::CacheIn.get( client_key )
|
timeout = Sessions::CacheIn.get(client_key)
|
||||||
return if timeout
|
return if timeout
|
||||||
|
|
||||||
# set new timeout
|
# set new timeout
|
||||||
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
|
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
|
||||||
|
|
||||||
data = load
|
data = load
|
||||||
|
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
class Sessions::Backend::TicketOverviewIndex
|
|
||||||
def initialize( user, client = nil, client_id = nil, ttl = 5 )
|
|
||||||
@user = user
|
|
||||||
@client = client
|
|
||||||
@client_id = client_id
|
|
||||||
@ttl = ttl
|
|
||||||
@last_change = nil
|
|
||||||
@last_ticket_change = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def load
|
|
||||||
|
|
||||||
# get whole collection
|
|
||||||
overview = Ticket::Overviews.list(
|
|
||||||
current_user: @user,
|
|
||||||
)
|
|
||||||
|
|
||||||
# no data exists
|
|
||||||
return if !overview
|
|
||||||
|
|
||||||
# no change exists
|
|
||||||
return if @last_change == overview
|
|
||||||
|
|
||||||
# remember last state
|
|
||||||
@last_change = overview
|
|
||||||
|
|
||||||
overview
|
|
||||||
end
|
|
||||||
|
|
||||||
def client_key
|
|
||||||
"as::load::#{self.class}::#{@user.id}::#{@client_id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def push
|
|
||||||
|
|
||||||
# check check interval
|
|
||||||
return if Sessions::CacheIn.get( client_key )
|
|
||||||
|
|
||||||
# reset check interval
|
|
||||||
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
|
|
||||||
|
|
||||||
# check if min one ticket has changed
|
|
||||||
last_ticket_change = Ticket.latest_change
|
|
||||||
return if last_ticket_change == @last_ticket_change
|
|
||||||
@last_ticket_change = last_ticket_change
|
|
||||||
|
|
||||||
# load current data
|
|
||||||
data = load
|
|
||||||
|
|
||||||
return if !data
|
|
||||||
|
|
||||||
if !@client
|
|
||||||
return {
|
|
||||||
event: 'ticket_overview_index',
|
|
||||||
data: data,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
@client.log "push overview_index for user #{@user.id}"
|
|
||||||
@client.send(
|
|
||||||
event: 'ticket_overview_index',
|
|
||||||
data: data,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -1,127 +1,129 @@
|
||||||
class Sessions::Backend::TicketOverviewList
|
class Sessions::Backend::TicketOverviewList < Sessions::Backend::Base
|
||||||
def initialize( user, client = nil, client_id = nil, ttl = 6 )
|
|
||||||
@user = user
|
def self.reset(user_id)
|
||||||
@client = client
|
key = "TicketOverviewPull::#{user_id}"
|
||||||
@client_id = client_id
|
Cache.write(key, { needed: true })
|
||||||
@ttl = ttl
|
end
|
||||||
@last_change = nil
|
|
||||||
@last_ticket_change = nil
|
def initialize(user, asset_lookup, client = nil, client_id = nil, ttl = 8)
|
||||||
|
@user = user
|
||||||
|
@client = client
|
||||||
|
@client_id = client_id
|
||||||
|
@ttl = ttl
|
||||||
|
@asset_lookup = asset_lookup
|
||||||
|
@last_change = nil
|
||||||
|
@last_overview = {}
|
||||||
|
@last_overview_change = nil
|
||||||
|
@last_ticket_change = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load
|
||||||
|
|
||||||
# get whole collection
|
# get whole collection
|
||||||
overviews = Ticket::Overviews.all(
|
index_and_lists = Ticket::Overviews.index(@user)
|
||||||
current_user: @user,
|
|
||||||
)
|
|
||||||
return if !overviews
|
|
||||||
result = []
|
|
||||||
overviews.each { |overview|
|
|
||||||
overview_data = Ticket::Overviews.list(
|
|
||||||
view: overview.link,
|
|
||||||
current_user: @user,
|
|
||||||
array: true,
|
|
||||||
)
|
|
||||||
data = { list: overview_data, index: overview }
|
|
||||||
result.push data
|
|
||||||
}
|
|
||||||
|
|
||||||
# no data exists
|
# no data exists
|
||||||
return if !result || result.empty?
|
return if !index_and_lists || index_and_lists.empty?
|
||||||
|
|
||||||
# no change exists
|
# no change exists
|
||||||
return if @last_change == result
|
return if @last_change == index_and_lists
|
||||||
|
|
||||||
# remember last state
|
# remember last state
|
||||||
@last_change = result
|
@last_change = index_and_lists
|
||||||
|
|
||||||
result
|
index_and_lists
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_key
|
def client_key
|
||||||
"as::load::#{self.class}::#{@user.id}::#{@client_id}"
|
"as::load::#{self.class}::#{@user.id}::#{@client_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def work_needed?
|
||||||
|
key = "TicketOverviewPull::#{@user.id}"
|
||||||
|
if Cache.get(key)
|
||||||
|
Cache.delete(key)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false if Sessions::CacheIn.get(client_key)
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def push
|
def push
|
||||||
|
|
||||||
# check interval
|
return if !work_needed?
|
||||||
return if Sessions::CacheIn.get( client_key )
|
|
||||||
|
|
||||||
# reset check interval
|
# reset check interval
|
||||||
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
|
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
|
||||||
|
|
||||||
# check if min one ticket has changed
|
# check if min one ticket or overview has changed
|
||||||
|
last_overview_change = Overview.latest_change
|
||||||
last_ticket_change = Ticket.latest_change
|
last_ticket_change = Ticket.latest_change
|
||||||
return if last_ticket_change == @last_ticket_change
|
return if last_ticket_change == @last_ticket_change && last_overview_change == @last_overview_change
|
||||||
|
@last_overview_change = last_overview_change
|
||||||
@last_ticket_change = last_ticket_change
|
@last_ticket_change = last_ticket_change
|
||||||
|
|
||||||
# load current data
|
# load current data
|
||||||
items = load
|
index_and_lists = load
|
||||||
return if !items
|
return if !index_and_lists
|
||||||
|
|
||||||
|
# push overview index
|
||||||
|
indexes = []
|
||||||
|
index_and_lists.each { |index|
|
||||||
|
assets = {}
|
||||||
|
overview = Overview.lookup(id: index[:overview][:id])
|
||||||
|
meta = {
|
||||||
|
name: overview.name,
|
||||||
|
prio: overview.prio,
|
||||||
|
link: overview.link,
|
||||||
|
count: index[:count],
|
||||||
|
}
|
||||||
|
indexes.push meta
|
||||||
|
}
|
||||||
|
if @client
|
||||||
|
@client.log "push overview_index for user #{@user.id}"
|
||||||
|
@client.send(
|
||||||
|
event: 'ticket_overview_index',
|
||||||
|
data: indexes,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
# push overviews
|
# push overviews
|
||||||
results = []
|
results = []
|
||||||
items.each { |item|
|
index_and_lists.each { |index|
|
||||||
|
|
||||||
overview_data = item[:list]
|
# do not deliver unchanged lists
|
||||||
|
next if @last_overview[index[:overview][:id]] == index
|
||||||
|
@last_overview[index[:overview][:id]] = index
|
||||||
|
|
||||||
assets = {}
|
assets = {}
|
||||||
overview_data[:ticket_ids].each {|ticket_id|
|
overview = Overview.lookup(id: index[:overview][:id])
|
||||||
ticket = Ticket.find( ticket_id )
|
if asset_needed?(overview)
|
||||||
|
assets = overview.assets(assets)
|
||||||
|
end
|
||||||
|
index[:tickets].each {|ticket_meta|
|
||||||
|
ticket = Ticket.lookup(id: ticket_meta[:id])
|
||||||
|
next if !asset_needed?(ticket)
|
||||||
assets = ticket.assets(assets)
|
assets = ticket.assets(assets)
|
||||||
}
|
}
|
||||||
|
|
||||||
# get groups
|
|
||||||
group_ids = []
|
|
||||||
Group.where(active: true).each { |group|
|
|
||||||
group_ids.push group.id
|
|
||||||
}
|
|
||||||
agents = {}
|
|
||||||
User.of_role('Agent').each { |user|
|
|
||||||
agents[ user.id ] = 1
|
|
||||||
}
|
|
||||||
users = {}
|
|
||||||
groups_users = {}
|
|
||||||
groups_users[''] = []
|
|
||||||
group_ids.each {|group_id|
|
|
||||||
groups_users[ group_id ] = []
|
|
||||||
Group.find(group_id).users.each {|user|
|
|
||||||
next if !agents[ user.id ]
|
|
||||||
groups_users[ group_id ].push user.id
|
|
||||||
if !users[user.id]
|
|
||||||
users[user.id] = User.find(user.id)
|
|
||||||
assets = users[user.id].assets(assets)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !@client
|
if !@client
|
||||||
result = {
|
result = {
|
||||||
event: 'navupdate_ticket_overview',
|
event: 'ticket_overview_list',
|
||||||
data: item[:index],
|
data: index,
|
||||||
}
|
}
|
||||||
results.push result
|
results.push result
|
||||||
else
|
else
|
||||||
|
|
||||||
@client.log "push overview_list for user #{@user.id}"
|
@client.log "push overview_list #{overview.link} for user #{@user.id}"
|
||||||
|
|
||||||
# send update to browser
|
# send update to browser
|
||||||
@client.send(
|
@client.send(
|
||||||
|
event: 'loadAssets',
|
||||||
data: assets,
|
data: assets,
|
||||||
event: 'loadAssets'
|
|
||||||
)
|
)
|
||||||
@client.send(
|
@client.send(
|
||||||
data: {
|
event: 'ticket_overview_list',
|
||||||
view: item[:index].link.to_s,
|
data: index,
|
||||||
overview: overview_data[:overview],
|
|
||||||
ticket_ids: overview_data[:ticket_ids],
|
|
||||||
tickets_count: overview_data[:tickets_count],
|
|
||||||
bulk: {
|
|
||||||
group_id__owner_id: groups_users,
|
|
||||||
owner_id: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
event: 'ticket_overview_rebuild',
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Sessions::CacheIn
|
||||||
@@expires_in_ttl = {}
|
@@expires_in_ttl = {}
|
||||||
# rubocop:enable Style/ClassVars
|
# rubocop:enable Style/ClassVars
|
||||||
|
|
||||||
def self.delete( key )
|
def self.delete(key)
|
||||||
@@data.delete( key )
|
@@data.delete(key)
|
||||||
@@data_time.delete( key )
|
@@data_time.delete(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.set( key, value, params = {} )
|
def self.set(key, value, params = {})
|
||||||
if params[:expires_in]
|
if params[:expires_in]
|
||||||
@@expires_in[key] = Time.zone.now + params[:expires_in]
|
@@expires_in[key] = Time.zone.now + params[:expires_in]
|
||||||
@@expires_in_ttl[key] = params[:expires_in]
|
@@expires_in_ttl[key] = params[:expires_in]
|
||||||
|
@ -21,7 +21,7 @@ module Sessions::CacheIn
|
||||||
@@data_time[ key ] = Time.zone.now
|
@@data_time[ key ] = Time.zone.now
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.expired( key, params = {} )
|
def self.expired(key, params = {})
|
||||||
|
|
||||||
# expire if value never was set
|
# expire if value never was set
|
||||||
return true if !@@data.include? key
|
return true if !@@data.include? key
|
||||||
|
@ -47,8 +47,8 @@ module Sessions::CacheIn
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get( key, params = {} )
|
def self.get(key, params = {})
|
||||||
return if expired( key, params )
|
return if expired( key, params)
|
||||||
@@data[ key ]
|
@@data[ key ]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class Sessions::Client
|
class Sessions::Client
|
||||||
|
|
||||||
def initialize( client_id )
|
def initialize(client_id)
|
||||||
@client_id = client_id
|
@client_id = client_id
|
||||||
log '---client start ws connection---'
|
log '---client start ws connection---'
|
||||||
fetch
|
fetch
|
||||||
|
@ -10,7 +10,6 @@ class Sessions::Client
|
||||||
def fetch
|
def fetch
|
||||||
|
|
||||||
backends = [
|
backends = [
|
||||||
'Sessions::Backend::TicketOverviewIndex',
|
|
||||||
'Sessions::Backend::TicketOverviewList',
|
'Sessions::Backend::TicketOverviewList',
|
||||||
'Sessions::Backend::Collections',
|
'Sessions::Backend::Collections',
|
||||||
'Sessions::Backend::Rss',
|
'Sessions::Backend::Rss',
|
||||||
|
@ -18,22 +17,24 @@ class Sessions::Client
|
||||||
'Sessions::Backend::TicketCreate',
|
'Sessions::Backend::TicketCreate',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
asset_lookup = {}
|
||||||
backend_pool = []
|
backend_pool = []
|
||||||
user_id_last_run = nil
|
user_id_last_run = nil
|
||||||
loop_count = 0
|
loop_count = 0
|
||||||
loop do
|
loop do
|
||||||
|
|
||||||
# get connection user
|
# get connection user
|
||||||
session_data = Sessions.get( @client_id )
|
session_data = Sessions.get(@client_id)
|
||||||
return if !session_data
|
return if !session_data
|
||||||
return if !session_data[:user]
|
return if !session_data[:user]
|
||||||
return if !session_data[:user]['id']
|
return if !session_data[:user]['id']
|
||||||
user = User.lookup( id: session_data[:user]['id'] )
|
user = User.lookup(id: session_data[:user]['id'])
|
||||||
return if !user
|
return if !user
|
||||||
|
|
||||||
# init new backends
|
# init new backends
|
||||||
if user_id_last_run != user.id
|
if user_id_last_run != user.id
|
||||||
user_id_last_run = user.id
|
user_id_last_run = user.id
|
||||||
|
asset_lookup = {}
|
||||||
|
|
||||||
# release old objects
|
# release old objects
|
||||||
backend_pool.collect! {
|
backend_pool.collect! {
|
||||||
|
@ -43,7 +44,7 @@ class Sessions::Client
|
||||||
# create new pool
|
# create new pool
|
||||||
backend_pool = []
|
backend_pool = []
|
||||||
backends.each {|backend|
|
backends.each {|backend|
|
||||||
item = backend.constantize.new(user, self, @client_id)
|
item = backend.constantize.new(user, asset_lookup, self, @client_id)
|
||||||
backend_pool.push item
|
backend_pool.push item
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -66,11 +67,11 @@ class Sessions::Client
|
||||||
end
|
end
|
||||||
|
|
||||||
# send update to browser
|
# send update to browser
|
||||||
def send( data )
|
def send(data)
|
||||||
Sessions.send( @client_id, data )
|
Sessions.send(@client_id, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def log( msg )
|
def log(msg)
|
||||||
Rails.logger.debug "client(#{@client_id}) #{msg}"
|
Rails.logger.debug "client(#{@client_id}) #{msg}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,6 +25,30 @@ class Sessions::Event::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def valid_session?
|
||||||
|
if !@session
|
||||||
|
error = {
|
||||||
|
event: 'error',
|
||||||
|
data: {
|
||||||
|
state: 'no_session',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
Sessions.send(@client_id, error)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if !@session['id']
|
||||||
|
error = {
|
||||||
|
event: 'error',
|
||||||
|
data: {
|
||||||
|
state: 'no_session_user_id',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
Sessions.send(@client_id, error)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def log(level, data, client_id = nil)
|
def log(level, data, client_id = nil)
|
||||||
if !@options[:v]
|
if !@options[:v]
|
||||||
return if level == 'debug'
|
return if level == 'debug'
|
||||||
|
|
8
lib/sessions/event/ticket_overview_index.rb
Normal file
8
lib/sessions/event/ticket_overview_index.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class Sessions::Event::TicketOverviewIndex < Sessions::Event::Base
|
||||||
|
|
||||||
|
def run
|
||||||
|
return if !valid_session?
|
||||||
|
Sessions::Backend::TicketOverviewList.reset(@session['id'])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
8
lib/sessions/event/ticket_overview_list.rb
Normal file
8
lib/sessions/event/ticket_overview_list.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class Sessions::Event::TicketOverviewList < Sessions::Event::Base
|
||||||
|
|
||||||
|
def run
|
||||||
|
return if !valid_session?
|
||||||
|
Sessions::Backend::TicketOverviewList.reset(@session['id'])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -20,7 +20,7 @@ returns
|
||||||
data[:content] = Base64.decode64($2)
|
data[:content] = Base64.decode64($2)
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
fail "Unable to parse data url: #{data_url.substr(0, 100)}"
|
raise "Unable to parse data url: #{data_url.substr(0, 100)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -67,7 +67,7 @@ returns
|
||||||
if list && list[0]
|
if list && list[0]
|
||||||
return Store.find( list[0] )
|
return Store.find( list[0] )
|
||||||
end
|
end
|
||||||
fail 'No such raw logo!'
|
raise 'No such raw logo!'
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace :test do
|
||||||
end
|
end
|
||||||
Dir.glob('test/browser/*_test.rb').sort.each { |r|
|
Dir.glob('test/browser/*_test.rb').sort.each { |r|
|
||||||
sh "#{args.opts} ruby -Itest #{r}" do |ok, res|
|
sh "#{args.opts} ruby -Itest #{r}" do |ok, res|
|
||||||
fail 'Failed test. ' + res.inspect if !ok
|
raise 'Failed test. ' + res.inspect if !ok
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
puts 'All browser tests, elapsed: ' + (Time.zone.now - start).to_s + ' seconds'
|
puts 'All browser tests, elapsed: ' + (Time.zone.now - start).to_s + ' seconds'
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TweetBase
|
||||||
Rails.logger.debug tweet.user.inspect
|
Rails.logger.debug tweet.user.inspect
|
||||||
return tweet.user
|
return tweet.user
|
||||||
else
|
else
|
||||||
fail "Unknown tweet type '#{tweet.class}'"
|
raise "Unknown tweet type '#{tweet.class}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -100,6 +100,7 @@ class TweetBase
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_ticket(tweet, user, group_id, channel)
|
def to_ticket(tweet, user, group_id, channel)
|
||||||
|
UserInfo.current_user_id = user.id
|
||||||
|
|
||||||
Rails.logger.debug 'Create ticket from tweet...'
|
Rails.logger.debug 'Create ticket from tweet...'
|
||||||
Rails.logger.debug tweet.inspect
|
Rails.logger.debug tweet.inspect
|
||||||
|
@ -119,8 +120,6 @@ class TweetBase
|
||||||
return ticket if ticket
|
return ticket if ticket
|
||||||
end
|
end
|
||||||
|
|
||||||
UserInfo.current_user_id = user.id
|
|
||||||
|
|
||||||
# prepare title
|
# prepare title
|
||||||
title = tweet.text
|
title = tweet.text
|
||||||
if title.length > 80
|
if title.length > 80
|
||||||
|
@ -177,7 +176,7 @@ class TweetBase
|
||||||
end
|
end
|
||||||
in_reply_to = tweet.in_reply_to_status_id
|
in_reply_to = tweet.in_reply_to_status_id
|
||||||
else
|
else
|
||||||
fail "Unknown tweet type '#{tweet.class}'"
|
raise "Unknown tweet type '#{tweet.class}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
UserInfo.current_user_id = user.id
|
UserInfo.current_user_id = user.id
|
||||||
|
@ -233,7 +232,7 @@ class TweetBase
|
||||||
end
|
end
|
||||||
to_article(tweet, user, ticket)
|
to_article(tweet, user, ticket)
|
||||||
else
|
else
|
||||||
fail "Unknown tweet type '#{tweet.class}'"
|
raise "Unknown tweet type '#{tweet.class}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket events
|
||||||
|
@ -269,7 +268,7 @@ class TweetBase
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
fail "Can't handle unknown twitter article type '#{article[:type]}'."
|
raise "Can't handle unknown twitter article type '#{article[:type]}'."
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails.logger.debug tweet.inspect
|
Rails.logger.debug tweet.inspect
|
||||||
|
|
|
@ -322,7 +322,7 @@ returns
|
||||||
code: response.code,
|
code: response.code,
|
||||||
)
|
)
|
||||||
when Net::HTTPRedirection
|
when Net::HTTPRedirection
|
||||||
fail 'Too many redirections for the original URL, halting.' if count <= 0
|
raise 'Too many redirections for the original URL, halting.' if count <= 0
|
||||||
url = response['location']
|
url = response['location']
|
||||||
return get(url, params, options, count - 1)
|
return get(url, params, options, count - 1)
|
||||||
when Net::HTTPOK
|
when Net::HTTPOK
|
||||||
|
@ -351,7 +351,7 @@ returns
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
fail "Unable to process http call '#{response.inspect}'"
|
raise "Unable to process http call '#{response.inspect}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ftp(uri, options)
|
def self.ftp(uri, options)
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
z-index: 999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal:before {
|
.modal:before {
|
||||||
|
|
|
@ -6,7 +6,7 @@ EXIT=$4 || 0
|
||||||
|
|
||||||
script/scheduler.rb stop
|
script/scheduler.rb stop
|
||||||
script/websocket-server.rb stop
|
script/websocket-server.rb stop
|
||||||
kill $(cat tmp/pids/puma.pid)
|
kill $(cat tmp/pids/server.pid)
|
||||||
|
|
||||||
rake db:drop
|
rake db:drop
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ if [ "$LEVEL" == '1' ]; then
|
||||||
rm test/browser/agent_organization_profile_test.rb
|
rm test/browser/agent_organization_profile_test.rb
|
||||||
rm test/browser/agent_ticket_*.rb
|
rm test/browser/agent_ticket_*.rb
|
||||||
rm test/browser/chat_test.rb
|
rm test/browser/chat_test.rb
|
||||||
|
rm test/browser/first_steps_test.rb
|
||||||
rm test/browser/keyboard_shortcuts_test.rb
|
rm test/browser/keyboard_shortcuts_test.rb
|
||||||
rm test/browser/prefereces_test.rb
|
rm test/browser/prefereces_test.rb
|
||||||
rm test/browser/setting_test.rb
|
rm test/browser/setting_test.rb
|
||||||
|
@ -25,6 +26,7 @@ elif [ "$LEVEL" == '2' ]; then
|
||||||
rm test/browser/auth_test.rb
|
rm test/browser/auth_test.rb
|
||||||
rm test/browser/chat_test.rb
|
rm test/browser/chat_test.rb
|
||||||
rm test/browser/customer_ticket_create_test.rb
|
rm test/browser/customer_ticket_create_test.rb
|
||||||
|
rm test/browser/first_steps_test.rb
|
||||||
rm test/browser/form_test.rb
|
rm test/browser/form_test.rb
|
||||||
rm test/browser/keyboard_shortcuts_test.rb
|
rm test/browser/keyboard_shortcuts_test.rb
|
||||||
rm test/browser/maintenance_*.rb
|
rm test/browser/maintenance_*.rb
|
||||||
|
|
|
@ -10,6 +10,12 @@ rails r "Setting.set('websocket_port', '$WS_PORT')"
|
||||||
rails r "Setting.set('fqdn', '$IP:$BROWSER_PORT')"
|
rails r "Setting.set('fqdn', '$IP:$BROWSER_PORT')"
|
||||||
rails r "Setting.set('chat_agent_idle_timeout', '45')"
|
rails r "Setting.set('chat_agent_idle_timeout', '45')"
|
||||||
|
|
||||||
pumactl start --pidfile tmp/pids/puma.pid -d -p $APP_PORT -e $RAILS_ENV
|
echo "env used for script/build/test_startup.sh $1 $2 $3"
|
||||||
|
echo "export RAILS_ENV=$RAILS_ENV"
|
||||||
|
echo "export IP=$IP"
|
||||||
|
echo "export BROWSER_PORT=$BROWSER_PORT"
|
||||||
|
|
||||||
|
#rails s puma -d --pid tmp/pids/server.pid --bind 0.0.0.0 --port $APP_PORT
|
||||||
|
pumactl start --pidfile tmp/pids/server.pid -d -p $APP_PORT -e $RAILS_ENV
|
||||||
script/websocket-server.rb start -d -p $WS_PORT
|
script/websocket-server.rb start -d -p $WS_PORT
|
||||||
script/scheduler.rb start
|
script/scheduler.rb start
|
||||||
|
|
141
test/browser/first_steps_test.rb
Normal file
141
test/browser/first_steps_test.rb
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
require 'browser_test_helper'
|
||||||
|
|
||||||
|
class FirstStepsTest < TestCase
|
||||||
|
|
||||||
|
def test_basic
|
||||||
|
agent = "bob.smith_#{rand(99_999_999)}"
|
||||||
|
customer = "customer.smith_#{rand(99_999_999)}"
|
||||||
|
|
||||||
|
@browser = browser_instance
|
||||||
|
login(
|
||||||
|
username: 'master@example.com',
|
||||||
|
password: 'test',
|
||||||
|
url: browser_url,
|
||||||
|
)
|
||||||
|
tasks_close_all()
|
||||||
|
click(
|
||||||
|
css: '.active.content .tab[data-area="first-steps-widgets"]',
|
||||||
|
)
|
||||||
|
watch_for(
|
||||||
|
css: '.active.content',
|
||||||
|
value: 'Configuration',
|
||||||
|
)
|
||||||
|
|
||||||
|
# invite agent
|
||||||
|
click(
|
||||||
|
css: '.active.content .js-inviteAgent',
|
||||||
|
)
|
||||||
|
sleep 4
|
||||||
|
set(
|
||||||
|
css: '.modal [name="firstname"]',
|
||||||
|
value: 'Bob',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
css: '.modal [name="lastname"]',
|
||||||
|
value: 'Smith',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
css: '.modal [name="email"]',
|
||||||
|
value: "#{agent}@example.com",
|
||||||
|
)
|
||||||
|
check(
|
||||||
|
css: '.modal [name="group_ids"]',
|
||||||
|
)
|
||||||
|
click(
|
||||||
|
css: '.modal button.btn.btn--primary',
|
||||||
|
fast: true,
|
||||||
|
)
|
||||||
|
watch_for(
|
||||||
|
css: 'body div.modal',
|
||||||
|
value: 'Sending',
|
||||||
|
)
|
||||||
|
watch_for_disappear(
|
||||||
|
css: 'body div.modal',
|
||||||
|
value: 'Sending',
|
||||||
|
)
|
||||||
|
|
||||||
|
# invite customer
|
||||||
|
click(
|
||||||
|
css: '.active.content .js-inviteCustomer',
|
||||||
|
)
|
||||||
|
sleep 4
|
||||||
|
set(
|
||||||
|
css: '.modal [name="firstname"]',
|
||||||
|
value: 'Client',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
css: '.modal [name="lastname"]',
|
||||||
|
value: 'Smith',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
css: '.modal [name="email"]',
|
||||||
|
value: "#{customer}@example.com",
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
css: '.modal [data-name="note"]',
|
||||||
|
value: 'some note',
|
||||||
|
)
|
||||||
|
click(
|
||||||
|
css: '.modal button.btn.btn--primary',
|
||||||
|
fast: true,
|
||||||
|
)
|
||||||
|
watch_for(
|
||||||
|
css: 'body div.modal',
|
||||||
|
value: 'Sending',
|
||||||
|
)
|
||||||
|
watch_for_disappear(
|
||||||
|
css: 'body div.modal',
|
||||||
|
value: 'Sending',
|
||||||
|
)
|
||||||
|
|
||||||
|
# test ticket
|
||||||
|
click(
|
||||||
|
css: '.active.content .js-testTicket',
|
||||||
|
fast: true,
|
||||||
|
)
|
||||||
|
watch_for(
|
||||||
|
css: 'body div.modal',
|
||||||
|
value: 'A Test Ticket has been created',
|
||||||
|
)
|
||||||
|
click(
|
||||||
|
css: '.modal .modal-body',
|
||||||
|
fast: true,
|
||||||
|
)
|
||||||
|
watch_for_disappear(
|
||||||
|
css: 'body div.modal',
|
||||||
|
value: 'Test Ticket',
|
||||||
|
)
|
||||||
|
execute(
|
||||||
|
js: '$(".active.content .sidebar").show()',
|
||||||
|
)
|
||||||
|
watch_for(
|
||||||
|
css: '.active.content .js-activityContent',
|
||||||
|
value: 'Nicole Braun created Article for Test Ticket!',
|
||||||
|
timeout: 35,
|
||||||
|
)
|
||||||
|
|
||||||
|
# check update
|
||||||
|
click(
|
||||||
|
css: '.active.content a[href="#channels/form"]',
|
||||||
|
)
|
||||||
|
sleep 2
|
||||||
|
switch(
|
||||||
|
css: '#content .js-formSetting',
|
||||||
|
type: 'on',
|
||||||
|
)
|
||||||
|
sleep 2
|
||||||
|
click(
|
||||||
|
css: '#navigation a[href="#dashboard"]',
|
||||||
|
)
|
||||||
|
hit = false
|
||||||
|
(1..38).each {
|
||||||
|
next if !@browser.find_elements(css: '.active.content a[href="#channels/form"].todo.is-done')[0]
|
||||||
|
hit = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
assert(hit)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -153,7 +153,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
login = instance.find_elements(css: '.user-menu .user a')[0].attribute('title')
|
login = instance.find_elements(css: '.user-menu .user a')[0].attribute('title')
|
||||||
if login != params[:username]
|
if login != params[:username]
|
||||||
screenshot(browser: instance, comment: 'auto wizard login failed')
|
screenshot(browser: instance, comment: 'auto wizard login failed')
|
||||||
fail 'auto wizard login failed'
|
raise 'auto wizard login failed'
|
||||||
end
|
end
|
||||||
assert(true, 'auto wizard login ok')
|
assert(true, 'auto wizard login ok')
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
screenshot(browser: instance, comment: 'login_failed')
|
screenshot(browser: instance, comment: 'login_failed')
|
||||||
fail 'No login box found'
|
raise 'No login box found'
|
||||||
end
|
end
|
||||||
|
|
||||||
screenshot(browser: instance, comment: 'login')
|
screenshot(browser: instance, comment: 'login')
|
||||||
|
@ -186,7 +186,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
login = instance.find_elements(css: '.user-menu .user a')[0].attribute('title')
|
login = instance.find_elements(css: '.user-menu .user a')[0].attribute('title')
|
||||||
if login != params[:username]
|
if login != params[:username]
|
||||||
screenshot(browser: instance, comment: 'login_failed')
|
screenshot(browser: instance, comment: 'login_failed')
|
||||||
fail 'login failed'
|
raise 'login failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
clues_close(
|
clues_close(
|
||||||
|
@ -226,7 +226,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'logout_failed')
|
screenshot(browser: instance, comment: 'logout_failed')
|
||||||
fail 'no login box found, seems logout was not successfully!'
|
raise 'no login box found, seems logout was not successfully!'
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -247,7 +247,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
clues = instance.find_elements(css: '.js-modal--clue .js-close')[0]
|
clues = instance.find_elements(css: '.js-modal--clue .js-close')[0]
|
||||||
if !params[:optional] && !clues
|
if !params[:optional] && !clues
|
||||||
screenshot(browser: instance, comment: 'no_clues')
|
screenshot(browser: instance, comment: 'no_clues')
|
||||||
fail 'Unable to closes clues, no clues found!'
|
raise 'Unable to closes clues, no clues found!'
|
||||||
end
|
end
|
||||||
return if !clues
|
return if !clues
|
||||||
instance.execute_script("$('.js-modal--clue .js-close').click()")
|
instance.execute_script("$('.js-modal--clue .js-close').click()")
|
||||||
|
@ -296,7 +296,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
current_url = instance.current_url
|
current_url = instance.current_url
|
||||||
if current_url !~ /#{Regexp.quote(params[:url])}/
|
if current_url !~ /#{Regexp.quote(params[:url])}/
|
||||||
screenshot(browser: instance, comment: 'location_check_failed')
|
screenshot(browser: instance, comment: 'location_check_failed')
|
||||||
fail "url #{current_url} is not matching #{params[:url]}"
|
raise "url #{current_url} is not matching #{params[:url]}"
|
||||||
end
|
end
|
||||||
assert(true, "url #{current_url} is matching #{params[:url]}")
|
assert(true, "url #{current_url} is matching #{params[:url]}")
|
||||||
end
|
end
|
||||||
|
@ -412,7 +412,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
if params[:js]
|
if params[:js]
|
||||||
return instance.execute_script(params[:js])
|
return instance.execute_script(params[:js])
|
||||||
end
|
end
|
||||||
fail "Invalid execute params #{params.inspect}"
|
raise "Invalid execute params #{params.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -431,7 +431,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
if !instance.find_elements(css: params[:css])[0]
|
if !instance.find_elements(css: params[:css])[0]
|
||||||
screenshot(browser: instance, comment: 'exists_failed')
|
screenshot(browser: instance, comment: 'exists_failed')
|
||||||
fail "#{params[:css]} dosn't exist, but should"
|
raise "#{params[:css]} dosn't exist, but should"
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -452,7 +452,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
if instance.find_elements(css: params[:css])[0]
|
if instance.find_elements(css: params[:css])[0]
|
||||||
screenshot(browser: instance, comment: 'exists_not_failed')
|
screenshot(browser: instance, comment: 'exists_not_failed')
|
||||||
fail "#{params[:css]} exists but should not"
|
raise "#{params[:css]} exists but should not"
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -637,7 +637,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
if params[:slow]
|
if params[:slow]
|
||||||
sleep 2
|
sleep 2
|
||||||
else
|
else
|
||||||
sleep 0.6
|
sleep 0.3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -673,10 +673,10 @@ class TestCase < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
if params[:should_not_match]
|
if params[:should_not_match]
|
||||||
if success
|
if success
|
||||||
fail "should not match '#{params[:value]}' in select list, but is matching"
|
raise "should not match '#{params[:value]}' in select list, but is matching"
|
||||||
end
|
end
|
||||||
elsif !success
|
elsif !success
|
||||||
fail "not matching '#{params[:value]}' in select list"
|
raise "not matching '#{params[:value]}' in select list"
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -719,10 +719,10 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
if match
|
if match
|
||||||
if params[:should_not_match]
|
if params[:should_not_match]
|
||||||
fail "matching '#{params[:value]}' in content '#{text}' but should not!"
|
raise "matching '#{params[:value]}' in content '#{text}' but should not!"
|
||||||
end
|
end
|
||||||
elsif !params[:should_not_match]
|
elsif !params[:should_not_match]
|
||||||
fail "not matching '#{params[:value]}' in content '#{text}' but should!"
|
raise "not matching '#{params[:value]}' in content '#{text}' but should!"
|
||||||
end
|
end
|
||||||
sleep 0.8
|
sleep 0.8
|
||||||
match
|
match
|
||||||
|
@ -769,7 +769,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
instance.find_elements(css: ".content.active .js-secondaryActionLabel[data-type=#{params[:type]}]")[0].click
|
instance.find_elements(css: ".content.active .js-secondaryActionLabel[data-type=#{params[:type]}]")[0].click
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
fail "Unknown params for task_type: #{params.inspect}"
|
raise "Unknown params for task_type: #{params.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -809,23 +809,23 @@ class TestCase < Test::Unit::TestCase
|
||||||
if params.key?(:value ) && cookie[:value].to_s =~ /#{params[:value]}/i
|
if params.key?(:value ) && cookie[:value].to_s =~ /#{params[:value]}/i
|
||||||
assert(true, "matching value '#{params[:value]}' in cookie '#{cookie}'")
|
assert(true, "matching value '#{params[:value]}' in cookie '#{cookie}'")
|
||||||
else
|
else
|
||||||
fail "not matching value '#{params[:value]}' in cookie '#{cookie}'"
|
raise "not matching value '#{params[:value]}' in cookie '#{cookie}'"
|
||||||
end
|
end
|
||||||
if params.key?(:expires) && cookie[:expires].to_s =~ /#{params[:expires]}/i
|
if params.key?(:expires) && cookie[:expires].to_s =~ /#{params[:expires]}/i
|
||||||
assert(true, "matching expires '#{params[:expires].inspect}' in cookie '#{cookie}'")
|
assert(true, "matching expires '#{params[:expires].inspect}' in cookie '#{cookie}'")
|
||||||
else
|
else
|
||||||
fail "not matching expires '#{params[:expires]}' in cookie '#{cookie}'"
|
raise "not matching expires '#{params[:expires]}' in cookie '#{cookie}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
return if !params[:should_not_exist]
|
return if !params[:should_not_exist]
|
||||||
|
|
||||||
fail "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies}'"
|
raise "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies}'"
|
||||||
}
|
}
|
||||||
if params[:should_not_exist]
|
if params[:should_not_exist]
|
||||||
assert(true, "cookie with name '#{params[:name]}' is not existing")
|
assert(true, "cookie with name '#{params[:name]}' is not existing")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
fail "not matching name '#{params[:name]}' in cookie '#{cookies}'"
|
raise "not matching name '#{params[:name]}' in cookie '#{cookies}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -847,7 +847,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
if title =~ /#{params[:value]}/i
|
if title =~ /#{params[:value]}/i
|
||||||
assert(true, "matching '#{params[:value]}' in title '#{title}'")
|
assert(true, "matching '#{params[:value]}' in title '#{title}'")
|
||||||
else
|
else
|
||||||
fail "not matching '#{params[:value]}' in title '#{title}'"
|
raise "not matching '#{params[:value]}' in title '#{title}'"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -880,7 +880,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
if title =~ /#{data[:title]}/i
|
if title =~ /#{data[:title]}/i
|
||||||
assert(true, "matching '#{data[:title]}' in title '#{title}'")
|
assert(true, "matching '#{data[:title]}' in title '#{title}'")
|
||||||
else
|
else
|
||||||
fail "not matching '#{data[:title]}' in title '#{title}'"
|
raise "not matching '#{data[:title]}' in title '#{title}'"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts "tv #{params.inspect}"
|
puts "tv #{params.inspect}"
|
||||||
|
@ -899,16 +899,16 @@ class TestCase < Test::Unit::TestCase
|
||||||
if is_modified
|
if is_modified
|
||||||
assert(true, "task '#{data[:title]}' is modifed")
|
assert(true, "task '#{data[:title]}' is modifed")
|
||||||
elsif !exists
|
elsif !exists
|
||||||
fail "task '#{data[:title]}' not exists, should not modified"
|
raise "task '#{data[:title]}' not exists, should not modified"
|
||||||
else
|
else
|
||||||
fail "task '#{data[:title]}' is not modifed"
|
raise "task '#{data[:title]}' is not modifed"
|
||||||
end
|
end
|
||||||
elsif !is_modified
|
elsif !is_modified
|
||||||
assert(true, "task '#{data[:title]}' is modifed")
|
assert(true, "task '#{data[:title]}' is modifed")
|
||||||
elsif !exists
|
elsif !exists
|
||||||
fail "task '#{data[:title]}' not exists, should be not modified"
|
raise "task '#{data[:title]}' not exists, should be not modified"
|
||||||
else
|
else
|
||||||
fail "task '#{data[:title]}' is modifed, but should not"
|
raise "task '#{data[:title]}' is modifed, but should not"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
|
@ -943,7 +943,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
element = instance.find_elements(partial_link_text: data[:title])[0]
|
element = instance.find_elements(partial_link_text: data[:title])[0]
|
||||||
if !element
|
if !element
|
||||||
screenshot(browser: instance, comment: 'open_task_failed')
|
screenshot(browser: instance, comment: 'open_task_failed')
|
||||||
fail "no task with title '#{data[:title]}' found"
|
raise "no task with title '#{data[:title]}' found"
|
||||||
end
|
end
|
||||||
element.click
|
element.click
|
||||||
true
|
true
|
||||||
|
@ -971,7 +971,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
element = instance.find_elements(partial_link_text: data[:title])[0]
|
element = instance.find_elements(partial_link_text: data[:title])[0]
|
||||||
if !element
|
if !element
|
||||||
screenshot(browser: instance, comment: 'close_task_failed')
|
screenshot(browser: instance, comment: 'close_task_failed')
|
||||||
fail "no task with title '#{data[:title]}' found"
|
raise "no task with title '#{data[:title]}' found"
|
||||||
end
|
end
|
||||||
|
|
||||||
instance.mouse.move_to(element)
|
instance.mouse.move_to(element)
|
||||||
|
@ -1058,7 +1058,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'watch_for_failed')
|
screenshot(browser: instance, comment: 'watch_for_failed')
|
||||||
fail "'#{params[:value]}' found in '#{text}'"
|
raise "'#{params[:value]}' found in '#{text}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -1116,7 +1116,7 @@ wait untill text in selector disabppears
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'disappear_failed')
|
screenshot(browser: instance, comment: 'disappear_failed')
|
||||||
fail "#{params[:css]}) still exsists"
|
raise "#{params[:css]}) still exsists"
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -1171,7 +1171,7 @@ wait untill text in selector disabppears
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
|
|
||||||
(1..100).each do
|
(1..100).each do
|
||||||
sleep 1
|
sleep 0.2
|
||||||
begin
|
begin
|
||||||
if instance.find_elements(css: '.navigation .tasks .task:first-child')[0]
|
if instance.find_elements(css: '.navigation .tasks .task:first-child')[0]
|
||||||
instance.mouse.move_to(instance.find_elements(css: '.navigation .tasks .task:first-child')[0])
|
instance.mouse.move_to(instance.find_elements(css: '.navigation .tasks .task:first-child')[0])
|
||||||
|
@ -1193,7 +1193,6 @@ wait untill text in selector disabppears
|
||||||
# try again
|
# try again
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sleep 1
|
|
||||||
assert(true, 'all tasks closed')
|
assert(true, 'all tasks closed')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1310,7 +1309,7 @@ wait untill text in selector disabppears
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'overview_create_failed')
|
screenshot(browser: instance, comment: 'overview_create_failed')
|
||||||
fail 'overview creation failed'
|
raise 'overview creation failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -1348,7 +1347,7 @@ wait untill text in selector disabppears
|
||||||
element = instance.find_elements(css: '.active .newTicket')[0]
|
element = instance.find_elements(css: '.active .newTicket')[0]
|
||||||
if !element
|
if !element
|
||||||
screenshot(browser: instance, comment: 'ticket_create_failed')
|
screenshot(browser: instance, comment: 'ticket_create_failed')
|
||||||
fail 'no ticket create screen found!'
|
raise 'no ticket create screen found!'
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
|
@ -1448,7 +1447,7 @@ wait untill text in selector disabppears
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'ticket_create_failed')
|
screenshot(browser: instance, comment: 'ticket_create_failed')
|
||||||
fail "ticket creation failed, can't get zoom url (current url is '#{instance.current_url}')"
|
raise "ticket creation failed, can't get zoom url (current url is '#{instance.current_url}')"
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -1604,7 +1603,7 @@ wait untill text in selector disabppears
|
||||||
if !found
|
if !found
|
||||||
screenshot(browser: instance, comment: 'ticket_update_discard_message_failed')
|
screenshot(browser: instance, comment: 'ticket_update_discard_message_failed')
|
||||||
|
|
||||||
fail 'no discard message found'
|
raise 'no discard message found'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1633,7 +1632,7 @@ wait untill text in selector disabppears
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'ticket_update_failed')
|
screenshot(browser: instance, comment: 'ticket_update_failed')
|
||||||
fail 'unable to update ticket'
|
raise 'unable to update ticket'
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -1662,7 +1661,7 @@ wait untill text in selector disabppears
|
||||||
if title =~ /#{data[:title]}/i
|
if title =~ /#{data[:title]}/i
|
||||||
assert(true, "matching '#{data[:title]}' in title '#{title}'")
|
assert(true, "matching '#{data[:title]}' in title '#{title}'")
|
||||||
else
|
else
|
||||||
fail "not matching '#{data[:title]}' in title '#{title}'"
|
raise "not matching '#{data[:title]}' in title '#{title}'"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1671,7 +1670,7 @@ wait untill text in selector disabppears
|
||||||
if body =~ /#{data[:body]}/i
|
if body =~ /#{data[:body]}/i
|
||||||
assert(true, "matching '#{data[:body]}' in body '#{body}'")
|
assert(true, "matching '#{data[:body]}' in body '#{body}'")
|
||||||
else
|
else
|
||||||
fail "not matching '#{data[:body]}' in body '#{body}'"
|
raise "not matching '#{data[:body]}' in body '#{body}'"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
|
@ -1710,7 +1709,7 @@ wait untill text in selector disabppears
|
||||||
number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text
|
number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text
|
||||||
if number !~ /#{params[:number]}/
|
if number !~ /#{params[:number]}/
|
||||||
screenshot(browser: instance, comment: 'ticket_open_by_overview_failed')
|
screenshot(browser: instance, comment: 'ticket_open_by_overview_failed')
|
||||||
fail "unable to search/find ticket #{params[:number]}!"
|
raise "unable to search/find ticket #{params[:number]}!"
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
assert(true, "ticket #{params[:number]} found")
|
assert(true, "ticket #{params[:number]} found")
|
||||||
|
@ -1744,7 +1743,7 @@ wait untill text in selector disabppears
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
text = instance.find_elements(css: '#global-search')[0].attribute('value')
|
text = instance.find_elements(css: '#global-search')[0].attribute('value')
|
||||||
if !text
|
if !text
|
||||||
fail '#global-search is not empty!'
|
raise '#global-search is not empty!'
|
||||||
end
|
end
|
||||||
|
|
||||||
# search by number again
|
# search by number again
|
||||||
|
@ -1760,7 +1759,7 @@ wait untill text in selector disabppears
|
||||||
number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text
|
number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text
|
||||||
if number !~ /#{params[:number]}/
|
if number !~ /#{params[:number]}/
|
||||||
screenshot(browser: instance, comment: 'ticket_open_by_search_failed')
|
screenshot(browser: instance, comment: 'ticket_open_by_search_failed')
|
||||||
fail "unable to search/find ticket #{params[:number]}!"
|
raise "unable to search/find ticket #{params[:number]}!"
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
true
|
true
|
||||||
|
@ -1794,7 +1793,7 @@ wait untill text in selector disabppears
|
||||||
title = instance.find_elements(css: '.active .ticketZoom-header .ticket-title-update')[0].text
|
title = instance.find_elements(css: '.active .ticketZoom-header .ticket-title-update')[0].text
|
||||||
if title !~ /#{params[:title]}/
|
if title !~ /#{params[:title]}/
|
||||||
screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
|
screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
|
||||||
fail "unable to search/find ticket #{params[:title]}!"
|
raise "unable to search/find ticket #{params[:title]}!"
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
true
|
true
|
||||||
|
@ -1872,7 +1871,7 @@ wait untill text in selector disabppears
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
text = instance.find_elements(css: '#global-search')[0].attribute('value')
|
text = instance.find_elements(css: '#global-search')[0].attribute('value')
|
||||||
if !text
|
if !text
|
||||||
fail '#global-search is not empty!'
|
raise '#global-search is not empty!'
|
||||||
end
|
end
|
||||||
element = instance.find_elements(css: '#global-search')[0]
|
element = instance.find_elements(css: '#global-search')[0]
|
||||||
element.click
|
element.click
|
||||||
|
@ -1884,7 +1883,7 @@ wait untill text in selector disabppears
|
||||||
name = instance.find_elements(css: '.active h1')[0].text
|
name = instance.find_elements(css: '.active h1')[0].text
|
||||||
if name !~ /#{params[:value]}/
|
if name !~ /#{params[:value]}/
|
||||||
screenshot(browser: instance, comment: 'organization_open_by_search_failed')
|
screenshot(browser: instance, comment: 'organization_open_by_search_failed')
|
||||||
fail "unable to search/find org #{params[:value]}!"
|
raise "unable to search/find org #{params[:value]}!"
|
||||||
end
|
end
|
||||||
assert(true, "org #{params[:value]} found")
|
assert(true, "org #{params[:value]} found")
|
||||||
sleep 2
|
sleep 2
|
||||||
|
@ -1916,7 +1915,7 @@ wait untill text in selector disabppears
|
||||||
name = instance.find_elements(css: '.active h1')[0].text
|
name = instance.find_elements(css: '.active h1')[0].text
|
||||||
if name !~ /#{params[:value]}/
|
if name !~ /#{params[:value]}/
|
||||||
screenshot(browser: instance, comment: 'user_open_by_search_failed')
|
screenshot(browser: instance, comment: 'user_open_by_search_failed')
|
||||||
fail "unable to search/find user #{params[:value]}!"
|
raise "unable to search/find user #{params[:value]}!"
|
||||||
end
|
end
|
||||||
assert(true, "user #{params[:term]} found")
|
assert(true, "user #{params[:term]} found")
|
||||||
sleep 2
|
sleep 2
|
||||||
|
@ -2025,7 +2024,7 @@ wait untill text in selector disabppears
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'sla_create_failed')
|
screenshot(browser: instance, comment: 'sla_create_failed')
|
||||||
fail 'sla creation failed'
|
raise 'sla creation failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -2074,7 +2073,7 @@ wait untill text in selector disabppears
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'text_module_create_failed')
|
screenshot(browser: instance, comment: 'text_module_create_failed')
|
||||||
fail 'text module creation failed'
|
raise 'text module creation failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -2121,7 +2120,7 @@ wait untill text in selector disabppears
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'signature_create_failed')
|
screenshot(browser: instance, comment: 'signature_create_failed')
|
||||||
fail 'signature creation failed'
|
raise 'signature creation failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -2195,7 +2194,7 @@ wait untill text in selector disabppears
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'group_create_failed')
|
screenshot(browser: instance, comment: 'group_create_failed')
|
||||||
fail 'group creation failed'
|
raise 'group creation failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
def quote(string)
|
def quote(string)
|
||||||
|
|
|
@ -5,11 +5,11 @@ class ElasticsearchTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# set config
|
# set config
|
||||||
if !ENV['ES_URL']
|
if !ENV['ES_URL']
|
||||||
fail "ERROR: Need ES_URL - hint ES_URL='http://172.0.0.1:9200'"
|
raise "ERROR: Need ES_URL - hint ES_URL='http://172.0.0.1:9200'"
|
||||||
end
|
end
|
||||||
Setting.set('es_url', ENV['ES_URL'])
|
Setting.set('es_url', ENV['ES_URL'])
|
||||||
if !ENV['ES_INDEX'] && !ENV['ES_INDEX_RAND']
|
if !ENV['ES_INDEX'] && !ENV['ES_INDEX_RAND']
|
||||||
fail "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
|
raise "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
|
||||||
end
|
end
|
||||||
if ENV['ES_INDEX_RAND']
|
if ENV['ES_INDEX_RAND']
|
||||||
ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}"
|
ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}"
|
||||||
|
|
|
@ -249,7 +249,7 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# realtest - test I
|
# realtest - test I
|
||||||
if !ENV['EMAILHELPER_MAILBOX_1']
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
||||||
fail "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
||||||
end
|
end
|
||||||
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
||||||
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
||||||
|
@ -401,7 +401,7 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# realtest - test I
|
# realtest - test I
|
||||||
if !ENV['EMAILHELPER_MAILBOX_1']
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
||||||
fail "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
||||||
end
|
end
|
||||||
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
||||||
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
||||||
|
@ -433,7 +433,7 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# realtest - test I, with imap
|
# realtest - test I, with imap
|
||||||
if !ENV['EMAILHELPER_MAILBOX_1']
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
||||||
fail "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
||||||
end
|
end
|
||||||
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
||||||
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
||||||
|
@ -448,7 +448,7 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# realtest - test II, gmail with only pop3
|
# realtest - test II, gmail with only pop3
|
||||||
if !ENV['EMAILHELPER_MAILBOX_2']
|
if !ENV['EMAILHELPER_MAILBOX_2']
|
||||||
fail "Need EMAILHELPER_MAILBOX_2 as ENV variable like export EMAILHELPER_MAILBOX_2='hansb36621@gmail.com:somepass'"
|
raise "Need EMAILHELPER_MAILBOX_2 as ENV variable like export EMAILHELPER_MAILBOX_2='hansb36621@gmail.com:somepass'"
|
||||||
end
|
end
|
||||||
mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0]
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0]
|
||||||
mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1]
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1]
|
||||||
|
@ -467,7 +467,7 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# realtest - test I, with imap
|
# realtest - test I, with imap
|
||||||
if !ENV['EMAILHELPER_MAILBOX_1']
|
if !ENV['EMAILHELPER_MAILBOX_1']
|
||||||
fail "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
|
||||||
end
|
end
|
||||||
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
|
||||||
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
|
||||||
|
@ -499,7 +499,7 @@ class EmailHelperTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# realtest - test II, gmail with pop3
|
# realtest - test II, gmail with pop3
|
||||||
if !ENV['EMAILHELPER_MAILBOX_2']
|
if !ENV['EMAILHELPER_MAILBOX_2']
|
||||||
fail "Need EMAILHELPER_MAILBOX_2 as ENV variable like export EMAILHELPER_MAILBOX_2='hansb36621@gmail.com:somepass'"
|
raise "Need EMAILHELPER_MAILBOX_2 as ENV variable like export EMAILHELPER_MAILBOX_2='hansb36621@gmail.com:somepass'"
|
||||||
end
|
end
|
||||||
mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0]
|
mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0]
|
||||||
mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1]
|
mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1]
|
||||||
|
|
|
@ -6,28 +6,28 @@ class FacebookBrowserTest < TestCase
|
||||||
|
|
||||||
# app config
|
# app config
|
||||||
if !ENV['FACEBOOK_BT_APP_ID']
|
if !ENV['FACEBOOK_BT_APP_ID']
|
||||||
fail "ERROR: Need FACEBOOK_BT_APP_ID - hint FACEBOOK_BT_APP_ID='1234'"
|
raise "ERROR: Need FACEBOOK_BT_APP_ID - hint FACEBOOK_BT_APP_ID='1234'"
|
||||||
end
|
end
|
||||||
app_id = ENV['FACEBOOK_BT_APP_ID']
|
app_id = ENV['FACEBOOK_BT_APP_ID']
|
||||||
if !ENV['FACEBOOK_BT_APP_SECRET']
|
if !ENV['FACEBOOK_BT_APP_SECRET']
|
||||||
fail "ERROR: Need FACEBOOK_BT_APP_SECRET - hint FACEBOOK_BT_APP_SECRET='1234'"
|
raise "ERROR: Need FACEBOOK_BT_APP_SECRET - hint FACEBOOK_BT_APP_SECRET='1234'"
|
||||||
end
|
end
|
||||||
app_secret = ENV['FACEBOOK_BT_APP_SECRET']
|
app_secret = ENV['FACEBOOK_BT_APP_SECRET']
|
||||||
if !ENV['FACEBOOK_BT_USER_LOGIN']
|
if !ENV['FACEBOOK_BT_USER_LOGIN']
|
||||||
fail "ERROR: Need FACEBOOK_BT_USER_LOGIN - hint FACEBOOK_BT_USER_LOGIN='1234'"
|
raise "ERROR: Need FACEBOOK_BT_USER_LOGIN - hint FACEBOOK_BT_USER_LOGIN='1234'"
|
||||||
end
|
end
|
||||||
user_login = ENV['FACEBOOK_BT_USER_LOGIN']
|
user_login = ENV['FACEBOOK_BT_USER_LOGIN']
|
||||||
if !ENV['FACEBOOK_BT_USER_PW']
|
if !ENV['FACEBOOK_BT_USER_PW']
|
||||||
fail "ERROR: Need FACEBOOK_BT_USER_PW - hint FACEBOOK_BT_USER_PW='1234'"
|
raise "ERROR: Need FACEBOOK_BT_USER_PW - hint FACEBOOK_BT_USER_PW='1234'"
|
||||||
end
|
end
|
||||||
user_pw = ENV['FACEBOOK_BT_USER_PW']
|
user_pw = ENV['FACEBOOK_BT_USER_PW']
|
||||||
if !ENV['FACEBOOK_BT_PAGE_ID']
|
if !ENV['FACEBOOK_BT_PAGE_ID']
|
||||||
fail "ERROR: Need FACEBOOK_BT_PAGE_ID - hint FACEBOOK_BT_PAGE_ID='1234'"
|
raise "ERROR: Need FACEBOOK_BT_PAGE_ID - hint FACEBOOK_BT_PAGE_ID='1234'"
|
||||||
end
|
end
|
||||||
page_id = ENV['FACEBOOK_BT_PAGE_ID']
|
page_id = ENV['FACEBOOK_BT_PAGE_ID']
|
||||||
|
|
||||||
if !ENV['FACEBOOK_BT_CUSTOMER']
|
if !ENV['FACEBOOK_BT_CUSTOMER']
|
||||||
fail "ERROR: Need FACEBOOK_BT_CUSTOMER - hint FACEBOOK_BT_CUSTOMER='name:1234:access_token'"
|
raise "ERROR: Need FACEBOOK_BT_CUSTOMER - hint FACEBOOK_BT_CUSTOMER='name:1234:access_token'"
|
||||||
end
|
end
|
||||||
customer_name = ENV['FACEBOOK_BT_CUSTOMER'].split(':')[0]
|
customer_name = ENV['FACEBOOK_BT_CUSTOMER'].split(':')[0]
|
||||||
customer_id = ENV['FACEBOOK_BT_CUSTOMER'].split(':')[1]
|
customer_id = ENV['FACEBOOK_BT_CUSTOMER'].split(':')[1]
|
||||||
|
|
|
@ -16,21 +16,21 @@ class FacebookTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# account config
|
# account config
|
||||||
if !ENV['FACEBOOK_USER']
|
if !ENV['FACEBOOK_USER']
|
||||||
fail "ERROR: Need FACEBOOK_USER - hint FACEBOOK_USER='name:1234:access_token'"
|
raise "ERROR: Need FACEBOOK_USER - hint FACEBOOK_USER='name:1234:access_token'"
|
||||||
end
|
end
|
||||||
user_name = ENV['FACEBOOK_USER'].split(':')[0]
|
user_name = ENV['FACEBOOK_USER'].split(':')[0]
|
||||||
user_id = ENV['FACEBOOK_USER'].split(':')[1]
|
user_id = ENV['FACEBOOK_USER'].split(':')[1]
|
||||||
user_access_token = ENV['FACEBOOK_USER'].split(':')[2]
|
user_access_token = ENV['FACEBOOK_USER'].split(':')[2]
|
||||||
|
|
||||||
if !ENV['FACEBOOK_PAGE']
|
if !ENV['FACEBOOK_PAGE']
|
||||||
fail "ERROR: Need FACEBOOK_PAGE - hint FACEBOOK_PAGE='name:1234:access_token'"
|
raise "ERROR: Need FACEBOOK_PAGE - hint FACEBOOK_PAGE='name:1234:access_token'"
|
||||||
end
|
end
|
||||||
page_name = ENV['FACEBOOK_PAGE'].split(':')[0]
|
page_name = ENV['FACEBOOK_PAGE'].split(':')[0]
|
||||||
page_id = ENV['FACEBOOK_PAGE'].split(':')[1]
|
page_id = ENV['FACEBOOK_PAGE'].split(':')[1]
|
||||||
page_access_token = ENV['FACEBOOK_PAGE'].split(':')[2]
|
page_access_token = ENV['FACEBOOK_PAGE'].split(':')[2]
|
||||||
|
|
||||||
if !ENV['FACEBOOK_CUSTOMER']
|
if !ENV['FACEBOOK_CUSTOMER']
|
||||||
fail "ERROR: Need FACEBOOK_CUSTOMER - hint FACEBOOK_CUSTOMER='name:1234:access_token'"
|
raise "ERROR: Need FACEBOOK_CUSTOMER - hint FACEBOOK_CUSTOMER='name:1234:access_token'"
|
||||||
end
|
end
|
||||||
customer_name = ENV['FACEBOOK_CUSTOMER'].split(':')[0]
|
customer_name = ENV['FACEBOOK_CUSTOMER'].split(':')[0]
|
||||||
customer_id = ENV['FACEBOOK_CUSTOMER'].split(':')[1]
|
customer_id = ENV['FACEBOOK_CUSTOMER'].split(':')[1]
|
||||||
|
|
|
@ -5,10 +5,10 @@ class OtrsImportBrowserTest < TestCase
|
||||||
def test_import
|
def test_import
|
||||||
|
|
||||||
if !ENV['IMPORT_BT_OTRS_ENDPOINT']
|
if !ENV['IMPORT_BT_OTRS_ENDPOINT']
|
||||||
fail "ERROR: Need IMPORT_BT_OTRS_ENDPOINT - hint IMPORT_BT_OTRS_ENDPOINT='http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator'"
|
raise "ERROR: Need IMPORT_BT_OTRS_ENDPOINT - hint IMPORT_BT_OTRS_ENDPOINT='http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator'"
|
||||||
end
|
end
|
||||||
if !ENV['IMPORT_BT_OTRS_ENDPOINT_KEY']
|
if !ENV['IMPORT_BT_OTRS_ENDPOINT_KEY']
|
||||||
fail "ERROR: Need IMPORT_BT_OTRS_ENDPOINT_KEY - hint IMPORT_BT_OTRS_ENDPOINT_KEY='01234567899876543210'"
|
raise "ERROR: Need IMPORT_BT_OTRS_ENDPOINT_KEY - hint IMPORT_BT_OTRS_ENDPOINT_KEY='01234567899876543210'"
|
||||||
end
|
end
|
||||||
|
|
||||||
@browser = browser_instance
|
@browser = browser_instance
|
||||||
|
|
|
@ -4,10 +4,10 @@ require 'integration_test_helper'
|
||||||
class OtrsImportTest < ActiveSupport::TestCase
|
class OtrsImportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
if !ENV['IMPORT_OTRS_ENDPOINT']
|
if !ENV['IMPORT_OTRS_ENDPOINT']
|
||||||
fail "ERROR: Need IMPORT_OTRS_ENDPOINT - hint IMPORT_OTRS_ENDPOINT='http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator'"
|
raise "ERROR: Need IMPORT_OTRS_ENDPOINT - hint IMPORT_OTRS_ENDPOINT='http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator'"
|
||||||
end
|
end
|
||||||
if !ENV['IMPORT_OTRS_ENDPOINT_KEY']
|
if !ENV['IMPORT_OTRS_ENDPOINT_KEY']
|
||||||
fail "ERROR: Need IMPORT_OTRS_ENDPOINT_KEY - hint IMPORT_OTRS_ENDPOINT_KEY='01234567899876543210'"
|
raise "ERROR: Need IMPORT_OTRS_ENDPOINT_KEY - hint IMPORT_OTRS_ENDPOINT_KEY='01234567899876543210'"
|
||||||
end
|
end
|
||||||
|
|
||||||
Setting.set('import_otrs_endpoint', ENV['IMPORT_OTRS_ENDPOINT'])
|
Setting.set('import_otrs_endpoint', ENV['IMPORT_OTRS_ENDPOINT'])
|
||||||
|
|
|
@ -5,11 +5,11 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# set config
|
# set config
|
||||||
if !ENV['ES_URL']
|
if !ENV['ES_URL']
|
||||||
fail "ERROR: Need ES_URL - hint ES_URL='http://172.0.0.1:9200'"
|
raise "ERROR: Need ES_URL - hint ES_URL='http://172.0.0.1:9200'"
|
||||||
end
|
end
|
||||||
Setting.set('es_url', ENV['ES_URL'])
|
Setting.set('es_url', ENV['ES_URL'])
|
||||||
if !ENV['ES_INDEX'] && !ENV['ES_INDEX_RAND']
|
if !ENV['ES_INDEX'] && !ENV['ES_INDEX_RAND']
|
||||||
fail "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
|
raise "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
|
||||||
end
|
end
|
||||||
if ENV['ES_INDEX_RAND']
|
if ENV['ES_INDEX_RAND']
|
||||||
ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}"
|
ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}"
|
||||||
|
|
|
@ -6,31 +6,31 @@ class TwitterBrowserTest < TestCase
|
||||||
|
|
||||||
# app config
|
# app config
|
||||||
if !ENV['TWITTER_BT_CONSUMER_KEY']
|
if !ENV['TWITTER_BT_CONSUMER_KEY']
|
||||||
fail "ERROR: Need TWITTER_BT_CONSUMER_KEY - hint TWITTER_BT_CONSUMER_KEY='1234'"
|
raise "ERROR: Need TWITTER_BT_CONSUMER_KEY - hint TWITTER_BT_CONSUMER_KEY='1234'"
|
||||||
end
|
end
|
||||||
consumer_key = ENV['TWITTER_BT_CONSUMER_KEY']
|
consumer_key = ENV['TWITTER_BT_CONSUMER_KEY']
|
||||||
if !ENV['TWITTER_BT_CONSUMER_SECRET']
|
if !ENV['TWITTER_BT_CONSUMER_SECRET']
|
||||||
fail "ERROR: Need TWITTER_BT_CONSUMER_SECRET - hint TWITTER_BT_CONSUMER_SECRET='1234'"
|
raise "ERROR: Need TWITTER_BT_CONSUMER_SECRET - hint TWITTER_BT_CONSUMER_SECRET='1234'"
|
||||||
end
|
end
|
||||||
consumer_secret = ENV['TWITTER_BT_CONSUMER_SECRET']
|
consumer_secret = ENV['TWITTER_BT_CONSUMER_SECRET']
|
||||||
|
|
||||||
if !ENV['TWITTER_BT_USER_LOGIN']
|
if !ENV['TWITTER_BT_USER_LOGIN']
|
||||||
fail "ERROR: Need TWITTER_BT_USER_LOGIN - hint TWITTER_BT_USER_LOGIN='1234'"
|
raise "ERROR: Need TWITTER_BT_USER_LOGIN - hint TWITTER_BT_USER_LOGIN='1234'"
|
||||||
end
|
end
|
||||||
twitter_user_login = ENV['TWITTER_BT_USER_LOGIN']
|
twitter_user_login = ENV['TWITTER_BT_USER_LOGIN']
|
||||||
|
|
||||||
if !ENV['TWITTER_BT_USER_PW']
|
if !ENV['TWITTER_BT_USER_PW']
|
||||||
fail "ERROR: Need TWITTER_BT_USER_PW - hint TWITTER_BT_USER_PW='1234'"
|
raise "ERROR: Need TWITTER_BT_USER_PW - hint TWITTER_BT_USER_PW='1234'"
|
||||||
end
|
end
|
||||||
twitter_user_pw = ENV['TWITTER_BT_USER_PW']
|
twitter_user_pw = ENV['TWITTER_BT_USER_PW']
|
||||||
|
|
||||||
if !ENV['TWITTER_BT_CUSTOMER_TOKEN']
|
if !ENV['TWITTER_BT_CUSTOMER_TOKEN']
|
||||||
fail "ERROR: Need TWITTER_BT_CUSTOMER_TOKEN - hint TWITTER_BT_CUSTOMER_TOKEN='1234'"
|
raise "ERROR: Need TWITTER_BT_CUSTOMER_TOKEN - hint TWITTER_BT_CUSTOMER_TOKEN='1234'"
|
||||||
end
|
end
|
||||||
twitter_customer_token = ENV['TWITTER_BT_CUSTOMER_TOKEN']
|
twitter_customer_token = ENV['TWITTER_BT_CUSTOMER_TOKEN']
|
||||||
|
|
||||||
if !ENV['TWITTER_BT_CUSTOMER_TOKEN_SECRET']
|
if !ENV['TWITTER_BT_CUSTOMER_TOKEN_SECRET']
|
||||||
fail "ERROR: Need TWITTER_BT_CUSTOMER_TOKEN_SECRET - hint TWITTER_BT_CUSTOMER_TOKEN_SECRET='1234'"
|
raise "ERROR: Need TWITTER_BT_CUSTOMER_TOKEN_SECRET - hint TWITTER_BT_CUSTOMER_TOKEN_SECRET='1234'"
|
||||||
end
|
end
|
||||||
twitter_customer_token_secret = ENV['TWITTER_BT_CUSTOMER_TOKEN_SECRET']
|
twitter_customer_token_secret = ENV['TWITTER_BT_CUSTOMER_TOKEN_SECRET']
|
||||||
|
|
||||||
|
|
|
@ -17,23 +17,23 @@ class TwitterTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# app config
|
# app config
|
||||||
if !ENV['TWITTER_CONSUMER_KEY']
|
if !ENV['TWITTER_CONSUMER_KEY']
|
||||||
fail "ERROR: Need TWITTER_CONSUMER_KEY - hint TWITTER_CONSUMER_KEY='1234'"
|
raise "ERROR: Need TWITTER_CONSUMER_KEY - hint TWITTER_CONSUMER_KEY='1234'"
|
||||||
end
|
end
|
||||||
if !ENV['TWITTER_CONSUMER_SECRET']
|
if !ENV['TWITTER_CONSUMER_SECRET']
|
||||||
fail "ERROR: Need TWITTER_CONSUMER_SECRET - hint TWITTER_CONSUMER_SECRET='1234'"
|
raise "ERROR: Need TWITTER_CONSUMER_SECRET - hint TWITTER_CONSUMER_SECRET='1234'"
|
||||||
end
|
end
|
||||||
consumer_key = ENV['TWITTER_CONSUMER_KEY']
|
consumer_key = ENV['TWITTER_CONSUMER_KEY']
|
||||||
consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
|
consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
|
||||||
|
|
||||||
# armin_theo (is system and is following marion_bauer)
|
# armin_theo (is system and is following marion_bauer)
|
||||||
if !ENV['TWITTER_SYSTEM_LOGIN']
|
if !ENV['TWITTER_SYSTEM_LOGIN']
|
||||||
fail "ERROR: Need TWITTER_SYSTEM_LOGIN - hint TWITTER_SYSTEM_LOGIN='@system'"
|
raise "ERROR: Need TWITTER_SYSTEM_LOGIN - hint TWITTER_SYSTEM_LOGIN='@system'"
|
||||||
end
|
end
|
||||||
if !ENV['TWITTER_SYSTEM_TOKEN']
|
if !ENV['TWITTER_SYSTEM_TOKEN']
|
||||||
fail "ERROR: Need TWITTER_SYSTEM_TOKEN - hint TWITTER_SYSTEM_TOKEN='1234'"
|
raise "ERROR: Need TWITTER_SYSTEM_TOKEN - hint TWITTER_SYSTEM_TOKEN='1234'"
|
||||||
end
|
end
|
||||||
if !ENV['TWITTER_SYSTEM_TOKEN_SECRET']
|
if !ENV['TWITTER_SYSTEM_TOKEN_SECRET']
|
||||||
fail "ERROR: Need TWITTER_SYSTEM_TOKEN_SECRET - hint TWITTER_SYSTEM_TOKEN_SECRET='1234'"
|
raise "ERROR: Need TWITTER_SYSTEM_TOKEN_SECRET - hint TWITTER_SYSTEM_TOKEN_SECRET='1234'"
|
||||||
end
|
end
|
||||||
system_login = ENV['TWITTER_SYSTEM_LOGIN']
|
system_login = ENV['TWITTER_SYSTEM_LOGIN']
|
||||||
system_login_without_at = system_login[1, system_login.length]
|
system_login_without_at = system_login[1, system_login.length]
|
||||||
|
@ -42,13 +42,13 @@ class TwitterTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# me_bauer (is customer and is following armin_theo)
|
# me_bauer (is customer and is following armin_theo)
|
||||||
if !ENV['TWITTER_CUSTOMER_LOGIN']
|
if !ENV['TWITTER_CUSTOMER_LOGIN']
|
||||||
fail "ERROR: Need CUSTOMER_LOGIN - hint TWITTER_CUSTOMER_LOGIN='@customer'"
|
raise "ERROR: Need CUSTOMER_LOGIN - hint TWITTER_CUSTOMER_LOGIN='@customer'"
|
||||||
end
|
end
|
||||||
if !ENV['TWITTER_CUSTOMER_TOKEN']
|
if !ENV['TWITTER_CUSTOMER_TOKEN']
|
||||||
fail "ERROR: Need CUSTOMER_TOKEN - hint TWITTER_CUSTOMER_TOKEN='1234'"
|
raise "ERROR: Need CUSTOMER_TOKEN - hint TWITTER_CUSTOMER_TOKEN='1234'"
|
||||||
end
|
end
|
||||||
if !ENV['TWITTER_CUSTOMER_TOKEN_SECRET']
|
if !ENV['TWITTER_CUSTOMER_TOKEN_SECRET']
|
||||||
fail "ERROR: Need CUSTOMER_TOKEN_SECRET - hint TWITTER_CUSTOMER_TOKEN_SECRET='1234'"
|
raise "ERROR: Need CUSTOMER_TOKEN_SECRET - hint TWITTER_CUSTOMER_TOKEN_SECRET='1234'"
|
||||||
end
|
end
|
||||||
customer_login = ENV['TWITTER_CUSTOMER_LOGIN']
|
customer_login = ENV['TWITTER_CUSTOMER_LOGIN']
|
||||||
customer_token = ENV['TWITTER_CUSTOMER_TOKEN']
|
customer_token = ENV['TWITTER_CUSTOMER_TOKEN']
|
||||||
|
|
|
@ -5,13 +5,13 @@ class ZendeskImportBrowserTest < TestCase
|
||||||
def test_import
|
def test_import
|
||||||
|
|
||||||
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT']
|
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT']
|
||||||
fail "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT - hint IMPORT_BT_ZENDESK_ENDPOINT='https://example.zendesk.com/' (including trailing slash!)"
|
raise "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT - hint IMPORT_BT_ZENDESK_ENDPOINT='https://example.zendesk.com/' (including trailing slash!)"
|
||||||
end
|
end
|
||||||
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT_USERNAME']
|
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT_USERNAME']
|
||||||
fail "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT_USERNAME - hint IMPORT_BT_ZENDESK_ENDPOINT_USERNAME='your@email.com'"
|
raise "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT_USERNAME - hint IMPORT_BT_ZENDESK_ENDPOINT_USERNAME='your@email.com'"
|
||||||
end
|
end
|
||||||
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT_KEY']
|
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT_KEY']
|
||||||
fail "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT_KEY - hint IMPORT_BT_ZENDESK_ENDPOINT_KEY='XYZ3133723421111'"
|
raise "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT_KEY - hint IMPORT_BT_ZENDESK_ENDPOINT_KEY='XYZ3133723421111'"
|
||||||
end
|
end
|
||||||
|
|
||||||
@browser = browser_instance
|
@browser = browser_instance
|
||||||
|
|
|
@ -4,13 +4,13 @@ require 'integration_test_helper'
|
||||||
class ZendeskImportTest < ActiveSupport::TestCase
|
class ZendeskImportTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
if !ENV['IMPORT_ZENDESK_ENDPOINT']
|
if !ENV['IMPORT_ZENDESK_ENDPOINT']
|
||||||
fail "ERROR: Need IMPORT_ZENDESK_ENDPOINT - hint IMPORT_ZENDESK_ENDPOINT='https://example.zendesk.com/api/v2'"
|
raise "ERROR: Need IMPORT_ZENDESK_ENDPOINT - hint IMPORT_ZENDESK_ENDPOINT='https://example.zendesk.com/api/v2'"
|
||||||
end
|
end
|
||||||
if !ENV['IMPORT_ZENDESK_ENDPOINT_KEY']
|
if !ENV['IMPORT_ZENDESK_ENDPOINT_KEY']
|
||||||
fail "ERROR: Need IMPORT_ZENDESK_ENDPOINT_KEY - hint IMPORT_ZENDESK_ENDPOINT_KEY='01234567899876543210'"
|
raise "ERROR: Need IMPORT_ZENDESK_ENDPOINT_KEY - hint IMPORT_ZENDESK_ENDPOINT_KEY='01234567899876543210'"
|
||||||
end
|
end
|
||||||
if !ENV['IMPORT_ZENDESK_ENDPOINT_USERNAME']
|
if !ENV['IMPORT_ZENDESK_ENDPOINT_USERNAME']
|
||||||
fail "ERROR: Need IMPORT_ZENDESK_ENDPOINT_USERNAME - hint IMPORT_ZENDESK_ENDPOINT_USERNAME='bob.ross@happylittletrees.com'"
|
raise "ERROR: Need IMPORT_ZENDESK_ENDPOINT_USERNAME - hint IMPORT_ZENDESK_ENDPOINT_USERNAME='bob.ross@happylittletrees.com'"
|
||||||
end
|
end
|
||||||
|
|
||||||
Setting.set('import_zendesk_endpoint', ENV['IMPORT_ZENDESK_ENDPOINT'])
|
Setting.set('import_zendesk_endpoint', ENV['IMPORT_ZENDESK_ENDPOINT'])
|
||||||
|
|
|
@ -3,52 +3,52 @@ require 'test_helper'
|
||||||
|
|
||||||
class SessionBasicTest < ActiveSupport::TestCase
|
class SessionBasicTest < ActiveSupport::TestCase
|
||||||
test 'a cache' do
|
test 'a cache' do
|
||||||
Sessions::CacheIn.set( 'last_run_test', true, { expires_in: 2.seconds } )
|
Sessions::CacheIn.set('last_run_test', true, { expires_in: 2.seconds })
|
||||||
result = Sessions::CacheIn.get( 'last_run_test' )
|
result = Sessions::CacheIn.get('last_run_test')
|
||||||
assert_equal( true, result, 'check 1' )
|
assert_equal(true, result, 'check 1')
|
||||||
|
|
||||||
# should not be expired
|
# should not be expired
|
||||||
result = Sessions::CacheIn.expired( 'last_run_test' )
|
result = Sessions::CacheIn.expired('last_run_test')
|
||||||
assert_equal( false, result, 'check 1 - expired' )
|
assert_equal(false, result, 'check 1 - expired')
|
||||||
|
|
||||||
# should be expired
|
# should be expired
|
||||||
sleep 3
|
sleep 3
|
||||||
result = Sessions::CacheIn.expired( 'last_run_test' )
|
result = Sessions::CacheIn.expired('last_run_test')
|
||||||
assert_equal( true, result, 'check 1 - expired' )
|
assert_equal(true, result, 'check 1 - expired')
|
||||||
|
|
||||||
# renew expire
|
# renew expire
|
||||||
result = Sessions::CacheIn.get( 'last_run_test', re_expire: true )
|
result = Sessions::CacheIn.get('last_run_test', re_expire: true)
|
||||||
assert_equal( true, result, 'check 1 - re_expire' )
|
assert_equal(true, result, 'check 1 - re_expire')
|
||||||
|
|
||||||
# should not be expired
|
# should not be expired
|
||||||
result = Sessions::CacheIn.expired( 'last_run_test' )
|
result = Sessions::CacheIn.expired('last_run_test')
|
||||||
assert_equal( false, result, 'check 1 - expired' )
|
assert_equal(false, result, 'check 1 - expired')
|
||||||
|
|
||||||
# ignore expired
|
# ignore expired
|
||||||
sleep 3
|
sleep 3
|
||||||
result = Sessions::CacheIn.get( 'last_run_test', ignore_expire: true )
|
result = Sessions::CacheIn.get('last_run_test', ignore_expire: true)
|
||||||
assert_equal( true, result, 'check 1 - ignore_expire' )
|
assert_equal(true, result, 'check 1 - ignore_expire')
|
||||||
|
|
||||||
# should be expired
|
# should be expired
|
||||||
result = Sessions::CacheIn.expired( 'last_run_test' )
|
result = Sessions::CacheIn.expired('last_run_test')
|
||||||
assert_equal( true, result, 'check 2' )
|
assert_equal(true, result, 'check 2')
|
||||||
|
|
||||||
result = Sessions::CacheIn.get( 'last_run_test' )
|
result = Sessions::CacheIn.get('last_run_test')
|
||||||
assert_equal( nil, result, 'check 2' )
|
assert_equal(nil, result, 'check 2')
|
||||||
|
|
||||||
# check delete cache
|
# check delete cache
|
||||||
Sessions::CacheIn.set( 'last_run_delete', true, { expires_in: 5.seconds } )
|
Sessions::CacheIn.set('last_run_delete', true, { expires_in: 5.seconds })
|
||||||
result = Sessions::CacheIn.get( 'last_run_delete' )
|
result = Sessions::CacheIn.get('last_run_delete')
|
||||||
assert_equal( true, result, 'check 1' )
|
assert_equal(true, result, 'check 1')
|
||||||
Sessions::CacheIn.delete( 'last_run_delete' )
|
Sessions::CacheIn.delete('last_run_delete')
|
||||||
result = Sessions::CacheIn.get( 'last_run_delete' )
|
result = Sessions::CacheIn.get('last_run_delete')
|
||||||
assert_equal( nil, nil, 'check delete' )
|
assert_equal(nil, nil, 'check delete')
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'c session create / update' do
|
test 'c session create / update' do
|
||||||
|
|
||||||
# create users
|
# create users
|
||||||
roles = Role.where( name: [ 'Agent'] )
|
roles = Role.where(name: ['Agent'])
|
||||||
groups = Group.all
|
groups = Group.all
|
||||||
|
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
|
@ -67,34 +67,34 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# create sessions
|
# create sessions
|
||||||
client_id1 = '123456789'
|
client_id1 = '123456789'
|
||||||
Sessions.create( client_id1, {}, { type: 'websocket' } )
|
Sessions.create(client_id1, {}, { type: 'websocket' })
|
||||||
|
|
||||||
# check if session exists
|
# check if session exists
|
||||||
assert( Sessions.session_exists?(client_id1), 'check if session exists' )
|
assert(Sessions.session_exists?(client_id1), 'check if session exists')
|
||||||
|
|
||||||
# check session data
|
# check session data
|
||||||
data = Sessions.get(client_id1)
|
data = Sessions.get(client_id1)
|
||||||
assert( data[:meta], 'check if meta exists' )
|
assert(data[:meta], 'check if meta exists')
|
||||||
assert( data[:user], 'check if user exists' )
|
assert(data[:user], 'check if user exists')
|
||||||
assert_equal( data[:user]['id'], nil, 'check if user id is correct' )
|
assert_equal(data[:user]['id'], nil, 'check if user id is correct')
|
||||||
|
|
||||||
# recreate session
|
# recreate session
|
||||||
Sessions.create( client_id1, agent1.attributes, { type: 'websocket' } )
|
Sessions.create(client_id1, agent1.attributes, { type: 'websocket' })
|
||||||
|
|
||||||
# check if session exists
|
# check if session exists
|
||||||
assert( Sessions.session_exists?(client_id1), 'check if session exists' )
|
assert(Sessions.session_exists?(client_id1), 'check if session exists')
|
||||||
|
|
||||||
# check session data
|
# check session data
|
||||||
data = Sessions.get(client_id1)
|
data = Sessions.get(client_id1)
|
||||||
assert( data[:meta], 'check if meta exists' )
|
assert(data[:meta], 'check if meta exists')
|
||||||
assert( data[:user], 'check if user exists' )
|
assert(data[:user], 'check if user exists')
|
||||||
assert_equal( data[:user]['id'], agent1.id, 'check if user id is correct' )
|
assert_equal(data[:user]['id'], agent1.id, 'check if user id is correct')
|
||||||
|
|
||||||
# destroy session
|
# destroy session
|
||||||
Sessions.destory(client_id1)
|
Sessions.destory(client_id1)
|
||||||
|
|
||||||
# check if session exists
|
# check if session exists
|
||||||
assert( !Sessions.session_exists?(client_id1), 'check if session exists' )
|
assert(!Sessions.session_exists?(client_id1), 'check if session exists')
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,23 +103,23 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
UserInfo.current_user_id = 2
|
UserInfo.current_user_id = 2
|
||||||
user = User.lookup(id: 1)
|
user = User.lookup(id: 1)
|
||||||
collection_client1 = Sessions::Backend::Collections::Group.new(user, false, '123-1', 3)
|
collection_client1 = Sessions::Backend::Collections::Group.new(user, {}, false, '123-1', 3)
|
||||||
collection_client2 = Sessions::Backend::Collections::Group.new(user, false, '234-2', 3)
|
collection_client2 = Sessions::Backend::Collections::Group.new(user, {}, false, '234-2', 3)
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1.empty?, 'check collections' )
|
assert(!result1.empty?, 'check collections')
|
||||||
sleep 0.6
|
sleep 0.6
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2.empty?, 'check collections' )
|
assert(!result2.empty?, 'check collections')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1, 'check collections - recall' )
|
assert(!result1, 'check collections - recall')
|
||||||
sleep 1
|
sleep 1
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2, 'check collections - recall' )
|
assert(!result2, 'check collections - recall')
|
||||||
|
|
||||||
# change collection
|
# change collection
|
||||||
group = Group.first
|
group = Group.first
|
||||||
|
@ -128,36 +128,36 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1.empty?, 'check collections - after touch' )
|
assert(!result1.empty?, 'check collections - after touch')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2.empty?, 'check collections - after touch' )
|
assert(!result2.empty?, 'check collections - after touch')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
# check again after touch
|
# check again after touch
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1, 'check collections - after touch - recall' )
|
assert(!result1, 'check collections - after touch - recall')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2, 'check collections - after touch - recall' )
|
assert(!result2, 'check collections - after touch - recall')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
# change collection
|
# change collection
|
||||||
group = Group.create( name: 'SomeGroup::' + rand(999_999).to_s, active: true )
|
group = Group.create(name: 'SomeGroup::' + rand(999_999).to_s, active: true)
|
||||||
sleep 4
|
sleep 4
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1.empty?, 'check collections - after create' )
|
assert(!result1.empty?, 'check collections - after create')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2.empty?, 'check collections - after create' )
|
assert(!result2.empty?, 'check collections - after create')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
# check again after create
|
# check again after create
|
||||||
sleep 4
|
sleep 4
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1, 'check collections - after create - recall' )
|
assert(!result1, 'check collections - after create - recall')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2, 'check collections - after create - recall' )
|
assert(!result2, 'check collections - after create - recall')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
# change collection
|
# change collection
|
||||||
group.destroy
|
group.destroy
|
||||||
|
@ -165,22 +165,22 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1.empty?, 'check collections - after destroy' )
|
assert(!result1.empty?, 'check collections - after destroy')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2.empty?, 'check collections - after destroy' )
|
assert(!result2.empty?, 'check collections - after destroy')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
# check again after destroy
|
# check again after destroy
|
||||||
sleep 4
|
sleep 4
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1, 'check collections - after destroy - recall' )
|
assert(!result1, 'check collections - after destroy - recall')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2, 'check collections - after destroy - recall' )
|
assert(!result2, 'check collections - after destroy - recall')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
end
|
end
|
||||||
|
|
||||||
user = User.lookup(id: 1)
|
user = User.lookup(id: 1)
|
||||||
roles = Role.where( name: %w(Agent Admin) )
|
roles = Role.where(name: %w(Agent Admin))
|
||||||
user.roles = roles
|
user.roles = roles
|
||||||
user.save
|
user.save
|
||||||
|
|
||||||
|
@ -190,41 +190,41 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
user = User.lookup(id: 1)
|
user = User.lookup(id: 1)
|
||||||
org = Organization.create( name: 'SomeOrg1::' + rand(999_999).to_s, active: true )
|
org = Organization.create( name: 'SomeOrg1::' + rand(999_999).to_s, active: true )
|
||||||
|
|
||||||
collection_client1 = Sessions::Backend::Collections::Organization.new(user, false, '123-1', 3)
|
collection_client1 = Sessions::Backend::Collections::Organization.new(user, {}, false, '123-1', 3)
|
||||||
collection_client2 = Sessions::Backend::Collections::Organization.new(user, false, '234-2', 3)
|
collection_client2 = Sessions::Backend::Collections::Organization.new(user, {}, false, '234-2', 3)
|
||||||
|
|
||||||
# get whole collections - should be nil, no org exists!
|
# get whole collections - should be nil, no org exists!
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1.empty?, 'check collections' )
|
assert(!result1.empty?, 'check collections')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2.empty?, 'check collections' )
|
assert(!result2.empty?, 'check collections')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
# next check - should still be nil, no org exists!
|
# next check - should still be nil, no org exists!
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1, 'check collections - recall' )
|
assert(!result1, 'check collections - recall')
|
||||||
sleep 0.6
|
sleep 0.6
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2, 'check collections - recall' )
|
assert(!result2, 'check collections - recall')
|
||||||
|
|
||||||
# change collection
|
# change collection
|
||||||
org = Organization.create( name: 'SomeOrg2::' + rand(999_999).to_s, active: true )
|
org = Organization.create(name: 'SomeOrg2::' + rand(999_999).to_s, active: true)
|
||||||
sleep 4
|
sleep 4
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1.empty?, 'check collections - after create' )
|
assert(!result1.empty?, 'check collections - after create')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2.empty?, 'check collections - after create' )
|
assert(!result2.empty?, 'check collections - after create')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
sleep 4
|
sleep 4
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1, 'check collections - after create recall' )
|
assert(!result1, 'check collections - after create recall')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result2, 'check collections - after create recall' )
|
assert(!result2, 'check collections - after create recall')
|
||||||
|
|
||||||
organization = Organization.first
|
organization = Organization.first
|
||||||
organization.touch
|
organization.touch
|
||||||
|
@ -232,32 +232,32 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( !result1.empty?, 'check collections - after touch' )
|
assert(!result1.empty?, 'check collections - after touch')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( !result1.empty?, 'check collections - after touch' )
|
assert(!result1.empty?, 'check collections - after touch')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'c rss' do
|
test 'c rss' do
|
||||||
user = User.lookup(id: 1)
|
user = User.lookup(id: 1)
|
||||||
collection_client1 = Sessions::Backend::Rss.new(user, false, '123-1')
|
collection_client1 = Sessions::Backend::Rss.new(user, {}, false, '123-1')
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
#puts "RSS1: #{result1.inspect}"
|
#puts "RSS1: #{result1.inspect}"
|
||||||
assert( !result1.empty?, 'check rss' )
|
assert(!result1.empty?, 'check rss')
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
#puts "R1: #{result1.inspect}"
|
#puts "R1: #{result1.inspect}"
|
||||||
assert( !result1, 'check rss - recall' )
|
assert(!result1, 'check rss - recall')
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'c activity stream' do
|
test 'c activity stream' do
|
||||||
|
|
||||||
# create users
|
# create users
|
||||||
roles = Role.where( name: %w(Agent Admin) )
|
roles = Role.where(name: %w(Agent Admin))
|
||||||
groups = Group.all
|
groups = Group.all
|
||||||
|
|
||||||
UserInfo.current_user_id = 2
|
UserInfo.current_user_id = 2
|
||||||
|
@ -272,61 +272,61 @@ class SessionBasicTest < ActiveSupport::TestCase
|
||||||
groups: groups,
|
groups: groups,
|
||||||
)
|
)
|
||||||
agent1.roles = roles
|
agent1.roles = roles
|
||||||
assert( agent1.save, 'create/update agent1' )
|
assert(agent1.save, 'create/update agent1')
|
||||||
|
|
||||||
as_client1 = Sessions::Backend::ActivityStream.new(agent1, false, '123-1', 3)
|
as_client1 = Sessions::Backend::ActivityStream.new(agent1, {}, false, '123-1', 3)
|
||||||
|
|
||||||
# get as stream
|
# get as stream
|
||||||
result1 = as_client1.push
|
result1 = as_client1.push
|
||||||
assert( result1, 'check as agent1' )
|
assert(result1, 'check as agent1')
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
result1 = as_client1.push
|
result1 = as_client1.push
|
||||||
assert( !result1, 'check as agent1 - recall' )
|
assert(!result1, 'check as agent1 - recall')
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
sleep 4
|
sleep 4
|
||||||
result1 = as_client1.push
|
result1 = as_client1.push
|
||||||
assert( !result1, 'check as agent1 - recall 2' )
|
assert(!result1, 'check as agent1 - recall 2')
|
||||||
|
|
||||||
agent1.update_attribute( :email, 'activity-stream-agent11@example.com' )
|
agent1.update_attribute(:email, 'activity-stream-agent11@example.com')
|
||||||
ticket = Ticket.create(title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1 )
|
ticket = Ticket.create(title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
|
||||||
|
|
||||||
sleep 4
|
sleep 4
|
||||||
|
|
||||||
# get as stream
|
# get as stream
|
||||||
result1 = as_client1.push
|
result1 = as_client1.push
|
||||||
assert( result1, 'check as agent1 - recall 3' )
|
assert( result1, 'check as agent1 - recall 3')
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'c ticket_create' do
|
test 'c ticket_create' do
|
||||||
|
|
||||||
UserInfo.current_user_id = 2
|
UserInfo.current_user_id = 2
|
||||||
user = User.lookup(id: 1)
|
user = User.lookup(id: 1)
|
||||||
ticket_create_client1 = Sessions::Backend::TicketCreate.new(user, false, '123-1', 3)
|
ticket_create_client1 = Sessions::Backend::TicketCreate.new(user, {}, false, '123-1', 3)
|
||||||
|
|
||||||
# get as stream
|
# get as stream
|
||||||
result1 = ticket_create_client1.push
|
result1 = ticket_create_client1.push
|
||||||
assert( result1, 'check ticket_create' )
|
assert(result1, 'check ticket_create')
|
||||||
sleep 0.6
|
sleep 0.6
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
result1 = ticket_create_client1.push
|
result1 = ticket_create_client1.push
|
||||||
assert( !result1, 'check ticket_create - recall' )
|
assert(!result1, 'check ticket_create - recall')
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
sleep 0.6
|
sleep 0.6
|
||||||
result1 = ticket_create_client1.push
|
result1 = ticket_create_client1.push
|
||||||
assert( !result1, 'check ticket_create - recall 2' )
|
assert(!result1, 'check ticket_create - recall 2')
|
||||||
|
|
||||||
Group.create( name: 'SomeTicketCreateGroup::' + rand(999_999).to_s, active: true )
|
Group.create(name: 'SomeTicketCreateGroup::' + rand(999_999).to_s, active: true)
|
||||||
|
|
||||||
sleep 4
|
sleep 4
|
||||||
|
|
||||||
# get as stream
|
# get as stream
|
||||||
result1 = ticket_create_client1.push
|
result1 = ticket_create_client1.push
|
||||||
assert( result1, 'check ticket_create - recall 3' )
|
assert(result1, 'check ticket_create - recall 3')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,11 +3,12 @@ require 'test_helper'
|
||||||
|
|
||||||
class SessionBasicTicketTest < ActiveSupport::TestCase
|
class SessionBasicTicketTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test 'b ticket_overview_index' do
|
test 'b ticket_overview_List' do
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
|
Ticket.destroy_all
|
||||||
|
|
||||||
# create users
|
# create users
|
||||||
roles = Role.where( name: [ 'Agent' ] )
|
roles = Role.where(name: ['Agent'])
|
||||||
groups = Group.all
|
groups = Group.all
|
||||||
|
|
||||||
agent1 = User.create_or_update(
|
agent1 = User.create_or_update(
|
||||||
|
@ -22,81 +23,54 @@ class SessionBasicTicketTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
agent1.roles = roles
|
agent1.roles = roles
|
||||||
assert( agent1.save, 'create/update agent1' )
|
assert(agent1.save, 'create/update agent1')
|
||||||
|
|
||||||
Ticket.create( title: 'default overview test', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1 )
|
Ticket.create(title: 'default overview test', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
|
||||||
|
|
||||||
user = User.lookup( id: agent1.id )
|
user = User.lookup(id: agent1.id)
|
||||||
client1 = Sessions::Backend::TicketOverviewIndex.new(user, false, '123-1', 5)
|
client1 = Sessions::Backend::TicketOverviewList.new(user, {}, false, '123-1', 5)
|
||||||
|
|
||||||
# get as stream
|
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert( result1, 'check ticket_overview_index' )
|
assert(result1, 'check ticket_overview_List')
|
||||||
|
|
||||||
# next check should be empty / no changes
|
# next check should be empty / no changes
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert( !result1, 'check ticket_overview_index - recall' )
|
assert(!result1, 'check ticket_overview_index - recall')
|
||||||
|
|
||||||
# next check should be empty / no changes
|
# next check should be empty / no changes
|
||||||
sleep 6
|
sleep 6
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert( !result1, 'check ticket_overview_index - recall 2' )
|
assert(!result1, 'check ticket_overview_index - recall 2')
|
||||||
|
|
||||||
# create ticket
|
# create ticket
|
||||||
ticket = Ticket.create( title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1 )
|
ticket = Ticket.create(title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
|
||||||
sleep 6
|
sleep 6
|
||||||
|
|
||||||
# get as stream
|
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert( result1, 'check ticket_overview_index - recall 3' )
|
assert(result1, 'check ticket_overview_index - recall 3')
|
||||||
end
|
sleep 6
|
||||||
|
|
||||||
test 'b ticket_overview_list' do
|
# chnage overview
|
||||||
UserInfo.current_user_id = 1
|
overviews = Ticket::Overviews.all(
|
||||||
|
current_user: user,
|
||||||
# create users
|
|
||||||
roles = Role.where( name: [ 'Agent' ] )
|
|
||||||
groups = Group.all
|
|
||||||
|
|
||||||
agent1 = User.create_or_update(
|
|
||||||
login: 'session-basic-ticket-agent-1',
|
|
||||||
firstname: 'Session',
|
|
||||||
lastname: 'session basic ' + rand(99_999).to_s,
|
|
||||||
email: 'session-basic-ticket-agent-1@example.com',
|
|
||||||
password: 'agentpw',
|
|
||||||
active: true,
|
|
||||||
roles: roles,
|
|
||||||
groups: groups,
|
|
||||||
)
|
)
|
||||||
|
overviews.first.touch
|
||||||
|
|
||||||
agent1.roles = roles
|
|
||||||
assert( agent1.save, 'create/update agent1' )
|
|
||||||
|
|
||||||
Ticket.create( title: 'default overview test', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1 )
|
|
||||||
|
|
||||||
user = User.lookup( id: agent1.id )
|
|
||||||
|
|
||||||
client1 = Sessions::Backend::TicketOverviewList.new(user, false, '123-1', 5)
|
|
||||||
|
|
||||||
# get as stream
|
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert( result1, 'check ticket_overview_list' )
|
assert(result1, 'check ticket_overview_index - recall 4')
|
||||||
|
|
||||||
# next check should be empty / no changes
|
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert( !result1, 'check ticket_overview_list - recall' )
|
assert(!result1, 'check ticket_overview_index - recall 5')
|
||||||
|
|
||||||
# next check should be empty / no changes
|
Sessions::Backend::TicketOverviewList.reset(user.id)
|
||||||
sleep 6
|
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert( !result1, 'check ticket_overview_list - recall 2' )
|
assert(!result1, 'check ticket_overview_index - recall 6')
|
||||||
|
|
||||||
# create ticket
|
ticket = Ticket.create(title: '12323 - 2', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
|
||||||
ticket = Ticket.create( title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1 )
|
Sessions::Backend::TicketOverviewList.reset(user.id)
|
||||||
sleep 6
|
|
||||||
|
|
||||||
# get as stream
|
|
||||||
result1 = client1.push
|
result1 = client1.push
|
||||||
assert( result1, 'check ticket_overview_list - recall 3' )
|
assert(result1, 'check ticket_overview_index - recall 7')
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
|
|
||||||
# create users
|
# create users
|
||||||
roles = Role.where( name: %w(Agent Admin) )
|
roles = Role.where(name: %w(Agent Admin))
|
||||||
groups = Group.all
|
groups = Group.all
|
||||||
|
|
||||||
agent1 = User.create_or_update(
|
agent1 = User.create_or_update(
|
||||||
|
@ -24,7 +24,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
agent1.roles = roles
|
agent1.roles = roles
|
||||||
agent1.save
|
agent1.save
|
||||||
|
|
||||||
roles = Role.where( name: [ 'Agent' ] )
|
roles = Role.where(name: ['Agent'])
|
||||||
groups = Group.all
|
groups = Group.all
|
||||||
|
|
||||||
agent2 = User.create_or_update(
|
agent2 = User.create_or_update(
|
||||||
|
@ -40,7 +40,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
agent2.roles = roles
|
agent2.roles = roles
|
||||||
agent2.save
|
agent2.save
|
||||||
|
|
||||||
roles = Role.where( name: [ 'Customer'] )
|
roles = Role.where(name: ['Customer'])
|
||||||
customer1 = User.create_or_update(
|
customer1 = User.create_or_update(
|
||||||
login: 'session-collections-customer-1',
|
login: 'session-collections-customer-1',
|
||||||
firstname: 'Session',
|
firstname: 'Session',
|
||||||
|
@ -54,41 +54,41 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
customer1.roles = roles
|
customer1.roles = roles
|
||||||
customer1.save
|
customer1.save
|
||||||
|
|
||||||
collection_client1 = Sessions::Backend::Collections.new(agent1, nil, 'aaa-1', 3)
|
collection_client1 = Sessions::Backend::Collections.new(agent1, {}, nil, 'aaa-1', 3)
|
||||||
collection_client2 = Sessions::Backend::Collections.new(agent2, nil, 'bbb-2', 3)
|
collection_client2 = Sessions::Backend::Collections.new(agent2, {}, nil, 'bbb-2', 3)
|
||||||
collection_client3 = Sessions::Backend::Collections.new(customer1, nil, 'ccc-2', 3)
|
collection_client3 = Sessions::Backend::Collections.new(customer1, {}, nil, 'ccc-2', 3)
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( result1, 'check collections' )
|
assert(result1, 'check collections')
|
||||||
assert( check_if_collection_exists(result1, :Group), 'check collections - after init' )
|
assert(check_if_collection_exists(result1, :Group), 'check collections - after init')
|
||||||
assert( check_if_collection_exists(result1, :Role), 'check collections - after init' )
|
assert(check_if_collection_exists(result1, :Role), 'check collections - after init')
|
||||||
assert( check_if_collection_exists(result1, :Signature), 'check collections - after init' )
|
assert(check_if_collection_exists(result1, :Signature), 'check collections - after init')
|
||||||
assert( check_if_collection_exists(result1, :EmailAddress), 'check collections - after init' )
|
assert(check_if_collection_exists(result1, :EmailAddress), 'check collections - after init')
|
||||||
sleep 1
|
sleep 1
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( result2, 'check collections' )
|
assert(result2, 'check collections')
|
||||||
assert( check_if_collection_exists(result2, :Group), 'check collections - after init' )
|
assert(check_if_collection_exists(result2, :Group), 'check collections - after init')
|
||||||
assert( check_if_collection_exists(result2, :Role), 'check collections - after init' )
|
assert(check_if_collection_exists(result2, :Role), 'check collections - after init')
|
||||||
assert( check_if_collection_exists(result2, :Signature), 'check collections - after init' )
|
assert(check_if_collection_exists(result2, :Signature), 'check collections - after init')
|
||||||
assert( check_if_collection_exists(result2, :EmailAddress), 'check collections - after init' )
|
assert(check_if_collection_exists(result2, :EmailAddress), 'check collections - after init')
|
||||||
assert_equal( result1, result2, 'check collections' )
|
assert_equal(result1, result2, 'check collections')
|
||||||
|
|
||||||
result3 = collection_client3.push
|
result3 = collection_client3.push
|
||||||
assert( result3, 'check collections' )
|
assert(result3, 'check collections')
|
||||||
assert( check_if_collection_exists(result3, :Group), 'check collections - after init' )
|
assert(check_if_collection_exists(result3, :Group), 'check collections - after init')
|
||||||
assert( check_if_collection_exists(result3, :Role), 'check collections - after init' )
|
assert(check_if_collection_exists(result3, :Role), 'check collections - after init')
|
||||||
assert( !check_if_collection_exists(result3, :Signature), 'check collections - after init' )
|
assert(!check_if_collection_exists(result3, :Signature), 'check collections - after init')
|
||||||
assert( !check_if_collection_exists(result3, :EmailAddress), 'check collections - after init' )
|
assert(!check_if_collection_exists(result3, :EmailAddress), 'check collections - after init')
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( result1.empty?, 'check collections - recall' )
|
assert(result1.empty?, 'check collections - recall')
|
||||||
sleep 0.4
|
sleep 0.4
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( result2.empty?, 'check collections - recall' )
|
assert(result2.empty?, 'check collections - recall')
|
||||||
result3 = collection_client3.push
|
result3 = collection_client3.push
|
||||||
assert( result3.empty?, 'check collections - recall' )
|
assert(result3.empty?, 'check collections - recall')
|
||||||
|
|
||||||
# change collection
|
# change collection
|
||||||
group = Group.first
|
group = Group.first
|
||||||
|
@ -97,42 +97,42 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( result1, 'check collections - after touch' )
|
assert(result1, 'check collections - after touch')
|
||||||
assert( check_if_collection_exists(result1, :Group), 'check collections - after touch' )
|
assert(check_if_collection_exists(result1, :Group), 'check collections - after touch')
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( result2, 'check collections - after touch' )
|
assert(result2, 'check collections - after touch')
|
||||||
assert( check_if_collection_exists(result2, :Group), 'check collections - after touch' )
|
assert(check_if_collection_exists(result2, :Group), 'check collections - after touch')
|
||||||
result3 = collection_client3.push
|
result3 = collection_client3.push
|
||||||
assert( result3, 'check collections - after touch' )
|
assert(result3, 'check collections - after touch')
|
||||||
assert( check_if_collection_exists(result3, :Group), 'check collections - after touch' )
|
assert(check_if_collection_exists(result3, :Group), 'check collections - after touch')
|
||||||
|
|
||||||
# change collection
|
# change collection
|
||||||
org = Organization.create( name: 'SomeOrg::' + rand(999_999).to_s, active: true, member_ids: [customer1.id] )
|
org = Organization.create(name: 'SomeOrg::' + rand(999_999).to_s, active: true, member_ids: [customer1.id])
|
||||||
sleep 4
|
sleep 4
|
||||||
|
|
||||||
# get whole collections
|
# get whole collections
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( result1, 'check collections - after create' )
|
assert(result1, 'check collections - after create')
|
||||||
assert( check_if_collection_exists(result1, :Organization, { id: org.id, member_ids: [customer1.id] } ), 'check collections - after create with attributes' )
|
assert(check_if_collection_exists(result1, :Organization, { id: org.id, member_ids: [customer1.id] }), 'check collections - after create with attributes')
|
||||||
sleep 0.3
|
sleep 0.3
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( result2, 'check collections - after create' )
|
assert(result2, 'check collections - after create')
|
||||||
assert( check_if_collection_exists(result2, :Organization), 'check collections - after create' )
|
assert(check_if_collection_exists(result2, :Organization), 'check collections - after create')
|
||||||
|
|
||||||
# user has no organization, so collection should be empty
|
# user has no organization, so collection should be empty
|
||||||
result3 = collection_client3.push
|
result3 = collection_client3.push
|
||||||
assert( result3, 'check collections - after create' )
|
assert(result3, 'check collections - after create')
|
||||||
assert( !check_if_collection_exists(result3, :Organization), 'check collections - after create' )
|
assert(!check_if_collection_exists(result3, :Organization), 'check collections - after create')
|
||||||
|
|
||||||
# next check should be empty
|
# next check should be empty
|
||||||
sleep 1
|
sleep 1
|
||||||
result1 = collection_client1.push
|
result1 = collection_client1.push
|
||||||
assert( result1.empty?, 'check collections - recall' )
|
assert(result1.empty?, 'check collections - recall')
|
||||||
result2 = collection_client2.push
|
result2 = collection_client2.push
|
||||||
assert( result2.empty?, 'check collections - recall' )
|
assert(result2.empty?, 'check collections - recall')
|
||||||
result3 = collection_client3.push
|
result3 = collection_client3.push
|
||||||
assert( result3.empty?, 'check collections - recall' )
|
assert(result3.empty?, 'check collections - recall')
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_if_collection_exists(results, collection, attributes = nil)
|
def check_if_collection_exists(results, collection, attributes = nil)
|
||||||
|
|
|
@ -5,7 +5,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
test 'a check clients and send messages' do
|
test 'a check clients and send messages' do
|
||||||
|
|
||||||
# create users
|
# create users
|
||||||
roles = Role.where( name: [ 'Agent'] )
|
roles = Role.where(name: ['Agent'])
|
||||||
groups = Group.all
|
groups = Group.all
|
||||||
|
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
|
@ -53,21 +53,21 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
Sessions.destory(client_id1)
|
Sessions.destory(client_id1)
|
||||||
Sessions.destory(client_id2)
|
Sessions.destory(client_id2)
|
||||||
Sessions.destory(client_id3)
|
Sessions.destory(client_id3)
|
||||||
Sessions.create( client_id1, agent1.attributes, { type: 'websocket' } )
|
Sessions.create(client_id1, agent1.attributes, { type: 'websocket' })
|
||||||
Sessions.create( client_id2, agent2.attributes, { type: 'ajax' } )
|
Sessions.create(client_id2, agent2.attributes, { type: 'ajax' })
|
||||||
Sessions.create( client_id3, agent3.attributes, { type: 'ajax' } )
|
Sessions.create(client_id3, agent3.attributes, { type: 'ajax' })
|
||||||
|
|
||||||
# check if session exists
|
# check if session exists
|
||||||
assert( Sessions.session_exists?(client_id1), 'check if session exists' )
|
assert(Sessions.session_exists?(client_id1), 'check if session exists')
|
||||||
assert( Sessions.session_exists?(client_id2), 'check if session exists' )
|
assert(Sessions.session_exists?(client_id2), 'check if session exists')
|
||||||
assert( Sessions.session_exists?(client_id3), 'check if session exists' )
|
assert(Sessions.session_exists?(client_id3), 'check if session exists')
|
||||||
|
|
||||||
# check if session still exists after idle cleanup
|
# check if session still exists after idle cleanup
|
||||||
sleep 1
|
sleep 1
|
||||||
Sessions.destory_idle_sessions(5)
|
Sessions.destory_idle_sessions(5)
|
||||||
assert( Sessions.session_exists?(client_id1), 'check if session exists after 1 sec' )
|
assert(Sessions.session_exists?(client_id1), 'check if session exists after 1 sec')
|
||||||
assert( Sessions.session_exists?(client_id2), 'check if session exists after 1 sec' )
|
assert(Sessions.session_exists?(client_id2), 'check if session exists after 1 sec')
|
||||||
assert( Sessions.session_exists?(client_id3), 'check if session exists after 1 sec' )
|
assert(Sessions.session_exists?(client_id3), 'check if session exists after 1 sec')
|
||||||
|
|
||||||
# check if session still exists after idle cleanup with touched sessions
|
# check if session still exists after idle cleanup with touched sessions
|
||||||
sleep 6
|
sleep 6
|
||||||
|
@ -75,71 +75,71 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
Sessions.touch(client_id2)
|
Sessions.touch(client_id2)
|
||||||
Sessions.touch(client_id3)
|
Sessions.touch(client_id3)
|
||||||
Sessions.destory_idle_sessions(5)
|
Sessions.destory_idle_sessions(5)
|
||||||
assert( Sessions.session_exists?(client_id1), 'check if session exists after touch' )
|
assert(Sessions.session_exists?(client_id1), 'check if session exists after touch')
|
||||||
assert( Sessions.session_exists?(client_id2), 'check if session exists after touch' )
|
assert(Sessions.session_exists?(client_id2), 'check if session exists after touch')
|
||||||
assert( Sessions.session_exists?(client_id3), 'check if session exists after touch' )
|
assert(Sessions.session_exists?(client_id3), 'check if session exists after touch')
|
||||||
|
|
||||||
# check session data
|
# check session data
|
||||||
data = Sessions.get(client_id1)
|
data = Sessions.get(client_id1)
|
||||||
assert( data[:meta], 'check if meta exists' )
|
assert(data[:meta], 'check if meta exists')
|
||||||
assert( data[:user], 'check if user exists' )
|
assert(data[:user], 'check if user exists')
|
||||||
assert_equal( data[:user]['id'], agent1.id, 'check if user id is correct' )
|
assert_equal(data[:user]['id'], agent1.id, 'check if user id is correct')
|
||||||
|
|
||||||
data = Sessions.get(client_id2)
|
data = Sessions.get(client_id2)
|
||||||
assert( data[:meta], 'check if meta exists' )
|
assert(data[:meta], 'check if meta exists')
|
||||||
assert( data[:user], 'check if user exists' )
|
assert(data[:user], 'check if user exists')
|
||||||
assert_equal( data[:user]['id'], agent2.id, 'check if user id is correct' )
|
assert_equal(data[:user]['id'], agent2.id, 'check if user id is correct')
|
||||||
|
|
||||||
data = Sessions.get(client_id3)
|
data = Sessions.get(client_id3)
|
||||||
assert( data[:meta], 'check if meta exists' )
|
assert(data[:meta], 'check if meta exists')
|
||||||
assert( data[:user], 'check if user exists' )
|
assert(data[:user], 'check if user exists')
|
||||||
assert_equal( data[:user]['id'], agent3.id, 'check if user id is correct' )
|
assert_equal(data[:user]['id'], agent3.id, 'check if user id is correct')
|
||||||
|
|
||||||
# send data to one client
|
# send data to one client
|
||||||
Sessions.send( client_id1, { msg: 'äöüß123' } )
|
Sessions.send(client_id1, { msg: 'äöüß123' })
|
||||||
Sessions.send( client_id1, { msg: 'äöüß1234' } )
|
Sessions.send(client_id1, { msg: 'äöüß1234' })
|
||||||
messages = Sessions.queue(client_id1)
|
messages = Sessions.queue(client_id1)
|
||||||
assert_equal( 3, messages.count, 'messages count')
|
assert_equal(3, messages.count, 'messages count')
|
||||||
assert_equal( 'ws:login', messages[0]['event'], 'messages 1')
|
assert_equal('ws:login', messages[0]['event'], 'messages 1')
|
||||||
assert_equal( true, messages[0]['data']['success'], 'messages 1')
|
assert_equal(true, messages[0]['data']['success'], 'messages 1')
|
||||||
assert_equal( 'äöüß123', messages[1]['msg'], 'messages 2')
|
assert_equal('äöüß123', messages[1]['msg'], 'messages 2')
|
||||||
assert_equal( 'äöüß1234', messages[2]['msg'], 'messages 3')
|
assert_equal('äöüß1234', messages[2]['msg'], 'messages 3')
|
||||||
|
|
||||||
messages = Sessions.queue(client_id2)
|
messages = Sessions.queue(client_id2)
|
||||||
assert_equal( messages.count, 1, 'messages count')
|
assert_equal(messages.count, 1, 'messages count')
|
||||||
assert_equal( 'ws:login', messages[0]['event'], 'messages 1')
|
assert_equal('ws:login', messages[0]['event'], 'messages 1')
|
||||||
assert_equal( true, messages[0]['data']['success'], 'messages 1')
|
assert_equal(true, messages[0]['data']['success'], 'messages 1')
|
||||||
|
|
||||||
messages = Sessions.queue(client_id3)
|
messages = Sessions.queue(client_id3)
|
||||||
assert_equal( messages.count, 1, 'messages count')
|
assert_equal(messages.count, 1, 'messages count')
|
||||||
assert_equal( 'ws:login', messages[0]['event'], 'messages 1')
|
assert_equal('ws:login', messages[0]['event'], 'messages 1')
|
||||||
assert_equal( true, messages[0]['data']['success'], 'messages 1')
|
assert_equal(true, messages[0]['data']['success'], 'messages 1')
|
||||||
|
|
||||||
# broadcast to all clients
|
# broadcast to all clients
|
||||||
Sessions.broadcast( { msg: 'ooo123123123123123123' } )
|
Sessions.broadcast({ msg: 'ooo123123123123123123' })
|
||||||
messages = Sessions.queue(client_id1)
|
messages = Sessions.queue(client_id1)
|
||||||
assert_equal( messages.count, 1, 'messages count')
|
assert_equal(messages.count, 1, 'messages count')
|
||||||
assert_equal( 'ooo123123123123123123', messages[0]['msg'], 'messages broadcast 1')
|
assert_equal('ooo123123123123123123', messages[0]['msg'], 'messages broadcast 1')
|
||||||
|
|
||||||
messages = Sessions.queue(client_id2)
|
messages = Sessions.queue(client_id2)
|
||||||
assert_equal( messages.count, 1, 'messages count')
|
assert_equal(messages.count, 1, 'messages count')
|
||||||
assert_equal( 'ooo123123123123123123', messages[0]['msg'], 'messages broadcast 1')
|
assert_equal('ooo123123123123123123', messages[0]['msg'], 'messages broadcast 1')
|
||||||
|
|
||||||
messages = Sessions.queue(client_id3)
|
messages = Sessions.queue(client_id3)
|
||||||
assert_equal( messages.count, 1, 'messages count')
|
assert_equal(messages.count, 1, 'messages count')
|
||||||
assert_equal( 'ooo123123123123123123', messages[0]['msg'], 'messages broadcast 1')
|
assert_equal('ooo123123123123123123', messages[0]['msg'], 'messages broadcast 1')
|
||||||
|
|
||||||
# send dedicated message to user
|
# send dedicated message to user
|
||||||
Sessions.send_to( agent1.id, { msg: 'ooo1231231231231231234' } )
|
Sessions.send_to(agent1.id, { msg: 'ooo1231231231231231234' })
|
||||||
messages = Sessions.queue(client_id1)
|
messages = Sessions.queue(client_id1)
|
||||||
assert_equal( messages.count, 1, 'messages count')
|
assert_equal(messages.count, 1, 'messages count')
|
||||||
assert_equal( 'ooo1231231231231231234', messages[0]['msg'], 'messages send 1')
|
assert_equal('ooo1231231231231231234', messages[0]['msg'], 'messages send 1')
|
||||||
|
|
||||||
messages = Sessions.queue(client_id2)
|
messages = Sessions.queue(client_id2)
|
||||||
assert_equal( messages.count, 0, 'messages count')
|
assert_equal(messages.count, 0, 'messages count')
|
||||||
|
|
||||||
messages = Sessions.queue(client_id3)
|
messages = Sessions.queue(client_id3)
|
||||||
assert_equal( messages.count, 0, 'messages count')
|
assert_equal(messages.count, 0, 'messages count')
|
||||||
|
|
||||||
# start jobs
|
# start jobs
|
||||||
jobs = Thread.new {
|
jobs = Thread.new {
|
||||||
|
@ -149,25 +149,25 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
#jobs.join
|
#jobs.join
|
||||||
|
|
||||||
# check client threads
|
# check client threads
|
||||||
assert( Sessions.thread_client_exists?(client_id1), 'check if client is running' )
|
assert(Sessions.thread_client_exists?(client_id1), 'check if client is running')
|
||||||
assert( Sessions.thread_client_exists?(client_id2), 'check if client is running' )
|
assert(Sessions.thread_client_exists?(client_id2), 'check if client is running')
|
||||||
assert( Sessions.thread_client_exists?(client_id3), 'check if client is running' )
|
assert(Sessions.thread_client_exists?(client_id3), 'check if client is running')
|
||||||
|
|
||||||
# check if session still exists after idle cleanup
|
# check if session still exists after idle cleanup
|
||||||
sleep 8
|
sleep 8
|
||||||
client_ids = Sessions.destory_idle_sessions(5)
|
client_ids = Sessions.destory_idle_sessions(5)
|
||||||
|
|
||||||
# check client sessions
|
# check client sessions
|
||||||
assert( !Sessions.session_exists?(client_id1), 'check if session is removed' )
|
assert(!Sessions.session_exists?(client_id1), 'check if session is removed')
|
||||||
assert( !Sessions.session_exists?(client_id2), 'check if session is removed' )
|
assert(!Sessions.session_exists?(client_id2), 'check if session is removed')
|
||||||
assert( !Sessions.session_exists?(client_id3), 'check if session is removed' )
|
assert(!Sessions.session_exists?(client_id3), 'check if session is removed')
|
||||||
|
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
# check client threads
|
# check client threads
|
||||||
assert( !Sessions.thread_client_exists?(client_id1), 'check if client is running' )
|
assert(!Sessions.thread_client_exists?(client_id1), 'check if client is running')
|
||||||
assert( !Sessions.thread_client_exists?(client_id2), 'check if client is running' )
|
assert(!Sessions.thread_client_exists?(client_id2), 'check if client is running')
|
||||||
assert( !Sessions.thread_client_exists?(client_id3), 'check if client is running' )
|
assert(!Sessions.thread_client_exists?(client_id3), 'check if client is running')
|
||||||
|
|
||||||
# exit jobs
|
# exit jobs
|
||||||
jobs.exit
|
jobs.exit
|
||||||
|
@ -176,7 +176,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test 'b check client and backends' do
|
test 'b check client and backends' do
|
||||||
# create users
|
# create users
|
||||||
roles = Role.where( name: [ 'Agent'] )
|
roles = Role.where(name: ['Agent'])
|
||||||
groups = Group.all
|
groups = Group.all
|
||||||
|
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
|
@ -204,7 +204,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
agent2.roles = roles
|
agent2.roles = roles
|
||||||
agent2.save
|
agent2.save
|
||||||
org = Organization.create( name: 'SomeOrg::' + rand(999_999).to_s, active: true )
|
org = Organization.create(name: 'SomeOrg::' + rand(999_999).to_s, active: true)
|
||||||
|
|
||||||
# create sessions
|
# create sessions
|
||||||
client_id1_0 = '1234-1'
|
client_id1_0 = '1234-1'
|
||||||
|
@ -219,16 +219,16 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
Sessions.jobs
|
Sessions.jobs
|
||||||
}
|
}
|
||||||
sleep 5
|
sleep 5
|
||||||
Sessions.create( client_id1_0, agent1.attributes, { type: 'websocket' } )
|
Sessions.create(client_id1_0, agent1.attributes, { type: 'websocket' })
|
||||||
sleep 6.5
|
sleep 6.5
|
||||||
Sessions.create( client_id1_1, agent1.attributes, { type: 'websocket' } )
|
Sessions.create(client_id1_1, agent1.attributes, { type: 'websocket' })
|
||||||
sleep 3.2
|
sleep 3.2
|
||||||
Sessions.create( client_id2, agent2.attributes, { type: 'ajax' } )
|
Sessions.create(client_id2, agent2.attributes, { type: 'ajax' })
|
||||||
|
|
||||||
# check if session exists
|
# check if session exists
|
||||||
assert( Sessions.session_exists?(client_id1_0), 'check if session exists' )
|
assert(Sessions.session_exists?(client_id1_0), 'check if session exists')
|
||||||
assert( Sessions.session_exists?(client_id1_1), 'check if session exists' )
|
assert(Sessions.session_exists?(client_id1_1), 'check if session exists')
|
||||||
assert( Sessions.session_exists?(client_id2), 'check if session exists' )
|
assert(Sessions.session_exists?(client_id2), 'check if session exists')
|
||||||
sleep 11
|
sleep 11
|
||||||
|
|
||||||
# check collections
|
# check collections
|
||||||
|
@ -282,9 +282,9 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
client_ids = Sessions.destory_idle_sessions(5)
|
client_ids = Sessions.destory_idle_sessions(5)
|
||||||
|
|
||||||
# check client sessions
|
# check client sessions
|
||||||
assert( !Sessions.session_exists?(client_id1_0), 'check if session is removed' )
|
assert(!Sessions.session_exists?(client_id1_0), 'check if session is removed')
|
||||||
assert( !Sessions.session_exists?(client_id1_1), 'check if session is removed' )
|
assert(!Sessions.session_exists?(client_id1_1), 'check if session is removed')
|
||||||
assert( !Sessions.session_exists?(client_id2), 'check if session is removed' )
|
assert(!Sessions.session_exists?(client_id2), 'check if session is removed')
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class UserDeviceTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'session test' do
|
test 'aaa - session test' do
|
||||||
|
|
||||||
# signin with fingerprint A from country A via session -> new device #1
|
# signin with fingerprint A from country A via session -> new device #1
|
||||||
user_device1 = UserDevice.add(
|
user_device1 = UserDevice.add(
|
||||||
|
@ -84,7 +84,7 @@ class UserDeviceTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'session test - user agent (unknown)' do
|
test 'bbb - session test - user agent (unknown)' do
|
||||||
|
|
||||||
# known user agent
|
# known user agent
|
||||||
user_device1 = UserDevice.add(
|
user_device1 = UserDevice.add(
|
||||||
|
@ -118,8 +118,8 @@ class UserDeviceTest < ActiveSupport::TestCase
|
||||||
'session',
|
'session',
|
||||||
)
|
)
|
||||||
assert_equal('Mozilla/5.0 (iPhone; CPU iPhone OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H143 Safari/600.1.4', user_device3.user_agent)
|
assert_equal('Mozilla/5.0 (iPhone; CPU iPhone OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H143 Safari/600.1.4', user_device3.user_agent)
|
||||||
assert_equal('iPhone', user_device3.browser)
|
assert_equal('Safari', user_device3.browser)
|
||||||
assert_equal('iPhone', user_device3.name)
|
assert_equal('Ios, Safari', user_device3.name)
|
||||||
|
|
||||||
user_device4 = UserDevice.add(
|
user_device4 = UserDevice.add(
|
||||||
'Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1',
|
'Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1',
|
||||||
|
@ -130,11 +130,11 @@ class UserDeviceTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
assert_equal('Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1', user_device4.user_agent)
|
assert_equal('Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1', user_device4.user_agent)
|
||||||
assert_equal('Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1', user_device4.browser)
|
assert_equal('Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1', user_device4.browser)
|
||||||
assert_equal('Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1', user_device4.name)
|
assert_equal('Mac, Mac+OS+X/10.10.5 (14F27) CalendarAgent/316.1', user_device4.name)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'api test' do
|
test 'ccc - api test' do
|
||||||
|
|
||||||
# signin with ua from country A via basic auth -> new device #1
|
# signin with ua from country A via basic auth -> new device #1
|
||||||
user_device1 = UserDevice.add(
|
user_device1 = UserDevice.add(
|
||||||
|
|
Loading…
Reference in a new issue