Updated to rails 5.0.

This commit is contained in:
Jens Pfeifer 2017-09-08 08:28:34 +00:00
parent c6e40ce818
commit 533b44af8f
110 changed files with 696 additions and 645 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

@ -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

@ -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

@ -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,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

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

@ -1,4 +1,4 @@
class SchedulerStatus < ActiveRecord::Migration class SchedulerStatus < 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 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

@ -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)

View file

@ -9,12 +9,12 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
end end
test '01 without token' do test '01 without token' do
post '/api/v1/integration/check_mk/', {} post '/api/v1/integration/check_mk/', params: {}
assert_response(404) assert_response(404)
end end
test '01 invalid token & enabled feature' do test '01 invalid token & enabled feature' do
post '/api/v1/integration/check_mk/invalid_token', {} post '/api/v1/integration/check_mk/invalid_token', params: {}
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -25,7 +25,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
test '01 invalid token & disabled feature' do test '01 invalid token & disabled feature' do
Setting.set('check_mk_integration', false) Setting.set('check_mk_integration', false)
post '/api/v1/integration/check_mk/invalid_token', {} post '/api/v1/integration/check_mk/invalid_token', params: {}
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -40,7 +40,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
host: 'some host', host: 'some host',
service: 'some service', service: 'some service',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -60,7 +60,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
host: 'some host', host: 'some host',
service: 'some service', service: 'some service',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -81,7 +81,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
host: 'some host', host: 'some host',
service: 'some service', service: 'some service',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -101,7 +101,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
host: 'some host', host: 'some host',
service: 'some service', service: 'some service',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -120,7 +120,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
host: 'some host', host: 'some host',
service: 'some service', service: 'some service',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -141,7 +141,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
host: 'some host', host: 'some host',
service: 'some service', service: 'some service',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -158,7 +158,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
host: 'some host', host: 'some host',
service: 'some service', service: 'some service',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -178,7 +178,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
host: 'some host', host: 'some host',
service: 'some service', service: 'some service',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -197,7 +197,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
host: 'some host', host: 'some host',
service: 'some service', service: 'some service',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -217,7 +217,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
state: 'down', state: 'down',
host: 'some host', host: 'some host',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -236,7 +236,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
state: 'down', state: 'down',
host: 'some host', host: 'some host',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -254,7 +254,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest
state: 'up', state: 'up',
host: 'some host', host: 'some host',
} }
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)

View file

