Merge branch 'develop' of git.znuny.com:zammad/zammad into develop

This commit is contained in:
Martin Edenhofer 2017-09-08 16:09:45 +02:00
commit a4a513edea
118 changed files with 864 additions and 656 deletions

View file

@ -416,7 +416,6 @@ browser:build:
- core - core
script: script:
- export RAILS_ENV=production - export RAILS_ENV=production
- rake db:drop;
- rake db:create - rake db:create
- rake db:migrate - rake db:migrate
- rake assets:precompile - rake assets:precompile

View file

@ -2,7 +2,7 @@ source 'https://rubygems.org'
ruby '2.4.1' ruby '2.4.1'
gem 'rails', '4.2.9' gem 'rails', '5.0.5'
gem 'rails-observers' gem 'rails-observers'
gem 'activerecord-session_store' gem 'activerecord-session_store'

View file

@ -17,35 +17,38 @@ GIT
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actionmailer (4.2.9) actioncable (5.0.5)
actionpack (= 4.2.9) actionpack (= 5.0.5)
actionview (= 4.2.9) nio4r (>= 1.2, < 3.0)
activejob (= 4.2.9) websocket-driver (~> 0.6.1)
actionmailer (5.0.5)
actionpack (= 5.0.5)
actionview (= 5.0.5)
activejob (= 5.0.5)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 2.0)
actionpack (4.2.9) actionpack (5.0.5)
actionview (= 4.2.9) actionview (= 5.0.5)
activesupport (= 4.2.9) activesupport (= 5.0.5)
rack (~> 1.6) rack (~> 2.0)
rack-test (~> 0.6.2) rack-test (~> 0.6.3)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.9) actionview (5.0.5)
activesupport (= 4.2.9) activesupport (= 5.0.5)
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 (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (4.2.9) activejob (5.0.5)
activesupport (= 4.2.9) activesupport (= 5.0.5)
globalid (>= 0.3.0) globalid (>= 0.3.6)
activemodel (4.2.9) activemodel (5.0.5)
activesupport (= 4.2.9) activesupport (= 5.0.5)
builder (~> 3.1) activerecord (5.0.5)
activerecord (4.2.9) activemodel (= 5.0.5)
activemodel (= 4.2.9) activesupport (= 5.0.5)
activesupport (= 4.2.9) arel (~> 7.0)
arel (~> 6.0)
activerecord-nulldb-adapter (0.3.7) activerecord-nulldb-adapter (0.3.7)
activerecord (>= 2.0.0) activerecord (>= 2.0.0)
activerecord-session_store (1.1.0) activerecord-session_store (1.1.0)
@ -54,44 +57,45 @@ GEM
multi_json (~> 1.11, >= 1.11.2) multi_json (~> 1.11, >= 1.11.2)
rack (>= 1.5.2, < 3) rack (>= 1.5.2, < 3)
railties (>= 4.0, < 5.2) railties (>= 4.0, < 5.2)
activesupport (4.2.9) activesupport (5.0.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7) i18n (~> 0.7)
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.4.0) addressable (2.5.2)
arel (6.0.4) public_suffix (>= 2.0.2, < 4.0)
arel (7.1.4)
argon2 (1.1.3) argon2 (1.1.3)
ffi (~> 1.9) ffi (~> 1.9)
ffi-compiler (~> 0.1) ffi-compiler (~> 0.1)
ast (2.3.0) ast (2.3.0)
autoprefixer-rails (7.1.2.4) autoprefixer-rails (7.1.3)
execjs execjs
biz (1.7.0) biz (1.7.0)
clavius (~> 1.0) clavius (~> 1.0)
tzinfo tzinfo
browser (2.2.0) browser (2.5.1)
buftok (0.2.0) buftok (0.2.0)
builder (3.2.3) builder (3.2.3)
childprocess (0.5.9) childprocess (0.7.1)
ffi (~> 1.0, >= 1.0.11) ffi (~> 1.0, >= 1.0.11)
clavius (1.0.2) clavius (1.0.3)
clearbit (0.2.7) clearbit (0.2.7)
nestful (~> 1.1.0) nestful (~> 1.1.0)
coderay (1.1.1) coderay (1.1.2)
coffee-rails (4.2.1) coffee-rails (4.2.2)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.2.x) railties (>= 4.0.0)
coffee-script (2.4.1) coffee-script (2.4.1)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.12.2) coffee-script-source (1.12.2)
coffeelint (1.14.0) coffeelint (1.16.0)
coffee-script coffee-script
execjs execjs
json json
composite_primary_keys (8.1.6) composite_primary_keys (9.0.7)
activerecord (~> 4.2.0) activerecord (~> 5.0.0)
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
coveralls (0.8.21) coveralls (0.8.21)
json (>= 1.8, < 3) json (>= 1.8, < 3)
@ -107,12 +111,12 @@ GEM
delayed_job_active_record (4.1.2) delayed_job_active_record (4.1.2)
activerecord (>= 3.0, < 5.2) activerecord (>= 3.0, < 5.2)
delayed_job (>= 3.0, < 5) delayed_job (>= 3.0, < 5)
diff-lcs (1.2.5) diff-lcs (1.3)
diffy (3.1.0) diffy (3.2.0)
docile (1.1.5) docile (1.1.5)
domain_name (0.5.20170404) domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
doorkeeper (4.2.0) doorkeeper (4.2.6)
railties (>= 4.2) railties (>= 4.2)
eco (1.0.0) eco (1.0.0)
coffee-script coffee-script
@ -122,18 +126,18 @@ GEM
em-websocket (0.5.1) em-websocket (0.5.1)
eventmachine (>= 0.12.9) eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0) http_parser.rb (~> 0.6.0)
equalizer (0.0.10) equalizer (0.0.11)
erubis (2.7.0) erubis (2.7.0)
eventmachine (1.2.3) eventmachine (1.2.5)
execjs (2.7.0) execjs (2.7.0)
factory_girl (4.8.0) factory_girl (4.8.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
factory_girl_rails (4.8.0) factory_girl_rails (4.8.0)
factory_girl (~> 4.8.0) factory_girl (~> 4.8.0)
railties (>= 3.0.0) railties (>= 3.0.0)
faraday (0.9.2) faraday (0.11.0)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.1) faraday-http-cache (2.0.0)
faraday (~> 0.8) faraday (~> 0.8)
ffi (1.9.18) ffi (1.9.18)
ffi-compiler (0.1.3) ffi-compiler (0.1.3)
@ -142,17 +146,17 @@ GEM
figaro (1.1.1) figaro (1.1.1)
thor (~> 0.14) thor (~> 0.14)
formatador (0.2.5) formatador (0.2.5)
github_changelog_generator (1.14.1) github_changelog_generator (1.14.3)
activesupport activesupport
faraday-http-cache faraday-http-cache
multi_json multi_json
octokit (~> 4.0) octokit (~> 4.6)
rainbow (>= 2.1) rainbow (>= 2.1)
rake (>= 10.0) rake (>= 10.0)
retriable (~> 2.1) retriable (~> 2.1)
globalid (0.4.0) globalid (0.4.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
guard (2.14.0) guard (2.14.1)
formatador (>= 0.2.4) formatador (>= 0.2.4)
listen (>= 2.7, < 4.0) listen (>= 2.7, < 4.0)
lumberjack (~> 1.0) lumberjack (~> 1.0)
@ -170,10 +174,10 @@ GEM
guard-symlink (0.1.1) guard-symlink (0.1.1)
guard guard
guard-compat (~> 1.1) guard-compat (~> 1.1)
hashdiff (0.3.5) hashdiff (0.3.6)
hashie (3.5.6) hashie (3.5.6)
htmlentities (4.3.4) htmlentities (4.3.4)
http (1.0.4) http (2.2.2)
addressable (~> 2.3) addressable (~> 2.3)
http-cookie (~> 1.0) http-cookie (~> 1.0)
http-form_data (~> 1.0.1) http-form_data (~> 1.0.1)
@ -190,13 +194,13 @@ GEM
ice_cube (~> 0.13) ice_cube (~> 0.13)
ice_cube (0.16.2) ice_cube (0.16.2)
inflection (1.0.0) inflection (1.0.0)
json (1.8.6) json (2.1.0)
jwt (1.5.6) jwt (1.5.6)
kgio (2.11.0) kgio (2.11.0)
koala (2.4.0) koala (3.0.0)
addressable addressable
faraday faraday
multi_json (>= 1.3.0) json (>= 1.8)
libv8 (3.16.14.19) libv8 (3.16.14.19)
listen (3.1.5) listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
@ -208,41 +212,40 @@ GEM
multi_json (~> 1.10) multi_json (~> 1.10)
loofah (2.0.3) loofah (2.0.3)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
lumberjack (1.0.10) lumberjack (1.0.12)
mail (2.6.6) mail (2.6.6)
mime-types (>= 1.16, < 4) mime-types (>= 1.16, < 4)
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 (3.1) mime-types (2.99.3)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0) mini_portile2 (2.2.0)
minitest (5.10.3) minitest (5.10.3)
multi_json (1.12.1) multi_json (1.12.1)
multi_xml (0.6.0) multi_xml (0.6.0)
multipart-post (2.0.0) multipart-post (2.0.0)
mysql2 (0.4.6) mysql2 (0.4.9)
naught (1.1.0) naught (1.1.0)
nenv (0.3.0) nenv (0.3.0)
nestful (1.1.1) nestful (1.1.1)
net-ldap (0.15.0) net-ldap (0.16.0)
netrc (0.11.0) netrc (0.11.0)
nio4r (2.1.0)
nokogiri (1.8.0) nokogiri (1.8.0)
mini_portile2 (~> 2.2.0) mini_portile2 (~> 2.2.0)
nori (2.6.0) nori (2.6.0)
notiffany (0.1.1) notiffany (0.1.1)
nenv (~> 0.1) nenv (~> 0.1)
shellany (~> 0.0) shellany (~> 0.0)
oauth (0.5.1) oauth (0.5.3)
oauth2 (1.4.0) oauth2 (1.4.0)
faraday (>= 0.8, < 0.13) faraday (>= 0.8, < 0.13)
jwt (~> 1.0) jwt (~> 1.0)
multi_json (~> 1.3) multi_json (~> 1.3)
multi_xml (~> 0.5) multi_xml (~> 0.5)
rack (>= 1.2, < 3) rack (>= 1.2, < 3)
octokit (4.4.1) octokit (4.7.0)
sawyer (~> 0.7.0, >= 0.5.3) sawyer (~> 0.8.0, >= 0.5.3)
omniauth (1.6.1) omniauth (1.6.1)
hashie (>= 3.4.6, < 3.6.0) hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3) rack (>= 1.6.2, < 3)
@ -254,12 +257,12 @@ GEM
omniauth-gitlab (1.0.2) omniauth-gitlab (1.0.2)
omniauth (~> 1.0) omniauth (~> 1.0)
omniauth-oauth2 (~> 1.0) omniauth-oauth2 (~> 1.0)
omniauth-google-oauth2 (0.5.0) omniauth-google-oauth2 (0.5.2)
jwt (~> 1.5) jwt (~> 1.5)
multi_json (~> 1.3) multi_json (~> 1.3)
omniauth (>= 1.1.1) omniauth (>= 1.1.1)
omniauth-oauth2 (>= 1.3.1) omniauth-oauth2 (>= 1.3.1)
omniauth-linkedin-oauth2 (0.1.5) omniauth-linkedin-oauth2 (0.2.5)
omniauth (~> 1.0) omniauth (~> 1.0)
omniauth-oauth2 omniauth-oauth2
omniauth-microsoft-office365 (0.0.7) omniauth-microsoft-office365 (0.0.7)
@ -271,14 +274,14 @@ GEM
omniauth-oauth2 (1.4.0) omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0) oauth2 (~> 1.0)
omniauth (~> 1.2) omniauth (~> 1.2)
omniauth-twitter (1.2.1) omniauth-twitter (1.4.0)
json (~> 1.3)
omniauth-oauth (~> 1.1) omniauth-oauth (~> 1.1)
parser (2.3.1.2) rack
parser (2.4.0.0)
ast (~> 2.2) ast (~> 2.2)
pg (0.20.0) pg (0.20.0)
pluginator (1.5.0) pluginator (1.5.0)
power_assert (0.3.1) power_assert (1.1.0)
powerpack (0.1.1) powerpack (0.1.1)
pre-commit (0.35.0) pre-commit (0.35.0)
pluginator (~> 1.5) pluginator (~> 1.5)
@ -286,68 +289,68 @@ GEM
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
slop (~> 3.4) slop (~> 3.4)
puma (3.9.1) public_suffix (3.0.0)
rack (1.6.8) puma (3.10.0)
rack (2.0.3)
rack-livereload (0.3.16) rack-livereload (0.3.16)
rack rack
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rails (4.2.9) rails (5.0.5)
actionmailer (= 4.2.9) actioncable (= 5.0.5)
actionpack (= 4.2.9) actionmailer (= 5.0.5)
actionview (= 4.2.9) actionpack (= 5.0.5)
activejob (= 4.2.9) actionview (= 5.0.5)
activemodel (= 4.2.9) activejob (= 5.0.5)
activerecord (= 4.2.9) activemodel (= 5.0.5)
activesupport (= 4.2.9) activerecord (= 5.0.5)
bundler (>= 1.3.0, < 2.0) activesupport (= 5.0.5)
railties (= 4.2.9) bundler (>= 1.3.0)
sprockets-rails railties (= 5.0.5)
rails-deprecated_sanitizer (1.0.3) sprockets-rails (>= 2.0.0)
activesupport (>= 4.2.0.alpha) rails-dom-testing (2.0.3)
rails-dom-testing (1.0.8) activesupport (>= 4.2.0)
activesupport (>= 4.2.0.beta, < 5.0) nokogiri (>= 1.6)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3) rails-html-sanitizer (1.0.3)
loofah (~> 2.0) loofah (~> 2.0)
rails-observers (0.1.5) rails-observers (0.1.5)
activemodel (>= 4.0) activemodel (>= 4.0)
railties (4.2.9) railties (5.0.5)
actionpack (= 4.2.9) actionpack (= 5.0.5)
activesupport (= 4.2.9) activesupport (= 5.0.5)
method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rainbow (2.2.2) rainbow (2.2.2)
rake rake
raindrops (0.19.0) raindrops (0.19.0)
rake (12.0.0) rake (12.0.0)
rb-fsevent (0.9.7) rb-fsevent (0.10.2)
rb-inotify (0.9.7) rb-inotify (0.9.10)
ffi (>= 0.5.0) ffi (>= 0.5.0, < 2)
ref (2.0.0) ref (2.0.0)
rest-client (2.0.0) rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0) http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0) mime-types (>= 1.16, < 3.0)
netrc (~> 0.8) netrc (~> 0.7)
retriable (2.1.0) retriable (2.1.0)
rspec-core (3.5.4) rspec-core (3.6.0)
rspec-support (~> 3.5.0) rspec-support (~> 3.6.0)
rspec-expectations (3.5.0) rspec-expectations (3.6.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0) rspec-support (~> 3.6.0)
rspec-mocks (3.5.0) rspec-mocks (3.6.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0) rspec-support (~> 3.6.0)
rspec-rails (3.5.2) rspec-rails (3.6.1)
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
railties (>= 3.0) railties (>= 3.0)
rspec-core (~> 3.5.0) rspec-core (~> 3.6.0)
rspec-expectations (~> 3.5.0) rspec-expectations (~> 3.6.0)
rspec-mocks (~> 3.5.0) rspec-mocks (~> 3.6.0)
rspec-support (~> 3.5.0) rspec-support (~> 3.6.0)
rspec-support (3.5.0) rspec-support (3.6.0)
rubocop (0.42.0) rubocop (0.42.0)
parser (>= 2.3.1.1, < 3.0) parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1) powerpack (~> 0.1)
@ -355,23 +358,26 @@ GEM
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1) unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1) ruby-progressbar (1.8.1)
ruby_dep (1.4.0) ruby_dep (1.5.0)
rubyzip (1.2.1) rubyzip (1.2.1)
safe_yaml (1.0.4) safe_yaml (1.0.4)
sass (3.4.22) sass (3.5.1)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.6) sass-rails (5.0.6)
railties (>= 4.0.0, < 6) railties (>= 4.0.0, < 6)
sass (~> 3.1) sass (~> 3.1)
sprockets (>= 2.8, < 4.0) sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0) sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3) tilt (>= 1.1, < 3)
sawyer (0.7.0) sawyer (0.8.1)
addressable (>= 2.3.5, < 2.5) addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 0.10) faraday (~> 0.8, < 1.0)
selenium-webdriver (2.53.4) selenium-webdriver (2.53.4)
childprocess (~> 0.5) childprocess (~> 0.5)
rubyzip (~> 1.0) rubyzip (~> 1.0)
websocket (~> 1.0)
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)
@ -379,10 +385,10 @@ GEM
docile (~> 1.1.0) docile (~> 1.1.0)
json (>= 1.8, < 3) json (>= 1.8, < 3)
simplecov-html (~> 0.10.0) simplecov-html (~> 0.10.0)
simplecov-html (0.10.1) simplecov-html (0.10.2)
simplecov-rcov (0.2.3) simplecov-rcov (0.2.3)
simplecov (>= 0.4.1) simplecov (>= 0.4.1)
slack-notifier (1.5.1) slack-notifier (2.3.1)
slop (3.6.0) slop (3.6.0)
spring (2.0.2) spring (2.0.2)
activesupport (>= 4.2) activesupport (>= 4.2)
@ -391,47 +397,46 @@ GEM
sprockets (3.7.1) sprockets (3.7.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
rack (> 1, < 3) rack (> 1, < 3)
sprockets-rails (3.2.0) sprockets-rails (3.2.1)
actionpack (>= 4.0) actionpack (>= 4.0)
activesupport (>= 4.0) activesupport (>= 4.0)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
sqlite3 (1.3.11) sqlite3 (1.3.13)
telegramAPI (1.2.2) telegramAPI (1.2.2)
rest-client (~> 2.0, >= 1.7.3) rest-client (~> 1.7, >= 1.7.3)
term-ansicolor (1.6.0) term-ansicolor (1.6.0)
tins (~> 1.0) tins (~> 1.0)
test-unit (3.2.1) test-unit (3.2.5)
power_assert power_assert
therubyracer (0.12.3) therubyracer (0.12.3)
libv8 (~> 3.16.14.15) libv8 (~> 3.16.14.15)
ref ref
thor (0.19.4) thor (0.19.4)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.0.5) tilt (2.0.8)
tins (1.15.0) tins (1.15.0)
twitter (5.17.0) twitter (6.1.0)
addressable (~> 2.3) addressable (~> 2.5)
buftok (~> 0.2.0) buftok (~> 0.2.0)
equalizer (= 0.0.10) equalizer (= 0.0.11)
faraday (~> 0.9.0) faraday (~> 0.11.0)
http (~> 1.0) http (~> 2.1)
http_parser.rb (~> 0.6.0) http_parser.rb (~> 0.6.0)
json (~> 1.8) memoizable (~> 0.4.2)
memoizable (~> 0.4.0) naught (~> 1.1)
naught (~> 1.0) simple_oauth (~> 0.3.1)
simple_oauth (~> 0.3.0)
tzinfo (1.2.3) tzinfo (1.2.3)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (3.0.2) uglifier (3.2.0)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.7.4) unf_ext (0.0.7.4)
unicode-display_width (1.1.1) unicode-display_width (1.3.0)
unicorn (5.3.0) unicorn (5.3.0)
kgio (~> 2.6) kgio (~> 2.6)
raindrops (~> 0.7) raindrops (~> 0.7)
valid_email2 (2.0.0) valid_email2 (2.0.1)
activemodel (>= 3.2) activemodel (>= 3.2)
mail (~> 2.5) mail (~> 2.5)
viewpoint (1.1.0) viewpoint (1.1.0)
@ -443,7 +448,9 @@ GEM
addressable (>= 2.3.6) addressable (>= 2.3.6)
crack (>= 0.3.2) crack (>= 0.3.2)
hashdiff hashdiff
websocket (1.2.3) websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
writeexcel (1.0.5) writeexcel (1.0.5)
zendesk_api (1.14.4) zendesk_api (1.14.4)
faraday (~> 0.9) faraday (~> 0.9)
@ -507,7 +514,7 @@ DEPENDENCIES
pre-commit pre-commit
puma puma
rack-livereload rack-livereload
rails (= 4.2.9) rails (= 5.0.5)
rails-observers rails-observers
rb-fsevent rb-fsevent
rspec-rails rspec-rails
@ -539,4 +546,4 @@ RUBY VERSION
ruby 2.4.1p111 ruby 2.4.1p111
BUNDLED WITH BUNDLED WITH
1.15.3 1.15.4