@ -80,7 +80,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
test '01 monitoring without token' do test '01 monitoring without token' do
# health_check # health_check
get '/api/v1/monitoring/health_check', {}, @headers get '/api/v1/monitoring/health_check', params: {}, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -89,7 +89,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('Not authorized', result['error']) assert_equal('Not authorized', result['error'])
# status # status
get '/api/v1/monitoring/status', {}, @headers get '/api/v1/monitoring/status', params: {}, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -101,7 +101,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('Not authorized', result['error']) assert_equal('Not authorized', result['error'])
# token # token
post '/api/v1/monitoring/token', {}, @headers post '/api/v1/monitoring/token', params: {}, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -114,7 +114,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
test '02 monitoring with wrong token' do test '02 monitoring with wrong token' do
# health_check # health_check
get '/api/v1/monitoring/health_check?token=abc', {}, @headers get '/api/v1/monitoring/health_check?token=abc', params: {}, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -123,7 +123,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('Not authorized', result['error']) assert_equal('Not authorized', result['error'])
# status # status
get '/api/v1/monitoring/status?token=abc', {}, @headers get '/api/v1/monitoring/status?token=abc', params: {}, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -135,7 +135,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('Not authorized', result['error']) assert_equal('Not authorized', result['error'])
# token # token
post '/api/v1/monitoring/token', { token: 'abc' }.to_json, @headers post '/api/v1/monitoring/token', params: { token: 'abc' }.to_json, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -148,7 +148,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
test '03 monitoring with correct token' do test '03 monitoring with correct token' do
# health_check # health_check
get "/api/v1/monitoring/health_check?token=#{@token}", {}, @headers get "/api/v1/monitoring/health_check?token=#{@token}", params: {}, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -158,7 +158,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('success', result['message']) assert_equal('success', result['message'])
# status # status
get "/api/v1/monitoring/status?token=#{@token}", {}, @headers get "/api/v1/monitoring/status?token=#{@token}", params: {}, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -170,7 +170,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert(result.key?('last_created_at')) assert(result.key?('last_created_at'))
# token # token
post '/api/v1/monitoring/token', { token: @token }.to_json, @headers post '/api/v1/monitoring/token', params: { token: @token }.to_json, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -185,7 +185,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-admin@example.com', 'adminpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-admin@example.com', 'adminpw')
# health_check # health_check
get '/api/v1/monitoring/health_check', {}, @headers.merge('Authorization' => credentials) get '/api/v1/monitoring/health_check', params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -195,7 +195,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('success', result['message']) assert_equal('success', result['message'])
# status # status
get '/api/v1/monitoring/status', {}, @headers.merge('Authorization' => credentials) get '/api/v1/monitoring/status', params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -207,7 +207,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert(result.key?('last_created_at')) assert(result.key?('last_created_at'))
# token # token
post '/api/v1/monitoring/token', { token: @token }.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/monitoring/token', params: { token: @token }.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(201) assert_response(201)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -223,7 +223,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-agent@example.com', 'agentpw')
# health_check # health_check
get '/api/v1/monitoring/health_check', {}, @headers.merge('Authorization' => credentials) get '/api/v1/monitoring/health_check', params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -232,7 +232,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('Not authorized (user)!', result['error']) assert_equal('Not authorized (user)!', result['error'])
# status # status
get '/api/v1/monitoring/status', {}, @headers.merge('Authorization' => credentials) get '/api/v1/monitoring/status', params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -244,7 +244,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('Not authorized (user)!', result['error']) assert_equal('Not authorized (user)!', result['error'])
# token # token
post '/api/v1/monitoring/token', { token: @token }.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/monitoring/token', params: { token: @token }.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -263,7 +263,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-admin@example.com', 'adminpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-admin@example.com', 'adminpw')
# health_check # health_check
get '/api/v1/monitoring/health_check', {}, @headers.merge('Authorization' => credentials) get '/api/v1/monitoring/health_check', params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -272,7 +272,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('Not authorized (user)!', result['error']) assert_equal('Not authorized (user)!', result['error'])
# status # status
get '/api/v1/monitoring/status', {}, @headers.merge('Authorization' => credentials) get '/api/v1/monitoring/status', params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -284,7 +284,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('Not authorized (user)!', result['error']) assert_equal('Not authorized (user)!', result['error'])
# token # token
post '/api/v1/monitoring/token', { token: @token }.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/monitoring/token', params: { token: @token }.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -303,7 +303,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
permission.save! permission.save!
# health_check # health_check
get "/api/v1/monitoring/health_check?token=#{@token}", {}, @headers get "/api/v1/monitoring/health_check?token=#{@token}", params: {}, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -313,7 +313,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert_equal('success', result['message']) assert_equal('success', result['message'])
# status # status
get "/api/v1/monitoring/status?token=#{@token}", {}, @headers get "/api/v1/monitoring/status?token=#{@token}", params: {}, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -325,7 +325,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
assert(result.key?('last_created_at')) assert(result.key?('last_created_at'))
# token # token
post '/api/v1/monitoring/token', { token: @token }.to_json, @headers post '/api/v1/monitoring/token', params: { token: @token }.to_json, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -348,7 +348,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
channel.save! channel.save!
# health_check # health_check
get "/api/v1/monitoring/health_check?token=#{@token}", {}, @headers get "/api/v1/monitoring/health_check?token=#{@token}", params: {}, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -364,7 +364,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
scheduler.save! scheduler.save!
# health_check # health_check
get "/api/v1/monitoring/health_check?token=#{@token}", {}, @headers get "/api/v1/monitoring/health_check?token=#{@token}", params: {}, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -379,7 +379,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
FileUtils.touch("#{dir}/test.eml") FileUtils.touch("#{dir}/test.eml")
# health_check # health_check
get "/api/v1/monitoring/health_check?token=#{@token}", {}, @headers get "/api/v1/monitoring/health_check?token=#{@token}", params: {}, headers: @headers
assert_response(200) assert_response(200)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -393,7 +393,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest
test '09 check restart_failed_jobs' do test '09 check restart_failed_jobs' do
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-admin@example.com', 'adminpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-admin@example.com', 'adminpw')
post '/api/v1/monitoring/restart_failed_jobs', {}, @headers.merge('Authorization' => credentials) post '/api/v1/monitoring/restart_failed_jobs', params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(200) assert_response(200)
end end

View file

@ -53,7 +53,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest
test '01 packages index with nobody' do test '01 packages index with nobody' do
# index # index
get '/api/v1/packages', {}, @headers get '/api/v1/packages', params: {}, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -67,7 +67,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'adminpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'adminpw')
# index # index
get '/api/v1/packages', {}, @headers.merge('Authorization' => credentials) get '/api/v1/packages', params: {}, headers: @headers.merge('Authorization' => 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)
@ -79,7 +79,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'wrongadminpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'wrongadminpw')
# index # index
get '/api/v1/packages', {}, @headers.merge('Authorization' => credentials) get '/api/v1/packages', params: {}, headers: @headers.merge('Authorization' => 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)
@ -93,7 +93,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'adminpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'adminpw')
# index # index
get '/api/v1/packages', {}, @headers.merge('Authorization' => credentials) get '/api/v1/packages', params: {}, headers: @headers.merge('Authorization' => 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)
@ -105,7 +105,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-agent@example.com', 'agentpw')
# index # index
get '/api/v1/packages', {}, @headers.merge('Authorization' => credentials) get '/api/v1/packages', params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -119,7 +119,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-customer1@example.com', 'customer1pw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-customer1@example.com', 'customer1pw')
# index # index
get '/api/v1/packages', {}, @headers.merge('Authorization' => credentials) get '/api/v1/packages', params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)

View file

@ -191,21 +191,21 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 2, limit: 2,
} }
post '/api/v1/search/ticket', params.to_json, @headers post '/api/v1/search/ticket', params: params.to_json, headers: @headers
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)
assert_not(result.empty?) assert_not(result.empty?)
assert_equal('authentication failed', result['error']) assert_equal('authentication failed', result['error'])
post '/api/v1/search/user', params.to_json, @headers post '/api/v1/search/user', params: params.to_json, headers: @headers
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)
assert_not(result.empty?) assert_not(result.empty?)
assert_equal('authentication failed', result['error']) assert_equal('authentication failed', result['error'])
post '/api/v1/search', params.to_json, @headers post '/api/v1/search', params: params.to_json, headers: @headers
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)
@ -220,7 +220,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
query: '1234*', query: '1234*',
limit: 1, limit: 1,
} }
post '/api/v1/search', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -236,7 +236,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -256,7 +256,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search/ticket', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search/ticket', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -274,7 +274,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search/user', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search/user', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -291,7 +291,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 1, limit: 1,
} }
post '/api/v1/search', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -307,7 +307,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -327,7 +327,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search/ticket', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search/ticket', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -345,7 +345,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search/user', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search/user', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -362,7 +362,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -376,7 +376,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search/ticket', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search/ticket', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -390,7 +390,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search/user', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search/user', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -405,7 +405,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -421,7 +421,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search/ticket', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search/ticket', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -437,7 +437,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
limit: 10, limit: 10,
} }
post '/api/v1/search/user', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/search/user', params: params.to_json, headers: @headers.merge('Authorization' => 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)

View file