View file

@ -4,6 +4,7 @@ class Index extends App.ControllerSubContent
events: events:
'click .js-resetToken': 'resetToken' 'click .js-resetToken': 'resetToken'
'click .js-select': 'selectAll' 'click .js-select': 'selectAll'
'click .js-restartFailedJobs': 'restartFailedJobs'
constructor: -> constructor: ->
super super
@ -42,4 +43,14 @@ class Index extends App.ControllerSubContent
@load() @load()
) )
restartFailedJobs: (e) =>
e.preventDefault()
@ajax(
id: 'restart_failed_jobs_request'
type: 'POST'
url: "#{@apiPath}/monitoring/restart_failed_jobs"
success: (data) =>
@load()
)
App.Config.set('Monitoring', { prio: 3600, name: 'Monitoring', parent: '#system', target: '#system/monitoring', controller: Index, permission: ['admin.monitoring'] }, 'NavBarAdmin') App.Config.set('Monitoring', { prio: 3600, name: 'Monitoring', parent: '#system', target: '#system/monitoring', controller: Index, permission: ['admin.monitoring'] }, 'NavBarAdmin')

View file

@ -34,6 +34,9 @@
<% end %> <% end %>
<% end %> <% end %>
</ul> </ul>
<% if _.contains(@data.actions, 'restart_failed_jobs'): %>
<button class="btn btn--primary js-restartFailedJobs"><%- @T('Restart failed jobs') %></button>
<% end %>
</div> </div>
</div> </div>