@ -75,7 +75,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
test 'settings index with nobody' do test 'settings index with nobody' do
# index # index
get '/api/v1/settings', {}, @headers get '/api/v1/settings', params: {}, headers: @headers
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)
@ -83,7 +83,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
# show # show
setting = Setting.find_by(name: 'product_name') setting = Setting.find_by(name: 'product_name')
get "/api/v1/settings/#{setting.id}", {}, @headers get "/api/v1/settings/#{setting.id}", params: {}, headers: @headers
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal('authentication failed', result['error']) assert_equal('authentication failed', result['error'])
@ -94,7 +94,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('setting-admin@example.com', 'adminpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('setting-admin@example.com', 'adminpw')
# index # index
get '/api/v1/settings', {}, @headers.merge('Authorization' => credentials) get '/api/v1/settings', params: {}, headers: @headers.merge('Authorization' => 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)
@ -114,14 +114,14 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
# show # show
setting = Setting.find_by(name: 'product_name') setting = Setting.find_by(name: 'product_name')
get "/api/v1/settings/#{setting.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/settings/#{setting.id}", params: {}, headers: @headers.merge('Authorization' => 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_equal('product_name', result['name']) assert_equal('product_name', result['name'])
setting = Setting.find_by(name: 'api_token_access') setting = Setting.find_by(name: 'api_token_access')
get "/api/v1/settings/#{setting.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/settings/#{setting.id}", params: {}, headers: @headers.merge('Authorization' => 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)
@ -137,7 +137,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
some_new_key: true, some_new_key: true,
} }
} }
put "/api/v1/settings/#{setting.id}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/settings/#{setting.id}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -156,7 +156,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
some_new_key: true, some_new_key: true,
} }
} }
put "/api/v1/settings/#{setting.id}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/settings/#{setting.id}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -167,7 +167,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
# delete # delete
setting = Setting.find_by(name: 'product_name') setting = Setting.find_by(name: 'product_name')
delete "/api/v1/settings/#{setting.id}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/settings/#{setting.id}", params: {}.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal('Not authorized (feature not possible)', result['error']) assert_equal('Not authorized (feature not possible)', result['error'])
@ -178,7 +178,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('setting-admin-api@example.com', 'adminpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('setting-admin-api@example.com', 'adminpw')
# index # index
get '/api/v1/settings', {}, @headers.merge('Authorization' => credentials) get '/api/v1/settings', params: {}, headers: @headers.merge('Authorization' => 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)
@ -198,13 +198,13 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
# show # show
setting = Setting.find_by(name: 'product_name') setting = Setting.find_by(name: 'product_name')
get "/api/v1/settings/#{setting.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/settings/#{setting.id}", params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal('Not authorized (required ["admin.branding"])', result['error']) assert_equal('Not authorized (required ["admin.branding"])', result['error'])
setting = Setting.find_by(name: 'api_token_access') setting = Setting.find_by(name: 'api_token_access')
get "/api/v1/settings/#{setting.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/settings/#{setting.id}", params: {}, headers: @headers.merge('Authorization' => 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)
@ -220,7 +220,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
some_new_key: true, some_new_key: true,
} }
} }
put "/api/v1/settings/#{setting.id}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/settings/#{setting.id}", params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal('Not authorized (required ["admin.branding"])', result['error']) assert_equal('Not authorized (required ["admin.branding"])', result['error'])
@ -235,7 +235,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
some_new_key: true, some_new_key: true,
} }
} }
put "/api/v1/settings/#{setting.id}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/settings/#{setting.id}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -246,7 +246,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
# delete # delete
setting = Setting.find_by(name: 'product_name') setting = Setting.find_by(name: 'product_name')
delete "/api/v1/settings/#{setting.id}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/settings/#{setting.id}", params: {}.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal('Not authorized (feature not possible)', result['error']) assert_equal('Not authorized (feature not possible)', result['error'])
@ -257,7 +257,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('setting-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('setting-agent@example.com', 'agentpw')
# index # index
get '/api/v1/settings', {}, @headers.merge('Authorization' => credentials) get '/api/v1/settings', params: {}, headers: @headers.merge('Authorization' => 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)
@ -266,7 +266,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
# show # show
setting = Setting.find_by(name: 'product_name') setting = Setting.find_by(name: 'product_name')
get "/api/v1/settings/#{setting.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/settings/#{setting.id}", params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal('Not authorized (user)!', result['error']) assert_equal('Not authorized (user)!', result['error'])
@ -277,7 +277,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('setting-customer1@example.com', 'customer1pw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('setting-customer1@example.com', 'customer1pw')
# index # index
get '/api/v1/settings', {}, @headers.merge('Authorization' => credentials) get '/api/v1/settings', params: {}, headers: @headers.merge('Authorization' => 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)
@ -286,14 +286,14 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
# show # show
setting = Setting.find_by(name: 'product_name') setting = Setting.find_by(name: 'product_name')
get "/api/v1/settings/#{setting.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/settings/#{setting.id}", params: {}, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal('Not authorized (user)!', result['error']) assert_equal('Not authorized (user)!', result['error'])
# delete # delete
setting = Setting.find_by(name: 'product_name') setting = Setting.find_by(name: 'product_name')
delete "/api/v1/settings/#{setting.id}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/settings/#{setting.id}", params: {}.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(401) assert_response(401)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal('Not authorized (user)!', result['error']) assert_equal('Not authorized (user)!', result['error'])

View file

@ -95,12 +95,12 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest
) )
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article1.id}/#{store1.id}", {}, 'Authorization' => credentials get "/api/v1/ticket_attachment/#{ticket1.id}/#{article1.id}/#{store1.id}", params: {}, headers: { 'Authorization' => credentials }
assert_response(200) assert_response(200)
assert_equal('some content', @response.body) assert_equal('some content', @response.body)
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article2.id}/#{store1.id}", {}, 'Authorization' => credentials get "/api/v1/ticket_attachment/#{ticket1.id}/#{article2.id}/#{store1.id}", params: {}, headers: { 'Authorization' => credentials }
assert_response(401) assert_response(401)
assert_match(/401: Unauthorized/, @response.body) assert_match(/401: Unauthorized/, @response.body)
@ -119,23 +119,23 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest
) )
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
get "/api/v1/ticket_attachment/#{ticket2.id}/#{article1.id}/#{store1.id}", {}, 'Authorization' => credentials get "/api/v1/ticket_attachment/#{ticket2.id}/#{article1.id}/#{store1.id}", params: {}, headers: { 'Authorization' => credentials }
assert_response(200) assert_response(200)
assert_equal('some content', @response.body) assert_equal('some content', @response.body)
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
get "/api/v1/ticket_attachment/#{ticket2.id}/#{article2.id}/#{store1.id}", {}, 'Authorization' => credentials get "/api/v1/ticket_attachment/#{ticket2.id}/#{article2.id}/#{store1.id}", params: {}, headers: { 'Authorization' => credentials }
assert_response(401) assert_response(401)
assert_match(/401: Unauthorized/, @response.body) assert_match(/401: Unauthorized/, @response.body)
# allow access via merged ticket id also # allow access via merged ticket id also
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article1.id}/#{store1.id}", {}, 'Authorization' => credentials get "/api/v1/ticket_attachment/#{ticket1.id}/#{article1.id}/#{store1.id}", params: {}, headers: { 'Authorization' => credentials }
assert_response(200) assert_response(200)
assert_equal('some content', @response.body) assert_equal('some content', @response.body)
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article2.id}/#{store1.id}", {}, 'Authorization' => credentials get "/api/v1/ticket_attachment/#{ticket1.id}/#{article2.id}/#{store1.id}", params: {}, headers: { 'Authorization' => credentials }
assert_response(401) assert_response(401)
assert_match(/401: Unauthorized/, @response.body) assert_match(/401: Unauthorized/, @response.body)

View file

@ -61,7 +61,7 @@ class TicketArticlesControllerTest < ActionDispatch::IntegrationTest
body: 'some body', body: 'some body',
} }
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(201) assert_response(201)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -71,7 +71,7 @@ class TicketArticlesControllerTest < ActionDispatch::IntegrationTest
body: 'some body', body: 'some body',
type: 'note', type: 'note',
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -94,7 +94,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />', 9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />',
type: 'note', type: 'note',
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -127,7 +127,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
'mime-type' => 'text/plain', 'mime-type' => 'text/plain',
], ],
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -143,7 +143,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(1, ticket.articles[2].attachments.count) assert_equal(1, ticket.articles[2].attachments.count)
assert_equal(1, ticket.articles[3].attachments.count) assert_equal(1, ticket.articles[3].attachments.count)
get "/api/v1/ticket_articles/#{result['id']}?expand=true", {}.to_json, @headers.merge('Authorization' => credentials) get "/api/v1/ticket_articles/#{result['id']}?expand=true", params: {}.to_json, headers: @headers.merge('Authorization' => 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)
@ -164,7 +164,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
body: 'some body', body: 'some body',
} }
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(201) assert_response(201)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
@ -174,7 +174,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
body: 'some body', body: 'some body',
type: 'note', type: 'note',
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -197,7 +197,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
sender: 'Agent', sender: 'Agent',
type: 'note', type: 'note',
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -223,7 +223,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
type: 'note', type: 'note',
internal: true, internal: true,
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -266,13 +266,13 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(0, ticket.articles[3].attachments.count) assert_equal(0, ticket.articles[3].attachments.count)
assert_equal(0, ticket.articles[4].attachments.count) assert_equal(0, ticket.articles[4].attachments.count)
get "/api/v1/ticket_articles/#{article.id}", {}.to_json, @headers.merge('Authorization' => credentials) get "/api/v1/ticket_articles/#{article.id}", params: {}.to_json, headers: @headers.merge('Authorization' => 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)
assert_equal('Not authorized', result['error']) assert_equal('Not authorized', result['error'])
put "/api/v1/ticket_articles/#{article.id}", { internal: false }.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/ticket_articles/#{article.id}", params: { internal: false }.to_json, headers: @headers.merge('Authorization' => 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)
@ -293,7 +293,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
type: 'phone', type: 'phone',
} }
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -317,7 +317,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
origin_by_id: 1, origin_by_id: 1,
} }
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)

View file