View file

@ -1,10 +1,6 @@
module ApplicationController::Authenticates module ApplicationController::Authenticates
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do
skip_before_action :verify_authenticity_token
end
private private
def response_access_deny def response_access_deny

View file

@ -58,7 +58,7 @@ class ApplicationsController < ApplicationController
private private
def clean_params def clean_params
params_data = params.permit! #.to_h params_data = params.permit!.to_h
params_data.delete('application') params_data.delete('application')
params_data.delete('action') params_data.delete('action')
params_data.delete('controller') params_data.delete('controller')

View file

@ -13,10 +13,10 @@ module CreatesTicketArticles
raise Exceptions::UnprocessableEntity, 'Need at least article: { body: "some text" }' if !params[:body] raise Exceptions::UnprocessableEntity, 'Need at least article: { body: "some text" }' if !params[:body]
# fill default values # fill default values
if params[:type_id].empty? && params[:type].empty? if params[:type_id].blank? && params[:type].blank?
params[:type_id] = Ticket::Article::Type.lookup(name: 'note').id params[:type_id] = Ticket::Article::Type.lookup(name: 'note').id
end end
if params[:sender_id].empty? && params[:sender].empty? if params[:sender_id].blank? && params[:sender].blank?
sender = 'Customer' sender = 'Customer'
if current_user.permissions?('ticket.agent') if current_user.permissions?('ticket.agent')
sender = 'Agent' sender = 'Agent'
@ -73,7 +73,7 @@ module CreatesTicketArticles
} }
# add attachments as param # add attachments as param
if params[:attachments] if params[:attachments].present?
params[:attachments].each_with_index { |attachment, index| params[:attachments].each_with_index { |attachment, index|
# validation # validation
@ -112,7 +112,7 @@ module CreatesTicketArticles
) )
end end
return article if !form_id return article if form_id.blank?
# remove attachments from upload cache # remove attachments from upload cache
Store.remove( Store.remove(

View file

@ -9,7 +9,7 @@ class Integration::SipgateController < ApplicationController
# notify about inbound call / block inbound call # notify about inbound call / block inbound call
def in def in
if params['event'] == 'newCall' if params['event'] == 'newCall'
config_inbound = config[:inbound] || {} config_inbound = config_integration[:inbound] || {}
block_caller_ids = config_inbound[:block_caller_ids] || [] block_caller_ids = config_inbound[:block_caller_ids] || []
# check if call need to be blocked # check if call need to be blocked
@ -43,8 +43,8 @@ class Integration::SipgateController < ApplicationController
# set caller id of outbound call # set caller id of outbound call
def out def out
config_outbound = config[:outbound][:routing_table] config_outbound = config_integration[:outbound][:routing_table]
default_caller_id = config[:outbound][:default_caller_id] default_caller_id = config_integration[:outbound][:default_caller_id]
xml = Builder::XmlMarkup.new(indent: 2) xml = Builder::XmlMarkup.new(indent: 2)
xml.instruct! xml.instruct!
@ -89,14 +89,14 @@ class Integration::SipgateController < ApplicationController
xml_error('Feature is disable, please contact your admin to enable it!') xml_error('Feature is disable, please contact your admin to enable it!')
return return
end end
if !config || !config[:inbound] || !config[:outbound] if !config_integration || !config_integration[:inbound] || !config_integration[:outbound]
xml_error('Feature not configured, please contact your admin!') xml_error('Feature not configured, please contact your admin!')
return return
end end
end end
def config def config_integration
@config ||= Setting.get('sipgate_config') @config_integration ||= Setting.get('sipgate_config')
end end
def xml_error(error) def xml_error(error)

View file

@ -30,6 +30,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
token_or_permission_check token_or_permission_check
issues = [] issues = []
actions = Set.new
# channel check # channel check
last_run_tolerance = Time.zone.now - 1.hour last_run_tolerance = Time.zone.now - 1.hour
@ -81,6 +82,11 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
issues.push 'scheduler not running' issues.push 'scheduler not running'
end end
Scheduler.failed_jobs.each do |job|
issues.push "Failed to run scheduled job '#{job.name}'. Cause: #{job.error_message}"
actions.add(:restart_failed_jobs)
end
token = Setting.get('monitoring_token') token = Setting.get('monitoring_token')
if issues.empty? if issues.empty?
@ -96,8 +102,9 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
result = { result = {
healthy: false, healthy: false,
message: issues.join(';'), message: issues.join(';'),
issues: issues, issues: issues,
token: token, actions: actions,
token: token,
} }
render json: result render json: result
end end
@ -173,6 +180,14 @@ curl http://localhost/api/v1/monitoring/status?token=XXX
render json: result, status: :created render json: result, status: :created
end end
def restart_failed_jobs
access_check
Scheduler.restart_failed_jobs
render json: {}, status: :ok
end
private private
def token_or_permission_check def token_or_permission_check

View file

@ -31,15 +31,16 @@ class ObjectManagerAttributesController < ApplicationController
) )
raise Exceptions::UnprocessableEntity, 'already exists' if exists raise Exceptions::UnprocessableEntity, 'already exists' if exists
local_params = params.permit!.to_h
begin begin
object_manager_attribute = ObjectManager::Attribute.add( object_manager_attribute = ObjectManager::Attribute.add(
object: params[:object], object: local_params[:object],
name: params[:name], name: local_params[:name],
display: params[:display], display: local_params[:display],
data_type: params[:data_type], data_type: local_params[:data_type],
data_option: params[:data_option], data_option: local_params[:data_option],
active: params[:active], active: local_params[:active],
screens: params[:screens], screens: local_params[:screens],
position: 1550, position: 1550,
editable: true, editable: true,
) )
@ -52,15 +53,17 @@ class ObjectManagerAttributesController < ApplicationController
# PUT /object_manager_attributes/1 # PUT /object_manager_attributes/1
def update def update
check_params check_params
local_params = params.permit!.to_h
begin begin
object_manager_attribute = ObjectManager::Attribute.add( object_manager_attribute = ObjectManager::Attribute.add(
object: params[:object], object: local_params[:object],
name: params[:name], name: local_params[:name],
display: params[:display], display: local_params[:display],
data_type: params[:data_type], data_type: local_params[:data_type],
data_option: params[:data_option], data_option: local_params[:data_option],
active: params[:active], active: local_params[:active],
screens: params[:screens], screens: local_params[:screens],
position: 1550, position: 1550,
editable: true, editable: true,
) )

View file

@ -252,7 +252,7 @@ curl http://localhost/api/v1/organization/{id} -v -u #{login}:#{password} -H "Co
# do pagination if needed # do pagination if needed
if params[:page] && params[:per_page] if params[:page] && params[:per_page]
offset = (params[:page].to_i - 1) * params[:per_page].to_i offset = (params[:page].to_i - 1) * params[:per_page].to_i
organization_all = organization_all.slice(offset, params[:per_page].to_i) || [] organization_all = organization_all[offset, params[:per_page].to_i] || []
end end
if params[:expand] if params[:expand]

View file

@ -24,7 +24,7 @@ class SessionsController < ApplicationController
if params[:remember_me] if params[:remember_me]
expire_after = 1.year expire_after = 1.year
end end
env['rack.session.options'][:expire_after] = expire_after request.env['rack.session.options'][:expire_after] = expire_after
# set session user # set session user
current_user_set(user) current_user_set(user)