@ -61,7 +61,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
type: 'note', type: 'note',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -80,7 +80,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
type: 'note', type: 'note',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -97,7 +97,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
customer_id: @customer_without_org.id, customer_id: @customer_without_org.id,
article: {}, article: {},
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -116,7 +116,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
body: 'some test 123', body: 'some test 123',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -140,7 +140,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
body: 'some test 123', body: 'some test 123',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -160,7 +160,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
body: 'some test 123', body: 'some test 123',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
#assert_response(422) #assert_response(422)
#result = JSON.parse(@response.body) #result = JSON.parse(@response.body)
#assert_equal(Hash, result.class) #assert_equal(Hash, result.class)
@ -188,7 +188,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
body: 'some test 123', body: 'some test 123',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -208,7 +208,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
body: 'some test 123', body: 'some test 123',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -231,7 +231,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
body: 'some test 123', body: 'some test 123',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -252,7 +252,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
body: 'some test 123', body: 'some test 123',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -273,7 +273,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
subject: 'some test 123', subject: 'some test 123',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -296,7 +296,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
], ],
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -339,7 +339,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
], ],
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -375,7 +375,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
], ],
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -397,7 +397,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
], ],
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(422) assert_response(422)
result = JSON.parse(@response.body) result = JSON.parse(@response.body)
assert_equal(Hash, result.class) assert_equal(Hash, result.class)
@ -419,7 +419,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -463,7 +463,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -506,7 +506,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
} }
} }
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -540,7 +540,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
created_by_id: 1, created_by_id: 1,
) )
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
get "/api/v1/tickets/#{ticket.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/#{ticket.id}", params: {}, headers: @headers.merge('Authorization' => 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)
@ -549,13 +549,13 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
params = { params = {
title: 'ticket with wrong ticket id - 2', title: 'ticket with wrong ticket id - 2',
} }
put "/api/v1/tickets/#{ticket.id}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/tickets/#{ticket.id}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
assert_equal('Not authorized', result['error']) assert_equal('Not authorized', result['error'])
delete "/api/v1/tickets/#{ticket.id}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/tickets/#{ticket.id}", params: {}.to_json, headers: @headers.merge('Authorization' => 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)
@ -574,7 +574,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
created_by_id: 1, created_by_id: 1,
) )
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
get "/api/v1/tickets/#{ticket.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/#{ticket.id}", params: {}, headers: @headers.merge('Authorization' => 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)
@ -588,7 +588,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
title: "#{title} - 2", title: "#{title} - 2",
customer_id: @agent.id, customer_id: @agent.id,
} }
put "/api/v1/tickets/#{ticket.id}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/tickets/#{ticket.id}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -603,7 +603,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
subject: 'some subject', subject: 'some subject',
body: 'some body', body: 'some body',
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(201) assert_response(201)
article_result = JSON.parse(@response.body) article_result = JSON.parse(@response.body)
assert_equal(Hash, article_result.class) assert_equal(Hash, article_result.class)
@ -618,7 +618,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(Ticket::Article::Type.lookup(name: 'note').id, article_result['type_id']) assert_equal(Ticket::Article::Type.lookup(name: 'note').id, article_result['type_id'])
Scheduler.worker(true) Scheduler.worker(true)
get "/api/v1/tickets/search?query=#{CGI.escape(title)}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/search?query=#{CGI.escape(title)}", params: {}, headers: @headers.merge('Authorization' => 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)
@ -633,14 +633,14 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
}, },
}, },
} }
post '/api/v1/tickets/search', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets/search', params: params.to_json, headers: @headers.merge('Authorization' => 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_equal(ticket.id, result['tickets'][0]) assert_equal(ticket.id, result['tickets'][0])
assert_equal(1, result['tickets_count']) assert_equal(1, result['tickets_count'])
delete "/api/v1/ticket_articles/#{article_result['id']}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/ticket_articles/#{article_result['id']}", params: {}.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(200) assert_response(200)
params = { params = {
@ -651,7 +651,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
type: 'email', type: 'email',
internal: true, internal: true,
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -668,7 +668,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
params = { params = {
subject: 'new subject', subject: 'new subject',
} }
put "/api/v1/ticket_articles/#{result['id']}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/ticket_articles/#{result['id']}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -682,13 +682,13 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(Ticket::Article::Sender.lookup(name: 'Agent').id, result['sender_id']) assert_equal(Ticket::Article::Sender.lookup(name: 'Agent').id, result['sender_id'])
assert_equal(Ticket::Article::Type.lookup(name: 'email').id, result['type_id']) assert_equal(Ticket::Article::Type.lookup(name: 'email').id, result['type_id'])
delete "/api/v1/ticket_articles/#{result['id']}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/ticket_articles/#{result['id']}", params: {}.to_json, headers: @headers.merge('Authorization' => 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)
assert_equal('Not authorized (admin permission required)!', result['error']) assert_equal('Not authorized (admin permission required)!', result['error'])
delete "/api/v1/tickets/#{ticket.id}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/tickets/#{ticket.id}", params: {}.to_json, headers: @headers.merge('Authorization' => 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)
@ -706,7 +706,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
created_by_id: 1, created_by_id: 1,
) )
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-admin', 'adminpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-admin', 'adminpw')
get "/api/v1/tickets/#{ticket.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/#{ticket.id}", params: {}, headers: @headers.merge('Authorization' => 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)
@ -720,7 +720,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
title: 'ticket with corret ticket id - 2', title: 'ticket with corret ticket id - 2',
customer_id: @agent.id, customer_id: @agent.id,
} }
put "/api/v1/tickets/#{ticket.id}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/tickets/#{ticket.id}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -736,7 +736,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
subject: 'some subject', subject: 'some subject',
body: 'some body', body: 'some body',
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -754,7 +754,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
subject: 'new subject', subject: 'new subject',
internal: true, internal: true,
} }
put "/api/v1/ticket_articles/#{result['id']}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/ticket_articles/#{result['id']}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -768,7 +768,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(Ticket::Article::Sender.lookup(name: 'Agent').id, result['sender_id']) assert_equal(Ticket::Article::Sender.lookup(name: 'Agent').id, result['sender_id'])
assert_equal(Ticket::Article::Type.lookup(name: 'note').id, result['type_id']) assert_equal(Ticket::Article::Type.lookup(name: 'note').id, result['type_id'])
delete "/api/v1/ticket_articles/#{result['id']}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/ticket_articles/#{result['id']}", params: {}.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(200) assert_response(200)
params = { params = {
@ -777,7 +777,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
body: 'some body', body: 'some body',
type: 'email', type: 'email',
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -791,10 +791,10 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(Ticket::Article::Sender.lookup(name: 'Agent').id, result['sender_id']) assert_equal(Ticket::Article::Sender.lookup(name: 'Agent').id, result['sender_id'])
assert_equal(Ticket::Article::Type.lookup(name: 'email').id, result['type_id']) assert_equal(Ticket::Article::Type.lookup(name: 'email').id, result['type_id'])
delete "/api/v1/ticket_articles/#{result['id']}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/ticket_articles/#{result['id']}", params: {}.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(200) assert_response(200)
delete "/api/v1/tickets/#{ticket.id}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/tickets/#{ticket.id}", params: {}.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(200) assert_response(200)
end end
@ -826,7 +826,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
} }
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-admin', 'adminpw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-admin', 'adminpw')
get "/api/v1/tickets/search?query=#{CGI.escape(title)}&limit=40", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/search?query=#{CGI.escape(title)}&limit=40", params: {}, headers: @headers.merge('Authorization' => 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)
@ -834,7 +834,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(tickets[0].id, result['tickets'][19]) assert_equal(tickets[0].id, result['tickets'][19])
assert_equal(20, result['tickets_count']) assert_equal(20, result['tickets_count'])
get "/api/v1/tickets/search?query=#{CGI.escape(title)}&limit=10", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/search?query=#{CGI.escape(title)}&limit=10", params: {}, headers: @headers.merge('Authorization' => 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)
@ -842,7 +842,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(tickets[10].id, result['tickets'][9]) assert_equal(tickets[10].id, result['tickets'][9])
assert_equal(10, result['tickets_count']) assert_equal(10, result['tickets_count'])
get "/api/v1/tickets/search?query=#{CGI.escape(title)}&limit=40&page=1&per_page=5", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/search?query=#{CGI.escape(title)}&limit=40&page=1&per_page=5", params: {}, headers: @headers.merge('Authorization' => 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)
@ -850,7 +850,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(tickets[15].id, result['tickets'][4]) assert_equal(tickets[15].id, result['tickets'][4])
assert_equal(5, result['tickets_count']) assert_equal(5, result['tickets_count'])
get "/api/v1/tickets/search?query=#{CGI.escape(title)}&limit=40&page=2&per_page=5", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/search?query=#{CGI.escape(title)}&limit=40&page=2&per_page=5", params: {}, headers: @headers.merge('Authorization' => 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)
@ -858,7 +858,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(tickets[10].id, result['tickets'][4]) assert_equal(tickets[10].id, result['tickets'][4])
assert_equal(5, result['tickets_count']) assert_equal(5, result['tickets_count'])
get '/api/v1/tickets?limit=40&page=1&per_page=5', {}, @headers.merge('Authorization' => credentials) get '/api/v1/tickets?limit=40&page=1&per_page=5', params: {}, headers: @headers.merge('Authorization' => 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)
@ -867,7 +867,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(tickets[4].id, result[4]['id']) assert_equal(tickets[4].id, result[4]['id'])
assert_equal(5, result.count) assert_equal(5, result.count)
get '/api/v1/tickets?limit=40&page=2&per_page=5', {}, @headers.merge('Authorization' => credentials) get '/api/v1/tickets?limit=40&page=2&per_page=5', params: {}, headers: @headers.merge('Authorization' => 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)
@ -889,7 +889,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
body: 'some body', body: 'some body',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -914,7 +914,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
sender: 'System', sender: 'System',
}, },
} }
post '/api/v1/tickets', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -936,7 +936,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
created_by_id: 1, created_by_id: 1,
) )
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-customer1@example.com', 'customer1pw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-customer1@example.com', 'customer1pw')
get "/api/v1/tickets/#{ticket.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/#{ticket.id}", params: {}, headers: @headers.merge('Authorization' => 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)
@ -945,13 +945,13 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
params = { params = {
title: 'ticket with wrong ticket id - 2', title: 'ticket with wrong ticket id - 2',
} }
put "/api/v1/tickets/#{ticket.id}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/tickets/#{ticket.id}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
assert_equal('Not authorized', result['error']) assert_equal('Not authorized', result['error'])
delete "/api/v1/tickets/#{ticket.id}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/tickets/#{ticket.id}", params: {}.to_json, headers: @headers.merge('Authorization' => 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)
@ -970,7 +970,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
created_by_id: 1, created_by_id: 1,
) )
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-customer1@example.com', 'customer1pw') credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-customer1@example.com', 'customer1pw')
get "/api/v1/tickets/#{ticket.id}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/#{ticket.id}", params: {}, headers: @headers.merge('Authorization' => 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)
@ -984,7 +984,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
title: "#{title} - 2", title: "#{title} - 2",
customer_id: @agent.id, customer_id: @agent.id,
} }
put "/api/v1/tickets/#{ticket.id}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/tickets/#{ticket.id}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -999,7 +999,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
subject: 'some subject', subject: 'some subject',
body: 'some body', body: 'some body',
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => credentials)
assert_response(201) assert_response(201)
article_result = JSON.parse(@response.body) article_result = JSON.parse(@response.body)
assert_equal(Hash, article_result.class) assert_equal(Hash, article_result.class)
@ -1013,7 +1013,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(Ticket::Article::Type.lookup(name: 'note').id, article_result['type_id']) assert_equal(Ticket::Article::Type.lookup(name: 'note').id, article_result['type_id'])
Scheduler.worker(true) Scheduler.worker(true)
get "/api/v1/tickets/search?query=#{CGI.escape(title)}", {}, @headers.merge('Authorization' => credentials) get "/api/v1/tickets/search?query=#{CGI.escape(title)}", params: {}, headers: @headers.merge('Authorization' => 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)
@ -1028,14 +1028,14 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
}, },
}, },
} }
post '/api/v1/tickets/search', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/tickets/search', params: params.to_json, headers: @headers.merge('Authorization' => 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_equal(ticket.id, result['tickets'][0]) assert_equal(ticket.id, result['tickets'][0])
assert_equal(1, result['tickets_count']) assert_equal(1, result['tickets_count'])
delete "/api/v1/ticket_articles/#{article_result['id']}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/ticket_articles/#{article_result['id']}", params: {}.to_json, headers: @headers.merge('Authorization' => 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)
@ -1048,7 +1048,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
type: 'email', type: 'email',
sender: 'Agent', sender: 'Agent',
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -1061,7 +1061,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
assert_equal(Ticket::Article::Sender.lookup(name: 'Customer').id, result['sender_id']) assert_equal(Ticket::Article::Sender.lookup(name: 'Customer').id, result['sender_id'])
assert_equal(Ticket::Article::Type.lookup(name: 'note').id, result['type_id']) assert_equal(Ticket::Article::Type.lookup(name: 'note').id, result['type_id'])
delete "/api/v1/ticket_articles/#{result['id']}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/ticket_articles/#{result['id']}", params: {}.to_json, headers: @headers.merge('Authorization' => 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)
@ -1077,7 +1077,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
internal: true, internal: true,
} }
post '/api/v1/ticket_articles', params.to_json, @headers.merge('Authorization' => credentials) post '/api/v1/ticket_articles', params: params.to_json, headers: @headers.merge('Authorization' => 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)
@ -1094,13 +1094,13 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
params = { params = {
subject: 'new subject', subject: 'new subject',
} }
put "/api/v1/ticket_articles/#{result['id']}", params.to_json, @headers.merge('Authorization' => credentials) put "/api/v1/ticket_articles/#{result['id']}", params: params.to_json, headers: @headers.merge('Authorization' => 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)
assert_equal('Not authorized (ticket.agent or admin permission required)!', result['error']) assert_equal('Not authorized (ticket.agent or admin permission required)!', result['error'])
delete "/api/v1/tickets/#{ticket.id}", {}.to_json, @headers.merge('Authorization' => credentials) delete "/api/v1/tickets/#{ticket.id}", params: {}.to_json, headers: @headers.merge('Authorization' => 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)

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