View file

@ -93,7 +93,7 @@ class TicketsController < ApplicationController
render json: { error: 'Invalid email of customer' }, status: :unprocessable_entity render json: { error: 'Invalid email of customer' }, status: :unprocessable_entity
return return
end end
customer = User.find_by(email: email) customer = User.find_by(email: email.downcase)
if !customer if !customer
role_ids = Role.signup_role_ids role_ids = Role.signup_role_ids
customer = User.create( customer = User.create(
@ -122,7 +122,7 @@ class TicketsController < ApplicationController
ticket.with_lock do ticket.with_lock do
# create tags if given # create tags if given
if params[:tags] && !params[:tags].empty? if params[:tags].present?
tags = params[:tags].split(/,/) tags = params[:tags].split(/,/)
tags.each { |tag| tags.each { |tag|
ticket.tag_add(tag) ticket.tag_add(tag)
@ -142,12 +142,13 @@ class TicketsController < ApplicationController
# child: [ticket_id1, ticket_id2, ...] # child: [ticket_id1, ticket_id2, ...]
# }, # },
# } # }
if params[:links] if params[:links].present?
raise 'Invalid link structure' if params[:links].to_h.class != Hash link = params[:links].permit!.to_h
params[:links].each { |target_object, link_types_with_object_ids| raise Exceptions::UnprocessableEntity, 'Invalid link structure' if !link.is_a? Hash
raise 'Invalid link structure (Object)' if link_types_with_object_ids.to_h.class != Hash link.each { |target_object, link_types_with_object_ids|
raise Exceptions::UnprocessableEntity, 'Invalid link structure (Object)' if !link_types_with_object_ids.is_a? Hash
link_types_with_object_ids.each { |link_type, object_ids| link_types_with_object_ids.each { |link_type, object_ids|
raise 'Invalid link structure (Object->LinkType)' if object_ids.class != Array raise Exceptions::UnprocessableEntity, 'Invalid link structure (Object->LinkType)' if !object_ids.is_a? Array
object_ids.each { |local_object_id| object_ids.each { |local_object_id|
link = Link.add( link = Link.add(
link_type: link_type, link_type: link_type,
@ -399,7 +400,7 @@ class TicketsController < ApplicationController
# do pagination if needed # do pagination if needed
if params[:page] && params[:per_page] if params[:page] && params[:per_page]
offset = (params[:page].to_i - 1) * params[:per_page].to_i offset = (params[:page].to_i - 1) * params[:per_page].to_i
tickets = tickets.slice(offset, params[:per_page].to_i) || [] tickets = tickets[offset, params[:per_page].to_i] || []
end end
if params[:expand] if params[:expand]

View file

@ -378,7 +378,7 @@ class UsersController < ApplicationController
# do pagination if needed # do pagination if needed
if params[:page] && params[:per_page] if params[:page] && params[:per_page]
offset = (params[:page].to_i - 1) * params[:per_page].to_i offset = (params[:page].to_i - 1) * params[:per_page].to_i
user_all = user_all.slice(offset, params[:per_page].to_i) || [] user_all = user_all[offset, params[:per_page].to_i] || []
end end
if params[:expand] if params[:expand]

View file

@ -293,6 +293,10 @@ returns
def association_name_to_id_convert(params) def association_name_to_id_convert(params)
if params.respond_to?(:permit!)
params = params.permit!.to_h
end
data = {} data = {}
params.each { |key, value| params.each { |key, value|
data[key.to_sym] = value data[key.to_sym] = value

View file

@ -23,8 +23,8 @@ returns
def param_cleanup(params, new_object = false) def param_cleanup(params, new_object = false)
if params.respond_to?('permit!') if params.respond_to?(:permit!)
params.permit! params = params.permit!.to_h
end end
if params.nil? if params.nil?

View file

@ -257,7 +257,7 @@ module HasGroups
end end
def destroy_group_relations def destroy_group_relations
group_through.klass.destroy_all(group_through.foreign_key => id) group_through.klass.where(group_through.foreign_key => id).destroy_all
end end
# methods defined here are going to extend the class, not the instance of it # methods defined here are going to extend the class, not the instance of it

View file

@ -223,9 +223,9 @@ returns
lookup(extract_numbers(caller_id)).each { |record| lookup(extract_numbers(caller_id)).each { |record|
if record.level == 'known' if record.level == 'known'
preferences_known[direction].push record preferences_known[direction].push record.attributes
else else
preferences_maybe[direction].push record preferences_maybe[direction].push record.attributes
end end
comment = '' comment = ''
if record.user_id if record.user_id

View file

@ -338,7 +338,7 @@ Cti::Log.process(
log.comment = comment log.comment = comment
log.save log.save
else else
raise ArgumentError, "Unknown event #{event}" raise ArgumentError, "Unknown event #{event.inspect}"
end end
end end

View file

@ -18,10 +18,10 @@ class Observer::Organization::RefObjectTouch < ActiveRecord::Observer
def ref_object_touch(record) def ref_object_touch(record)
# return if we run import mode # return if we run import mode
return if Setting.get('import_mode') return true if Setting.get('import_mode')
# featrue used for different propose, do not touch references # featrue used for different propose, do not touch references
return if User.where(organization_id: record.id).count > 100 return true if User.where(organization_id: record.id).count > 100
# touch organizations tickets # touch organizations tickets
Ticket.select('id').where(organization_id: record.id).pluck(:id).each { |ticket_id| Ticket.select('id').where(organization_id: record.id).pluck(:id).each { |ticket_id|
@ -32,11 +32,12 @@ class Observer::Organization::RefObjectTouch < ActiveRecord::Observer
} }
# touch current members # touch current members
record.member_ids.uniq.each { |user_id| User.select('id').where(organization_id: record.id).pluck(:id).each { |user_id|
user = User.find(user_id) user = User.find(user_id)
user.with_lock do user.with_lock do
user.touch user.touch
end end
} }
true
end end
end end

View file

@ -18,7 +18,7 @@ class Observer::User::RefObjectTouch < ActiveRecord::Observer
def ref_object_touch(record) def ref_object_touch(record)
# return if we run import mode # return if we run import mode
return if Setting.get('import_mode') return true if Setting.get('import_mode')
# touch old organization if changed # touch old organization if changed
member_ids = [] member_ids = []
@ -47,9 +47,9 @@ class Observer::User::RefObjectTouch < ActiveRecord::Observer
# touch old/current customer # touch old/current customer
member_ids.uniq.each { |user_id| member_ids.uniq.each { |user_id|
if user_id != record.id next if user_id == record.id
User.find(user_id).touch User.find(user_id).touch
end
} }
true
end end
end end

View file

@ -73,7 +73,7 @@ returns
query.delete! '*' query.delete! '*'
organizations = Organization.where( organizations = Organization.where(
'name LIKE ? OR note LIKE ?', "%#{query}%", "%#{query}%" 'name LIKE ? OR note LIKE ?', "%#{query}%", "%#{query}%"
).order('name').limit(limit) ).order('name').limit(limit).to_a
# if only a few organizations are found, search for names of users # if only a few organizations are found, search for names of users
if organizations.length <= 3 if organizations.length <= 3

View file

@ -42,7 +42,7 @@ class Overview < ApplicationModel
def link_name(name) def link_name(name)
local_link = name.downcase local_link = name.downcase
local_link = local_link.parameterize('_') local_link = local_link.parameterize(separator: '_')
local_link.gsub!(/\s/, '_') local_link.gsub!(/\s/, '_')
local_link.gsub!(/_+/, '_') local_link.gsub!(/_+/, '_')
local_link = URI.escape(local_link) local_link = URI.escape(local_link)

View file

@ -114,7 +114,7 @@ returns
permission_ids.push permission.id permission_ids.push permission.id
} }
next if permission_ids.empty? next if permission_ids.empty?
Role.joins(:roles_permissions).joins(:permissions).where('permissions_roles.permission_id IN (?) AND roles.active = ? AND permissions.active = ?', permission_ids, true, true).uniq().each { |role| Role.joins(:roles_permissions).joins(:permissions).where('permissions_roles.permission_id IN (?) AND roles.active = ? AND permissions.active = ?', permission_ids, true, true).distinct().each { |role|
roles.push role roles.push role
} }
} }

View file

@ -169,9 +169,13 @@ class Scheduler < ApplicationModel
end end
def self._start_job(job, try_count = 0, try_run_time = Time.zone.now) def self._start_job(job, try_count = 0, try_run_time = Time.zone.now)
job.last_run = Time.zone.now job.update(
job.pid = Thread.current.object_id last_run: Time.zone.now,
job.save pid: Thread.current.object_id,
status: 'ok',
error_message: '',
)
logger.info "execute #{job.method} (try_count #{try_count})..." logger.info "execute #{job.method} (try_count #{try_count})..."
eval job.method() # rubocop:disable Lint/Eval eval job.method() # rubocop:disable Lint/Eval
rescue => e rescue => e
@ -197,7 +201,15 @@ class Scheduler < ApplicationModel
if try_run_max > try_count if try_run_max > try_count
_start_job(job, try_count, try_run_time) _start_job(job, try_count, try_run_time)
else else
raise "STOP thread for #{job.method} after #{try_count} tries (#{e.inspect})" @@jobs_started[ job.id ] = false
error = "Failed to run #{job.method} after #{try_count} tries #{e.inspect}"
logger.error error
job.update(
error_message: error,
status: 'error',
active: false,
)
end end
end end
@ -255,4 +267,28 @@ class Scheduler < ApplicationModel
end end
# This function returns a list of failed jobs
#
# @example
# Scheduler.failed_jobs
#
# return [Array]
def self.failed_jobs
where(status: 'error', active: false)
end
# This function restarts failed jobs to retry them
#
# @example
# Scheduler.restart_failed_jobs
#
# return [true]
def self.restart_failed_jobs
failed_jobs.each do |job|
job.update(active: true)
end
true
end
end end

View file

@ -13,16 +13,15 @@ class Taskbar < ApplicationModel
attr_accessor :local_update attr_accessor :local_update
def state_changed? def state_changed?
return false if !state return false if state.blank?
return false if state.empty?
state.each { |_key, value| state.each { |_key, value|
if value.class == Hash || value.class == ActiveSupport::HashWithIndifferentAccess if value.is_a? Hash
value.each { |_key1, value1| value.each { |_key1, value1|
next if value1 && value1.empty? next if value1.blank?
return true return true
} }
else else
next if value && value.empty? next if value.blank?
return true return true
end end
} }

View file

@ -505,7 +505,7 @@ returns
permission_ids.push permission.id permission_ids.push permission.id
} }
next if permission_ids.empty? next if permission_ids.empty?
Role.joins(:roles_permissions).joins(:permissions).where('permissions_roles.permission_id IN (?) AND roles.active = ? AND permissions.active = ?', permission_ids, true, true).uniq().pluck(:id).each { |role_id| Role.joins(:roles_permissions).joins(:permissions).where('permissions_roles.permission_id IN (?) AND roles.active = ? AND permissions.active = ?', permission_ids, true, true).distinct().pluck(:id).each { |role_id|
role_ids.push role_id role_ids.push role_id
} }
total_role_ids.push role_ids total_role_ids.push role_ids

View file

@ -12,11 +12,9 @@ module Zammad
# Application configuration should go into files in config/initializers # Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
# Custom directories with classes and modules you want to be autoloadable. # Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{config.root}/lib) config.autoload_paths += %W(#{config.root}/lib)
config.eager_load_paths += %W(#{config.root}/lib)
# Activate observers that should always be running. # Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer # config.active_record.observers = :cacher, :garbage_collector, :forum_observer

View file

@ -22,7 +22,7 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier

View file

@ -13,8 +13,8 @@ Rails.application.configure do
config.eager_load = false config.eager_load = false
# Configure static file server for tests with Cache-Control for performance. # Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true config.public_file_server.enabled = true
config.static_cache_control = 'public, max-age=3600' config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
# Show full error reports and disable caching. # Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true

View file

@ -1,8 +1,9 @@
Zammad::Application.routes.draw do Zammad::Application.routes.draw do
api_path = Rails.configuration.api_path api_path = Rails.configuration.api_path
match api_path + '/monitoring/health_check', to: 'monitoring#health_check', via: :get match api_path + '/monitoring/health_check', to: 'monitoring#health_check', via: :get
match api_path + '/monitoring/status', to: 'monitoring#status', via: :get match api_path + '/monitoring/status', to: 'monitoring#status', via: :get
match api_path + '/monitoring/token', to: 'monitoring#token', via: :post match api_path + '/monitoring/token', to: 'monitoring#token', via: :post
match api_path + '/monitoring/restart_failed_jobs', to: 'monitoring#restart_failed_jobs', via: :post
end end

View file

@ -1,4 +1,4 @@
class CreateBase < ActiveRecord::Migration class CreateBase < ActiveRecord::Migration[4.2]
def up def up
# clear old caches to start from scratch # clear old caches to start from scratch
@ -514,6 +514,8 @@ class CreateBase < ActiveRecord::Migration
t.integer :prio, null: false t.integer :prio, null: false
t.string :pid, limit: 250, null: true t.string :pid, limit: 250, null: true
t.string :note, limit: 250, null: true t.string :note, limit: 250, null: true
t.string :error_message, null: true
t.string :status, null: true
t.boolean :active, null: false, default: false t.boolean :active, null: false, default: false
t.integer :updated_by_id, null: false t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false t.integer :created_by_id, null: false

View file

@ -1,4 +1,4 @@
class CreateTicket < ActiveRecord::Migration class CreateTicket < ActiveRecord::Migration[4.2]
def up def up
create_table :ticket_state_types do |t| create_table :ticket_state_types do |t|
t.column :name, :string, limit: 250, null: false t.column :name, :string, limit: 250, null: false

View file

@ -1,4 +1,4 @@
class CreateNetwork < ActiveRecord::Migration class CreateNetwork < ActiveRecord::Migration[4.2]
def up def up
create_table :networks do |t| create_table :networks do |t|
t.column :name, :string, limit: 100, null: false t.column :name, :string, limit: 100, null: false

View file

@ -1,4 +1,4 @@
class UpdateTimestamps < ActiveRecord::Migration class UpdateTimestamps < ActiveRecord::Migration[4.2]
def up def up
# get all models # get all models
Models.all.each { |_model, value| Models.all.each { |_model, value|

View file

@ -1,4 +1,4 @@
class ObjectManagerUpdateUser < ActiveRecord::Migration class ObjectManagerUpdateUser < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class PermissionActive < ActiveRecord::Migration class PermissionActive < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')

View file

@ -1,4 +1,4 @@
class CreateDoorkeeperTables < ActiveRecord::Migration class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
def change def change
create_table :oauth_applications do |t| create_table :oauth_applications do |t|
t.string :name, null: false t.string :name, null: false

View file

@ -1,4 +1,4 @@
class OrganizationDomainBasedAssignment < ActiveRecord::Migration class OrganizationDomainBasedAssignment < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')

View file

@ -1,4 +1,4 @@
class JobUnableToCreateIssue432 < ActiveRecord::Migration class JobUnableToCreateIssue432 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')

View file

@ -1,4 +1,4 @@
class TicketNumberGeneratorIssue427 < ActiveRecord::Migration class TicketNumberGeneratorIssue427 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')

View file

@ -1,4 +1,4 @@
class StoreConfigNameUpdateIssue428 < ActiveRecord::Migration class StoreConfigNameUpdateIssue428 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')

View file

@ -1,4 +1,4 @@
class MonitoringIssue453 < ActiveRecord::Migration class MonitoringIssue453 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')

View file

@ -1,4 +1,4 @@
class AddTaskbarMeta < ActiveRecord::Migration class AddTaskbarMeta < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')

View file

@ -1,4 +1,4 @@
class ObjectManagerAttributeCreateMiddle < ActiveRecord::Migration class ObjectManagerAttributeCreateMiddle < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')

View file

@ -1,4 +1,4 @@
class SlackGroupConfigIssue587 < ActiveRecord::Migration class SlackGroupConfigIssue587 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class AddTicketTimeAccounting373 < ActiveRecord::Migration class AddTicketTimeAccounting373 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class FixedTypos622 < ActiveRecord::Migration class FixedTypos622 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class UnableToEnableTimeAccounting633 < ActiveRecord::Migration class UnableToEnableTimeAccounting633 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class LoginEmailLength650 < ActiveRecord::Migration class LoginEmailLength650 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class UiTicketZoomArticleNewInternal < ActiveRecord::Migration class UiTicketZoomArticleNewInternal < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class FixedTranslation < ActiveRecord::Migration class FixedTranslation < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class ApplicationSecretSetting < ActiveRecord::Migration class ApplicationSecretSetting < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class FollowUpPossibleCheck643 < ActiveRecord::Migration class FollowUpPossibleCheck643 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class RemoveLastLoginFromHistory722 < ActiveRecord::Migration class RemoveLastLoginFromHistory722 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class DoNotImportOnwNotifications731 < ActiveRecord::Migration class DoNotImportOnwNotifications731 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class TicketStatePriorityDefaults < ActiveRecord::Migration class TicketStatePriorityDefaults < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class ReloadOnlineBrowserAfterCorsCsrfChanges < ActiveRecord::Migration class ReloadOnlineBrowserAfterCorsCsrfChanges < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class TelegramSupport < ActiveRecord::Migration class TelegramSupport < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class FixedTranslation2 < ActiveRecord::Migration class FixedTranslation2 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class FixedAdminUserPermission920 < ActiveRecord::Migration class FixedAdminUserPermission920 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class ValidateAgentLimit < ActiveRecord::Migration class ValidateAgentLimit < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup
return if !Setting.find_by(name: 'system_init_done') return if !Setting.find_by(name: 'system_init_done')

View file

@ -1,4 +1,4 @@
class LdapSupport < ActiveRecord::Migration class LdapSupport < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class OverviewRoleIds < ActiveRecord::Migration class OverviewRoleIds < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class ChatIncreaseMessageSize < ActiveRecord::Migration class ChatIncreaseMessageSize < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class PrettyDateOptionsAdded < ActiveRecord::Migration class PrettyDateOptionsAdded < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class AddOriginById < ActiveRecord::Migration class AddOriginById < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class AddReplyTo < ActiveRecord::Migration class AddReplyTo < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class FollowUpMerged < ActiveRecord::Migration class FollowUpMerged < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -0,0 +1,12 @@
class SchedulerStatus < ActiveRecord::Migration[4.2]
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
change_table :schedulers do |t|
t.string :error_message, null: true
t.string :status, null: true
end
end
end

View file

@ -1,4 +1,4 @@
class TriggerRecipientUpdate < ActiveRecord::Migration class TriggerRecipientUpdate < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class ReplyToSenderFeature < ActiveRecord::Migration class ReplyToSenderFeature < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class SettingDeliveryPermanentFailed < ActiveRecord::Migration class SettingDeliveryPermanentFailed < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class LdapMultiGroupMapping < ActiveRecord::Migration class LdapMultiGroupMapping < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class ForeignKeys < ActiveRecord::Migration class ForeignKeys < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
def change def change

View file

@ -1,4 +1,4 @@
class EnhancedPermissions < ActiveRecord::Migration class EnhancedPermissions < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class TreeSelect < ActiveRecord::Migration class TreeSelect < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class LocaleAddDirection < ActiveRecord::Migration class LocaleAddDirection < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class FormGroupSelection < ActiveRecord::Migration class FormGroupSelection < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class ExchangeIntegration < ActiveRecord::Migration class ExchangeIntegration < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class OmniauthOffice365Setting < ActiveRecord::Migration class OmniauthOffice365Setting < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class TicketZoomSetting2 < ActiveRecord::Migration class TicketZoomSetting2 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class ObjectManagerUserEmailOptional < ActiveRecord::Migration class ObjectManagerUserEmailOptional < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class UserEmailMultipleUse < ActiveRecord::Migration class UserEmailMultipleUse < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class CleanupCtiLog < ActiveRecord::Migration class CleanupCtiLog < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class FixedTwitterTicketArticlePreferences3 < ActiveRecord::Migration class FixedTwitterTicketArticlePreferences3 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class SettingProxy < ActiveRecord::Migration class SettingProxy < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class IdoitSupport < ActiveRecord::Migration class IdoitSupport < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class CheckMkIntegration < ActiveRecord::Migration class CheckMkIntegration < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class AgendBasedSenderIssue1351 < ActiveRecord::Migration class AgendBasedSenderIssue1351 < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class OutOfOffice < ActiveRecord::Migration class OutOfOffice < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -1,4 +1,4 @@
class LastOwnerUpdate < ActiveRecord::Migration class LastOwnerUpdate < ActiveRecord::Migration[4.2]
def up def up
# return if it's a new setup # return if it's a new setup

View file

@ -0,0 +1,47 @@
# Rails dropped the class
# ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::MysqlDateTime
# via: https://github.com/rails/rails/commit/f1a0fa9e19b7e4ccaea191fc6cf0613880222ee7
# which we use in stored Cti::Log instance preferences.
# Since we don't need the instances but just an Hash we have to:
# - create a dummy class
# - loop over all instances
# - deserialize them in the preferences
# - replace them in the preferences with the Hash version
# create a dummy class
module ActiveRecord
module ConnectionAdapters
class AbstractMysqlAdapter
class MysqlDateTime < Type::DateTime
end
end
end
end
class CtiLogPreferencesMigration < ActiveRecord::Migration[5.0]
def change
# correct all entries
Cti::Log.all.each do |item|
next if !item.preferences
next if item.preferences.blank?
# check from and to keys which hold the instances
%w(from to).each do |direction|
next if item.preferences[direction].blank?
# loop over all instances and covert them
# to an Hash via .attributes
updated = item.preferences[direction].each_with_object([]) do |caller_id, new_direction|
new_direction.push(caller_id.attributes)
end
# overwrite the old key with the converted data
item.preferences[direction] = updated
end
# update entry
item.save!
end
end
end

View file

@ -26,6 +26,7 @@ $(function() {
tag: 'input', tag: 'input',
type: 'text', type: 'text',
placeholder: 'Your Name', placeholder: 'Your Name',
defaultValue: '',
}, },
{ {
display: 'Email', display: 'Email',
@ -33,12 +34,14 @@ $(function() {
tag: 'input', tag: 'input',
type: 'email', type: 'email',
placeholder: 'Your Email', placeholder: 'Your Email',
defaultValue: function () {return User.email;},
}, },
{ {
display: 'Message', display: 'Message',
name: 'body', name: 'body',
tag: 'textarea', tag: 'textarea',
placeholder: 'Your Message...', placeholder: 'Your Message...',
defaultValue: '',
rows: 7, rows: 7,
}, },
{ {
@ -74,6 +77,7 @@ $(function() {
tag: 'input', tag: 'input',
type: 'text', type: 'text',
placeholder: 'Your Name', placeholder: 'Your Name',
defaultValue: '',
}, },
{ {
display: 'Email', display: 'Email',
@ -81,12 +85,14 @@ $(function() {
tag: 'input', tag: 'input',
type: 'email', type: 'email',
placeholder: 'Your Email', placeholder: 'Your Email',
defaultValue: '',
}, },
{ {
display: 'Message', display: 'Message',
name: 'body', name: 'body',
tag: 'textarea', tag: 'textarea',
placeholder: 'Your Message...', placeholder: 'Your Message...',
defaultValue: '',
rows: 7, rows: 7,
}, },
], ],
@ -360,13 +366,14 @@ $(function() {
$form.append('<h2>' + this.options.messageTitle + '</h2>') $form.append('<h2>' + this.options.messageTitle + '</h2>')
} }
$.each(this.options.attributes, function(index, value) { $.each(this.options.attributes, function(index, value) {
var item = $('<div class="form-group"><label>' + _this.T(value.display) + '</label></div>') var item = $('<div class="form-group"><label>' + _this.T(value.display) + '</label></div>');
var defaultValue = (typeof value.defaultValue === 'function') ? value.defaultValue() : value.defaultValue;
for (var i=0; i < (value.repeat ? value.repeat : 1); i++) { for (var i=0; i < (value.repeat ? value.repeat : 1); i++) {
if (value.tag == 'input') { if (value.tag == 'input') {
item.append('<input class="form-control" name="' + value.name + '" type="' + value.type + '" placeholder="' + _this.T(value.placeholder) + '">') item.append('<input class="form-control" name="' + value.name + '" type="' + value.type + '" placeholder="' + _this.T(value.placeholder) + '" value="' + (defaultValue || '') + '">')
} }
else if (value.tag == 'textarea') { else if (value.tag == 'textarea') {
item.append('<textarea class="form-control" name="' + value.name + '" placeholder="' + _this.T(value.placeholder) + '" rows="' + value.rows + '"></textarea>') item.append('<textarea class="form-control" name="' + value.name + '" placeholder="' + _this.T(value.placeholder) + '" rows="' + value.rows + '">' + (defaultValue || '') + '</textarea>')
} }
} }
$form.append(item) $form.append(item)

View file

@ -0,0 +1,25 @@
FactoryGirl.define do
sequence :test_scheduler_name do |n|
"Testscheduler#{n}"
end
end
FactoryGirl.define do
factory :scheduler do
name { generate(:test_scheduler_name) }
last_run { Time.zone.now }
pid 1337
prio 1
status 'ok'
active true
period { 10.minutes }
running false
note 'test'
updated_by_id 1
created_by_id 1
created_at 1
updated_at 1
add_attribute(:method) { 'test' }
end
end

View file

@ -26,6 +26,45 @@ RSpec.describe Scheduler do
SpecSpace.send(:remove_const, :DelayedJobBackend) SpecSpace.send(:remove_const, :DelayedJobBackend)
end end
describe '.failed_jobs' do
it 'does list failed jobs' do
job = create(:scheduler, status: 'error', active: false)
failed_list = described_class.failed_jobs
expect(failed_list).to be_present
expect(failed_list).to include(job)
end
end
describe '.restart_failed_jobs' do
it 'does restart failed jobs' do
job = create(:scheduler, status: 'error', active: false)
described_class.restart_failed_jobs
job.reload
expect(job.active).to be true
end
end
describe '._start_job' do
it 'sets error status/message for failed jobs' do
job = create(:scheduler)
described_class._start_job(job)
expect(job.status).to eq 'error'
expect(job.active).to be false
expect(job.error_message).to be_present
end
it 'executes job that is expected to succeed' do
expect(Setting).to receive(:reload)
job = create(:scheduler, method: 'Setting.reload')
described_class._start_job(job)
expect(job.status).to eq 'ok'
end
end
describe '.cleanup' do describe '.cleanup' do
it 'gets called by .threads' do it 'gets called by .threads' do

View file

@ -55,7 +55,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
admin_credentials = ActionController::HttpAuthentication::Basic.encode_credentials('api-admin@example.com', 'adminpw') admin_credentials = ActionController::HttpAuthentication::Basic.encode_credentials('api-admin@example.com', 'adminpw')
Setting.set('api_password_access', false) Setting.set('api_password_access', false)
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(401) assert_response(401)
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -63,7 +63,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
assert_equal('API password access disabled!', result['error']) assert_equal('API password access disabled!', result['error'])
Setting.set('api_password_access', true) Setting.set('api_password_access', true)
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
assert_equal('*', @response.header['Access-Control-Allow-Origin']) assert_equal('*', @response.header['Access-Control-Allow-Origin'])
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -76,7 +76,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
agent_credentials = ActionController::HttpAuthentication::Basic.encode_credentials('api-agent@example.com', 'agentpw') agent_credentials = ActionController::HttpAuthentication::Basic.encode_credentials('api-agent@example.com', 'agentpw')
Setting.set('api_password_access', false) Setting.set('api_password_access', false)
get '/api/v1/tickets', {}, @headers.merge('Authorization' => agent_credentials) get '/api/v1/tickets', params: {}, headers: @headers.merge('Authorization' => agent_credentials)
assert_response(401) assert_response(401)
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -84,7 +84,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
assert_equal('API password access disabled!', result['error']) assert_equal('API password access disabled!', result['error'])
Setting.set('api_password_access', true) Setting.set('api_password_access', true)
get '/api/v1/tickets', {}, @headers.merge('Authorization' => agent_credentials) get '/api/v1/tickets', params: {}, headers: @headers.merge('Authorization' => agent_credentials)
assert_response(200) assert_response(200)
assert_equal('*', @response.header['Access-Control-Allow-Origin']) assert_equal('*', @response.header['Access-Control-Allow-Origin'])
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -97,7 +97,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
customer_credentials = ActionController::HttpAuthentication::Basic.encode_credentials('api-customer1@example.com', 'customer1pw') customer_credentials = ActionController::HttpAuthentication::Basic.encode_credentials('api-customer1@example.com', 'customer1pw')
Setting.set('api_password_access', false) Setting.set('api_password_access', false)
get '/api/v1/tickets', {}, @headers.merge('Authorization' => customer_credentials) get '/api/v1/tickets', params: {}, headers: @headers.merge('Authorization' => customer_credentials)
assert_response(401) assert_response(401)
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -105,7 +105,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
assert_equal('API password access disabled!', result['error']) assert_equal('API password access disabled!', result['error'])
Setting.set('api_password_access', true) Setting.set('api_password_access', true)
get '/api/v1/tickets', {}, @headers.merge('Authorization' => customer_credentials) get '/api/v1/tickets', params: {}, headers: @headers.merge('Authorization' => customer_credentials)
assert_response(200) assert_response(200)
assert_equal('*', @response.header['Access-Control-Allow-Origin']) assert_equal('*', @response.header['Access-Control-Allow-Origin'])
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -126,7 +126,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
admin_credentials = "Token token=#{admin_token.name}" admin_credentials = "Token token=#{admin_token.name}"
Setting.set('api_token_access', false) Setting.set('api_token_access', false)
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(401) assert_response(401)
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -134,7 +134,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
assert_equal('API token access disabled!', result['error']) assert_equal('API token access disabled!', result['error'])
Setting.set('api_token_access', true) Setting.set('api_token_access', true)
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
assert_equal('*', @response.header['Access-Control-Allow-Origin']) assert_equal('*', @response.header['Access-Control-Allow-Origin'])
@ -145,7 +145,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
admin_token.preferences[:permission] = ['admin.session_not_existing'] admin_token.preferences[:permission] = ['admin.session_not_existing']
admin_token.save! admin_token.save!
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -154,7 +154,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
admin_token.preferences[:permission] = [] admin_token.preferences[:permission] = []
admin_token.save! admin_token.save!
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -163,7 +163,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
@admin.active = false @admin.active = false
@admin.save! @admin.save!
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -172,7 +172,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
admin_token.preferences[:permission] = ['admin.session'] admin_token.preferences[:permission] = ['admin.session']
admin_token.save! admin_token.save!
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -181,13 +181,13 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
@admin.active = true @admin.active = true
@admin.save! @admin.save!
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
assert(result) assert(result)
get '/api/v1/roles', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/roles', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -196,7 +196,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
admin_token.preferences[:permission] = ['admin.session_not_existing', 'admin.role'] admin_token.preferences[:permission] = ['admin.session_not_existing', 'admin.role']
admin_token.save! admin_token.save!
get '/api/v1/roles', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/roles', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Array, result.class) assert_equal(Array, result.class)
@ -205,14 +205,14 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
admin_token.preferences[:permission] = ['ticket.agent'] admin_token.preferences[:permission] = ['ticket.agent']
admin_token.save! admin_token.save!
get '/api/v1/organizations', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/organizations', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Array, result.class) assert_equal(Array, result.class)
assert(result) assert(result)
name = "some org name #{rand(999_999_999)}" name = "some org name #{rand(999_999_999)}"
post '/api/v1/organizations', { name: name }.to_json, @headers.merge('Authorization' => admin_credentials) post '/api/v1/organizations', params: { name: name }.to_json, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(201) assert_response(201)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -220,7 +220,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
assert(result) assert(result)
name = "some org name #{rand(999_999_999)} - 2" name = "some org name #{rand(999_999_999)} - 2"
put "/api/v1/organizations/#{result['id']}", { name: name }.to_json, @headers.merge('Authorization' => admin_credentials) put "/api/v1/organizations/#{result['id']}", params: { name: name }.to_json, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -230,14 +230,14 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
admin_token.preferences[:permission] = ['admin.organization'] admin_token.preferences[:permission] = ['admin.organization']
admin_token.save! admin_token.save!
get '/api/v1/organizations', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/organizations', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Array, result.class) assert_equal(Array, result.class)
assert(result) assert(result)
name = "some org name #{rand(999_999_999)}" name = "some org name #{rand(999_999_999)}"
post '/api/v1/organizations', { name: name }.to_json, @headers.merge('Authorization' => admin_credentials) post '/api/v1/organizations', params: { name: name }.to_json, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(201) assert_response(201)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -245,7 +245,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
assert(result) assert(result)
name = "some org name #{rand(999_999_999)} - 2" name = "some org name #{rand(999_999_999)} - 2"
put "/api/v1/organizations/#{result['id']}", { name: name }.to_json, @headers.merge('Authorization' => admin_credentials) put "/api/v1/organizations/#{result['id']}", params: { name: name }.to_json, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -255,14 +255,14 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
admin_token.preferences[:permission] = ['admin'] admin_token.preferences[:permission] = ['admin']
admin_token.save! admin_token.save!
get '/api/v1/organizations', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/organizations', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Array, result.class) assert_equal(Array, result.class)
assert(result) assert(result)
name = "some org name #{rand(999_999_999)}" name = "some org name #{rand(999_999_999)}"
post '/api/v1/organizations', { name: name }.to_json, @headers.merge('Authorization' => admin_credentials) post '/api/v1/organizations', params: { name: name }.to_json, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(201) assert_response(201)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -270,7 +270,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
assert(result) assert(result)
name = "some org name #{rand(999_999_999)} - 2" name = "some org name #{rand(999_999_999)} - 2"
put "/api/v1/organizations/#{result['id']}", { name: name }.to_json, @headers.merge('Authorization' => admin_credentials) put "/api/v1/organizations/#{result['id']}", params: { name: name }.to_json, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -289,7 +289,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
agent_credentials = "Token token=#{agent_token.name}" agent_credentials = "Token token=#{agent_token.name}"
Setting.set('api_token_access', false) Setting.set('api_token_access', false)
get '/api/v1/tickets', {}, @headers.merge('Authorization' => agent_credentials) get '/api/v1/tickets', params: {}, headers: @headers.merge('Authorization' => agent_credentials)
assert_response(401) assert_response(401)
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -297,21 +297,21 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
assert_equal('API token access disabled!', result['error']) assert_equal('API token access disabled!', result['error'])
Setting.set('api_token_access', true) Setting.set('api_token_access', true)
get '/api/v1/tickets', {}, @headers.merge('Authorization' => agent_credentials) get '/api/v1/tickets', params: {}, headers: @headers.merge('Authorization' => agent_credentials)
assert_response(200) assert_response(200)
assert_equal('*', @response.header['Access-Control-Allow-Origin']) assert_equal('*', @response.header['Access-Control-Allow-Origin'])
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Array, result.class) assert_equal(Array, result.class)
assert(result) assert(result)
get '/api/v1/organizations', {}, @headers.merge('Authorization' => agent_credentials) get '/api/v1/organizations', params: {}, headers: @headers.merge('Authorization' => agent_credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Array, result.class) assert_equal(Array, result.class)
assert(result) assert(result)
name = "some org name #{rand(999_999_999)}" name = "some org name #{rand(999_999_999)}"
post '/api/v1/organizations', { name: name }.to_json, @headers.merge('Authorization' => agent_credentials) post '/api/v1/organizations', params: { name: name }.to_json, headers: @headers.merge('Authorization' => agent_credentials)
assert_response(401) assert_response(401)
end end
@ -326,7 +326,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
customer_credentials = "Token token=#{customer_token.name}" customer_credentials = "Token token=#{customer_token.name}"
Setting.set('api_token_access', false) Setting.set('api_token_access', false)
get '/api/v1/tickets', {}, @headers.merge('Authorization' => customer_credentials) get '/api/v1/tickets', params: {}, headers: @headers.merge('Authorization' => customer_credentials)
assert_response(401) assert_response(401)
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -334,21 +334,21 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
assert_equal('API token access disabled!', result['error']) assert_equal('API token access disabled!', result['error'])
Setting.set('api_token_access', true) Setting.set('api_token_access', true)
get '/api/v1/tickets', {}, @headers.merge('Authorization' => customer_credentials) get '/api/v1/tickets', params: {}, headers: @headers.merge('Authorization' => customer_credentials)
assert_equal('*', @response.header['Access-Control-Allow-Origin']) assert_equal('*', @response.header['Access-Control-Allow-Origin'])
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Array, result.class) assert_equal(Array, result.class)
assert(result) assert(result)
get '/api/v1/organizations', {}, @headers.merge('Authorization' => customer_credentials) get '/api/v1/organizations', params: {}, headers: @headers.merge('Authorization' => customer_credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Array, result.class) assert_equal(Array, result.class)
assert(result) assert(result)
name = "some org name #{rand(999_999_999)}" name = "some org name #{rand(999_999_999)}"
post '/api/v1/organizations', { name: name }.to_json, @headers.merge('Authorization' => customer_credentials) post '/api/v1/organizations', params: { name: name }.to_json, headers: @headers.merge('Authorization' => customer_credentials)
assert_response(401) assert_response(401)
end end
@ -365,7 +365,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
@admin.save! @admin.save!
Setting.set('api_token_access', false) Setting.set('api_token_access', false)
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(401) assert_response(401)
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -373,7 +373,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
assert_equal('API token access disabled!', result['error']) assert_equal('API token access disabled!', result['error'])
Setting.set('api_token_access', true) Setting.set('api_token_access', true)
get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(401) assert_response(401)
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -393,7 +393,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
) )
admin_credentials = "Token token=#{admin_token.name}" admin_credentials = "Token token=#{admin_token.name}"
get '/api/v1/tickets', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/tickets', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(401) assert_response(401)
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -416,7 +416,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
) )
admin_credentials = "Token token=#{admin_token.name}" admin_credentials = "Token token=#{admin_token.name}"
get '/api/v1/tickets', {}, @headers.merge('Authorization' => admin_credentials) get '/api/v1/tickets', params: {}, headers: @headers.merge('Authorization' => admin_credentials)
assert_response(200) assert_response(200)
assert_equal('*', @response.header['Access-Control-Allow-Origin']) assert_equal('*', @response.header['Access-Control-Allow-Origin'])
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -429,11 +429,11 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
test 'session auth - admin' do test 'session auth - admin' do
post '/api/v1/signin', { username: 'api-admin@example.com', password: 'adminpw', fingerprint: '123456789' } post '/api/v1/signin', params: { username: 'api-admin@example.com', password: 'adminpw', fingerprint: '123456789' }
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
assert_response(201) assert_response(201)
get '/api/v1/sessions', {} get '/api/v1/sessions', params: {}
assert_response(200) assert_response(200)
assert_not(@response.header.key?('Access-Control-Allow-Origin')) assert_not(@response.header.key?('Access-Control-Allow-Origin'))
result = JSON.parse(@response.body) result = JSON.parse(@response.body)

View file

@ -8,49 +8,49 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
@headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' } @headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' }
# 404 # 404
get '/not_existing_url', {}, @headers get '/not_existing_url', params: {}, headers: @headers
assert_response(404) assert_response(404)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
assert(result['error'], 'No route matches [GET] /not_existing_url') assert(result['error'], 'No route matches [GET] /not_existing_url')
# 401 # 401
get '/api/v1/organizations', {}, @headers get '/api/v1/organizations', params: {}, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
assert(result['error'], 'authentication failed') assert(result['error'], 'authentication failed')
# 422 # 422
get '/tests/unprocessable_entity', {}, @headers get '/tests/unprocessable_entity', params: {}, headers: @headers
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
assert(result['error'], 'some error message') assert(result['error'], 'some error message')
# 401 # 401
get '/tests/not_authorized', {}, @headers get '/tests/not_authorized', params: {}, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
assert(result['error'], 'some error message') assert(result['error'], 'some error message')
# 401 # 401
get '/tests/ar_not_found', {}, @headers get '/tests/ar_not_found', params: {}, headers: @headers
assert_response(404) assert_response(404)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
assert(result['error'], 'some error message') assert(result['error'], 'some error message')
# 500 # 500
get '/tests/standard_error', {}, @headers get '/tests/standard_error', params: {}, headers: @headers
assert_response(500) assert_response(500)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
assert(result['error'], 'some error message') assert(result['error'], 'some error message')
# 422 # 422
get '/tests/argument_error', {}, @headers get '/tests/argument_error', params: {}, headers: @headers
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -61,7 +61,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
test 'html requests' do test 'html requests' do
# 404 # 404
get '/not_existing_url', {}, @headers get '/not_existing_url', params: {}, headers: @headers
assert_response(404) assert_response(404)
assert_match(/<html/, @response.body) assert_match(/<html/, @response.body)
assert_match(%r{<title>404: Not Found</title>}, @response.body) assert_match(%r{<title>404: Not Found</title>}, @response.body)
@ -69,7 +69,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(%r{No route matches \[GET\] /not_existing_url}, @response.body) assert_match(%r{No route matches \[GET\] /not_existing_url}, @response.body)
# 401 # 401
get '/api/v1/organizations', {}, @headers get '/api/v1/organizations', params: {}, headers: @headers
assert_response(401) assert_response(401)
assert_match(/<html/, @response.body) assert_match(/<html/, @response.body)
assert_match(%r{<title>401: Unauthorized</title>}, @response.body) assert_match(%r{<title>401: Unauthorized</title>}, @response.body)
@ -77,7 +77,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(/authentication failed/, @response.body) assert_match(/authentication failed/, @response.body)
# 422 # 422
get '/tests/unprocessable_entity', {}, @headers get '/tests/unprocessable_entity', params: {}, headers: @headers
assert_response(422) assert_response(422)
assert_match(/<html/, @response.body) assert_match(/<html/, @response.body)
assert_match(%r{<title>422: Unprocessable Entity</title>}, @response.body) assert_match(%r{<title>422: Unprocessable Entity</title>}, @response.body)
@ -85,7 +85,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(/some error message/, @response.body) assert_match(/some error message/, @response.body)
# 401 # 401
get '/tests/not_authorized', {}, @headers get '/tests/not_authorized', params: {}, headers: @headers
assert_response(401) assert_response(401)
assert_match(/<html/, @response.body) assert_match(/<html/, @response.body)
assert_match(%r{<title>401: Unauthorized</title>}, @response.body) assert_match(%r{<title>401: Unauthorized</title>}, @response.body)
@ -93,7 +93,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(/some error message/, @response.body) assert_match(/some error message/, @response.body)
# 401 # 401
get '/tests/ar_not_found', {}, @headers get '/tests/ar_not_found', params: {}, headers: @headers
assert_response(404) assert_response(404)
assert_match(/<html/, @response.body) assert_match(/<html/, @response.body)
assert_match(%r{<title>404: Not Found</title>}, @response.body) assert_match(%r{<title>404: Not Found</title>}, @response.body)
@ -101,7 +101,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(/some error message/, @response.body) assert_match(/some error message/, @response.body)
# 500 # 500
get '/tests/standard_error', {}, @headers get '/tests/standard_error', params: {}, headers: @headers
assert_response(500) assert_response(500)
assert_match(/<html/, @response.body) assert_match(/<html/, @response.body)
assert_match(%r{<title>500: Something went wrong</title>}, @response.body) assert_match(%r{<title>500: Something went wrong</title>}, @response.body)
@ -109,7 +109,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(/some error message/, @response.body) assert_match(/some error message/, @response.body)
# 422 # 422
get '/tests/argument_error', {}, @headers get '/tests/argument_error', params: {}, headers: @headers
assert_response(422) assert_response(422)
assert_match(/<html/, @response.body) assert_match(/<html/, @response.body)
assert_match(%r{<title>422: Unprocessable Entity</title>}, @response.body) assert_match(%r{<title>422: Unprocessable Entity</title>}, @response.body)

View file

@ -41,7 +41,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
end end
test '01 - get config call' do test '01 - get config call' do
post '/api/v1/form_config', {}.to_json, @headers post '/api/v1/form_config', params: {}.to_json, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -50,7 +50,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
test '02 - get config call' do test '02 - get config call' do
Setting.set('form_ticket_create', true) Setting.set('form_ticket_create', true)
post '/api/v1/form_config', {}.to_json, @headers post '/api/v1/form_config', params: {}.to_json, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -61,7 +61,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
test '03 - get config call & do submit' do test '03 - get config call & do submit' do
Setting.set('form_ticket_create', true) Setting.set('form_ticket_create', true)
fingerprint = SecureRandom.hex(40) fingerprint = SecureRandom.hex(40)
post '/api/v1/form_config', { fingerprint: fingerprint }.to_json, @headers post '/api/v1/form_config', params: { fingerprint: fingerprint }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -71,13 +71,13 @@ class FormControllerTest < ActionDispatch::IntegrationTest
assert(result['token']) assert(result['token'])
token = result['token'] token = result['token']
post '/api/v1/form_submit', { fingerprint: fingerprint, token: 'invalid' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: 'invalid' }.to_json, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
assert_equal(result['error'], 'Not authorized') assert_equal(result['error'], 'Not authorized')
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -88,7 +88,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
assert_equal(result['errors']['title'], 'required') assert_equal(result['errors']['title'], 'required')
assert_equal(result['errors']['body'], 'required') assert_equal(result['errors']['body'], 'required')
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token, email: 'some' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, email: 'some' }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -99,7 +99,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
assert_equal(result['errors']['title'], 'required') assert_equal(result['errors']['title'], 'required')
assert_equal(result['errors']['body'], 'required') assert_equal(result['errors']['body'], 'required')
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -111,7 +111,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
travel 5.hours travel 5.hours
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -124,7 +124,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
travel 20.hours travel 20.hours
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }.to_json, headers: @headers
assert_response(401) assert_response(401)
end end
@ -132,7 +132,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
test '04 - get config call & do submit' do test '04 - get config call & do submit' do
Setting.set('form_ticket_create', true) Setting.set('form_ticket_create', true)
fingerprint = SecureRandom.hex(40) fingerprint = SecureRandom.hex(40)
post '/api/v1/form_config', { fingerprint: fingerprint }.to_json, @headers post '/api/v1/form_config', params: { fingerprint: fingerprint }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -142,13 +142,13 @@ class FormControllerTest < ActionDispatch::IntegrationTest
assert(result['token']) assert(result['token'])
token = result['token'] token = result['token']
post '/api/v1/form_submit', { fingerprint: fingerprint, token: 'invalid' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: 'invalid' }.to_json, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
assert_equal(result['error'], 'Not authorized') assert_equal(result['error'], 'Not authorized')
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -159,7 +159,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
assert_equal(result['errors']['title'], 'required') assert_equal(result['errors']['title'], 'required')
assert_equal(result['errors']['body'], 'required') assert_equal(result['errors']['body'], 'required')
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token, email: 'some' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, email: 'some' }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -170,7 +170,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
assert_equal(result['errors']['title'], 'required') assert_equal(result['errors']['title'], 'required')
assert_equal(result['errors']['body'], 'required') assert_equal(result['errors']['body'], 'required')
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'somebody@example.com', title: 'test', body: 'hello' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'somebody@example.com', title: 'test', body: 'hello' }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -185,7 +185,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
Setting.set('form_ticket_create', true) Setting.set('form_ticket_create', true)
fingerprint = SecureRandom.hex(40) fingerprint = SecureRandom.hex(40)
post '/api/v1/form_config', { fingerprint: fingerprint }.to_json, @headers post '/api/v1/form_config', params: { fingerprint: fingerprint }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -197,7 +197,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
(1..20).each { |count| (1..20).each { |count|
travel 10.seconds travel 10.seconds
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: "test#{count}", body: 'hello' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: "test#{count}", body: 'hello' }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -212,7 +212,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
sleep 10 # wait until elasticsearch is index sleep 10 # wait until elasticsearch is index
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test-last', body: 'hello' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test-last', body: 'hello' }.to_json, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -222,7 +222,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
(1..20).each { |count| (1..20).each { |count|
travel 10.seconds travel 10.seconds
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: "test-2-#{count}", body: 'hello' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: "test-2-#{count}", body: 'hello' }.to_json, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)
@ -237,7 +237,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest
sleep 10 # wait until elasticsearch is index sleep 10 # wait until elasticsearch is index
post '/api/v1/form_submit', { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test-2-last', body: 'hello' }.to_json, @headers post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test-2-last', body: 'hello' }.to_json, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(result.class, Hash) assert_equal(result.class, Hash)

Some files were not shown because too many files have changed in this diff Show more