diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d742f2338..34e5845d0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -416,7 +416,6 @@ browser:build: - core script: - export RAILS_ENV=production - - rake db:drop; - rake db:create - rake db:migrate - rake assets:precompile diff --git a/Gemfile b/Gemfile index 4d43388a0..f0a730fc3 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' ruby '2.4.1' -gem 'rails', '4.2.9' +gem 'rails', '5.0.5' gem 'rails-observers' gem 'activerecord-session_store' diff --git a/Gemfile.lock b/Gemfile.lock index 96e3ada43..4bc4dd073 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,35 +17,38 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.9) - actionpack (= 4.2.9) - actionview (= 4.2.9) - activejob (= 4.2.9) + actioncable (5.0.5) + actionpack (= 5.0.5) + nio4r (>= 1.2, < 3.0) + 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) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.9) - actionview (= 4.2.9) - activesupport (= 4.2.9) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.0.5) + actionview (= 5.0.5) + activesupport (= 5.0.5) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.9) - activesupport (= 4.2.9) + actionview (5.0.5) + activesupport (= 5.0.5) builder (~> 3.1) 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) - activejob (4.2.9) - activesupport (= 4.2.9) - globalid (>= 0.3.0) - activemodel (4.2.9) - activesupport (= 4.2.9) - builder (~> 3.1) - activerecord (4.2.9) - activemodel (= 4.2.9) - activesupport (= 4.2.9) - arel (~> 6.0) + activejob (5.0.5) + activesupport (= 5.0.5) + globalid (>= 0.3.6) + activemodel (5.0.5) + activesupport (= 5.0.5) + activerecord (5.0.5) + activemodel (= 5.0.5) + activesupport (= 5.0.5) + arel (~> 7.0) activerecord-nulldb-adapter (0.3.7) activerecord (>= 2.0.0) activerecord-session_store (1.1.0) @@ -54,44 +57,45 @@ GEM multi_json (~> 1.11, >= 1.11.2) rack (>= 1.5.2, < 3) railties (>= 4.0, < 5.2) - activesupport (4.2.9) + activesupport (5.0.5) + concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.4.0) - arel (6.0.4) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) + arel (7.1.4) argon2 (1.1.3) ffi (~> 1.9) ffi-compiler (~> 0.1) ast (2.3.0) - autoprefixer-rails (7.1.2.4) + autoprefixer-rails (7.1.3) execjs biz (1.7.0) clavius (~> 1.0) tzinfo - browser (2.2.0) + browser (2.5.1) buftok (0.2.0) builder (3.2.3) - childprocess (0.5.9) + childprocess (0.7.1) ffi (~> 1.0, >= 1.0.11) - clavius (1.0.2) + clavius (1.0.3) clearbit (0.2.7) nestful (~> 1.1.0) - coderay (1.1.1) - coffee-rails (4.2.1) + coderay (1.1.2) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.2.x) + railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - coffeelint (1.14.0) + coffeelint (1.16.0) coffee-script execjs json - composite_primary_keys (8.1.6) - activerecord (~> 4.2.0) + composite_primary_keys (9.0.7) + activerecord (~> 5.0.0) concurrent-ruby (1.0.5) coveralls (0.8.21) json (>= 1.8, < 3) @@ -107,12 +111,12 @@ GEM delayed_job_active_record (4.1.2) activerecord (>= 3.0, < 5.2) delayed_job (>= 3.0, < 5) - diff-lcs (1.2.5) - diffy (3.1.0) + diff-lcs (1.3) + diffy (3.2.0) docile (1.1.5) domain_name (0.5.20170404) unf (>= 0.0.5, < 1.0.0) - doorkeeper (4.2.0) + doorkeeper (4.2.6) railties (>= 4.2) eco (1.0.0) coffee-script @@ -122,18 +126,18 @@ GEM em-websocket (0.5.1) eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) - equalizer (0.0.10) + equalizer (0.0.11) erubis (2.7.0) - eventmachine (1.2.3) + eventmachine (1.2.5) execjs (2.7.0) factory_girl (4.8.0) activesupport (>= 3.0.0) factory_girl_rails (4.8.0) factory_girl (~> 4.8.0) railties (>= 3.0.0) - faraday (0.9.2) + faraday (0.11.0) multipart-post (>= 1.2, < 3) - faraday-http-cache (1.3.1) + faraday-http-cache (2.0.0) faraday (~> 0.8) ffi (1.9.18) ffi-compiler (0.1.3) @@ -142,17 +146,17 @@ GEM figaro (1.1.1) thor (~> 0.14) formatador (0.2.5) - github_changelog_generator (1.14.1) + github_changelog_generator (1.14.3) activesupport faraday-http-cache multi_json - octokit (~> 4.0) + octokit (~> 4.6) rainbow (>= 2.1) rake (>= 10.0) retriable (~> 2.1) globalid (0.4.0) activesupport (>= 4.2.0) - guard (2.14.0) + guard (2.14.1) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) lumberjack (~> 1.0) @@ -170,10 +174,10 @@ GEM guard-symlink (0.1.1) guard guard-compat (~> 1.1) - hashdiff (0.3.5) + hashdiff (0.3.6) hashie (3.5.6) htmlentities (4.3.4) - http (1.0.4) + http (2.2.2) addressable (~> 2.3) http-cookie (~> 1.0) http-form_data (~> 1.0.1) @@ -190,13 +194,13 @@ GEM ice_cube (~> 0.13) ice_cube (0.16.2) inflection (1.0.0) - json (1.8.6) + json (2.1.0) jwt (1.5.6) kgio (2.11.0) - koala (2.4.0) + koala (3.0.0) addressable faraday - multi_json (>= 1.3.0) + json (>= 1.8) libv8 (3.16.14.19) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) @@ -208,41 +212,40 @@ GEM multi_json (~> 1.10) loofah (2.0.3) nokogiri (>= 1.5.9) - lumberjack (1.0.10) + lumberjack (1.0.12) mail (2.6.6) mime-types (>= 1.16, < 4) memoizable (0.4.2) thread_safe (~> 0.3, >= 0.3.1) method_source (0.8.2) - mime-types (3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) + mime-types (2.99.3) mini_portile2 (2.2.0) minitest (5.10.3) multi_json (1.12.1) multi_xml (0.6.0) multipart-post (2.0.0) - mysql2 (0.4.6) + mysql2 (0.4.9) naught (1.1.0) nenv (0.3.0) nestful (1.1.1) - net-ldap (0.15.0) + net-ldap (0.16.0) netrc (0.11.0) + nio4r (2.1.0) nokogiri (1.8.0) mini_portile2 (~> 2.2.0) nori (2.6.0) notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) - oauth (0.5.1) + oauth (0.5.3) oauth2 (1.4.0) faraday (>= 0.8, < 0.13) jwt (~> 1.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - octokit (4.4.1) - sawyer (~> 0.7.0, >= 0.5.3) + octokit (4.7.0) + sawyer (~> 0.8.0, >= 0.5.3) omniauth (1.6.1) hashie (>= 3.4.6, < 3.6.0) rack (>= 1.6.2, < 3) @@ -254,12 +257,12 @@ GEM omniauth-gitlab (1.0.2) omniauth (~> 1.0) omniauth-oauth2 (~> 1.0) - omniauth-google-oauth2 (0.5.0) + omniauth-google-oauth2 (0.5.2) jwt (~> 1.5) multi_json (~> 1.3) omniauth (>= 1.1.1) omniauth-oauth2 (>= 1.3.1) - omniauth-linkedin-oauth2 (0.1.5) + omniauth-linkedin-oauth2 (0.2.5) omniauth (~> 1.0) omniauth-oauth2 omniauth-microsoft-office365 (0.0.7) @@ -271,14 +274,14 @@ GEM omniauth-oauth2 (1.4.0) oauth2 (~> 1.0) omniauth (~> 1.2) - omniauth-twitter (1.2.1) - json (~> 1.3) + omniauth-twitter (1.4.0) omniauth-oauth (~> 1.1) - parser (2.3.1.2) + rack + parser (2.4.0.0) ast (~> 2.2) pg (0.20.0) pluginator (1.5.0) - power_assert (0.3.1) + power_assert (1.1.0) powerpack (0.1.1) pre-commit (0.35.0) pluginator (~> 1.5) @@ -286,68 +289,68 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - puma (3.9.1) - rack (1.6.8) + public_suffix (3.0.0) + puma (3.10.0) + rack (2.0.3) rack-livereload (0.3.16) rack rack-test (0.6.3) rack (>= 1.0) - rails (4.2.9) - actionmailer (= 4.2.9) - actionpack (= 4.2.9) - actionview (= 4.2.9) - activejob (= 4.2.9) - activemodel (= 4.2.9) - activerecord (= 4.2.9) - activesupport (= 4.2.9) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.9) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.8) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) + rails (5.0.5) + actioncable (= 5.0.5) + actionmailer (= 5.0.5) + actionpack (= 5.0.5) + actionview (= 5.0.5) + activejob (= 5.0.5) + activemodel (= 5.0.5) + activerecord (= 5.0.5) + activesupport (= 5.0.5) + bundler (>= 1.3.0) + railties (= 5.0.5) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) rails-html-sanitizer (1.0.3) loofah (~> 2.0) rails-observers (0.1.5) activemodel (>= 4.0) - railties (4.2.9) - actionpack (= 4.2.9) - activesupport (= 4.2.9) + railties (5.0.5) + actionpack (= 5.0.5) + activesupport (= 5.0.5) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.2.2) rake raindrops (0.19.0) rake (12.0.0) - rb-fsevent (0.9.7) - rb-inotify (0.9.7) - ffi (>= 0.5.0) + rb-fsevent (0.10.2) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) ref (2.0.0) - rest-client (2.0.0) + rest-client (1.8.0) http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 4.0) - netrc (~> 0.8) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) retriable (2.1.0) - rspec-core (3.5.4) - rspec-support (~> 3.5.0) - rspec-expectations (3.5.0) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-mocks (3.5.0) + rspec-support (~> 3.6.0) + rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-rails (3.5.2) + rspec-support (~> 3.6.0) + rspec-rails (3.6.1) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) - rspec-support (~> 3.5.0) - rspec-support (3.5.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) rubocop (0.42.0) parser (>= 2.3.1.1, < 3.0) powerpack (~> 0.1) @@ -355,23 +358,26 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.8.1) - ruby_dep (1.4.0) + ruby_dep (1.5.0) rubyzip (1.2.1) 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) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sawyer (0.7.0) - addressable (>= 2.3.5, < 2.5) - faraday (~> 0.8, < 0.10) + sawyer (0.8.1) + addressable (>= 2.3.5, < 2.6) + faraday (~> 0.8, < 1.0) selenium-webdriver (2.53.4) childprocess (~> 0.5) rubyzip (~> 1.0) - websocket (~> 1.0) shellany (0.0.1) simple-rss (1.3.1) simple_oauth (0.3.1) @@ -379,10 +385,10 @@ GEM docile (~> 1.1.0) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.1) + simplecov-html (0.10.2) simplecov-rcov (0.2.3) simplecov (>= 0.4.1) - slack-notifier (1.5.1) + slack-notifier (2.3.1) slop (3.6.0) spring (2.0.2) activesupport (>= 4.2) @@ -391,47 +397,46 @@ GEM sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.0) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.11) + sqlite3 (1.3.13) telegramAPI (1.2.2) - rest-client (~> 2.0, >= 1.7.3) + rest-client (~> 1.7, >= 1.7.3) term-ansicolor (1.6.0) tins (~> 1.0) - test-unit (3.2.1) + test-unit (3.2.5) power_assert therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref thor (0.19.4) thread_safe (0.3.6) - tilt (2.0.5) + tilt (2.0.8) tins (1.15.0) - twitter (5.17.0) - addressable (~> 2.3) + twitter (6.1.0) + addressable (~> 2.5) buftok (~> 0.2.0) - equalizer (= 0.0.10) - faraday (~> 0.9.0) - http (~> 1.0) + equalizer (= 0.0.11) + faraday (~> 0.11.0) + http (~> 2.1) http_parser.rb (~> 0.6.0) - json (~> 1.8) - memoizable (~> 0.4.0) - naught (~> 1.0) - simple_oauth (~> 0.3.0) + memoizable (~> 0.4.2) + naught (~> 1.1) + simple_oauth (~> 0.3.1) tzinfo (1.2.3) thread_safe (~> 0.1) - uglifier (3.0.2) + uglifier (3.2.0) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.7.4) - unicode-display_width (1.1.1) + unicode-display_width (1.3.0) unicorn (5.3.0) kgio (~> 2.6) raindrops (~> 0.7) - valid_email2 (2.0.0) + valid_email2 (2.0.1) activemodel (>= 3.2) mail (~> 2.5) viewpoint (1.1.0) @@ -443,7 +448,9 @@ GEM addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff - websocket (1.2.3) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) writeexcel (1.0.5) zendesk_api (1.14.4) faraday (~> 0.9) @@ -507,7 +514,7 @@ DEPENDENCIES pre-commit puma rack-livereload - rails (= 4.2.9) + rails (= 5.0.5) rails-observers rb-fsevent rspec-rails @@ -539,4 +546,4 @@ RUBY VERSION ruby 2.4.1p111 BUNDLED WITH - 1.15.3 + 1.15.4 diff --git a/app/controllers/application_controller/authenticates.rb b/app/controllers/application_controller/authenticates.rb index b77b96c97..9d5703dbb 100644 --- a/app/controllers/application_controller/authenticates.rb +++ b/app/controllers/application_controller/authenticates.rb @@ -1,10 +1,6 @@ module ApplicationController::Authenticates extend ActiveSupport::Concern - included do - skip_before_action :verify_authenticity_token - end - private def response_access_deny diff --git a/app/controllers/applications_controller.rb b/app/controllers/applications_controller.rb index 49c106310..69dcbf2f4 100644 --- a/app/controllers/applications_controller.rb +++ b/app/controllers/applications_controller.rb @@ -58,7 +58,7 @@ class ApplicationsController < ApplicationController private def clean_params - params_data = params.permit! #.to_h + params_data = params.permit!.to_h params_data.delete('application') params_data.delete('action') params_data.delete('controller') diff --git a/app/controllers/concerns/creates_ticket_articles.rb b/app/controllers/concerns/creates_ticket_articles.rb index 8d0e06390..b3c662c2e 100644 --- a/app/controllers/concerns/creates_ticket_articles.rb +++ b/app/controllers/concerns/creates_ticket_articles.rb @@ -13,10 +13,10 @@ module CreatesTicketArticles raise Exceptions::UnprocessableEntity, 'Need at least article: { body: "some text" }' if !params[:body] # 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 end - if params[:sender_id].empty? && params[:sender].empty? + if params[:sender_id].blank? && params[:sender].blank? sender = 'Customer' if current_user.permissions?('ticket.agent') sender = 'Agent' @@ -73,7 +73,7 @@ module CreatesTicketArticles } # add attachments as param - if params[:attachments] + if params[:attachments].present? params[:attachments].each_with_index { |attachment, index| # validation @@ -112,7 +112,7 @@ module CreatesTicketArticles ) end - return article if !form_id + return article if form_id.blank? # remove attachments from upload cache Store.remove( diff --git a/app/controllers/integration/sipgate_controller.rb b/app/controllers/integration/sipgate_controller.rb index 88524d1ed..e311cffab 100644 --- a/app/controllers/integration/sipgate_controller.rb +++ b/app/controllers/integration/sipgate_controller.rb @@ -9,7 +9,7 @@ class Integration::SipgateController < ApplicationController # notify about inbound call / block inbound call def in if params['event'] == 'newCall' - config_inbound = config[:inbound] || {} + config_inbound = config_integration[:inbound] || {} block_caller_ids = config_inbound[:block_caller_ids] || [] # check if call need to be blocked @@ -43,8 +43,8 @@ class Integration::SipgateController < ApplicationController # set caller id of outbound call def out - config_outbound = config[:outbound][:routing_table] - default_caller_id = config[:outbound][:default_caller_id] + config_outbound = config_integration[:outbound][:routing_table] + default_caller_id = config_integration[:outbound][:default_caller_id] xml = Builder::XmlMarkup.new(indent: 2) xml.instruct! @@ -89,14 +89,14 @@ class Integration::SipgateController < ApplicationController xml_error('Feature is disable, please contact your admin to enable it!') return 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!') return end end - def config - @config ||= Setting.get('sipgate_config') + def config_integration + @config_integration ||= Setting.get('sipgate_config') end def xml_error(error) diff --git a/app/controllers/object_manager_attributes_controller.rb b/app/controllers/object_manager_attributes_controller.rb index e1f785c7d..33e1ad304 100644 --- a/app/controllers/object_manager_attributes_controller.rb +++ b/app/controllers/object_manager_attributes_controller.rb @@ -31,15 +31,16 @@ class ObjectManagerAttributesController < ApplicationController ) raise Exceptions::UnprocessableEntity, 'already exists' if exists + local_params = params.permit!.to_h begin object_manager_attribute = ObjectManager::Attribute.add( - object: params[:object], - name: params[:name], - display: params[:display], - data_type: params[:data_type], - data_option: params[:data_option], - active: params[:active], - screens: params[:screens], + object: local_params[:object], + name: local_params[:name], + display: local_params[:display], + data_type: local_params[:data_type], + data_option: local_params[:data_option], + active: local_params[:active], + screens: local_params[:screens], position: 1550, editable: true, ) @@ -52,15 +53,17 @@ class ObjectManagerAttributesController < ApplicationController # PUT /object_manager_attributes/1 def update check_params + + local_params = params.permit!.to_h begin object_manager_attribute = ObjectManager::Attribute.add( - object: params[:object], - name: params[:name], - display: params[:display], - data_type: params[:data_type], - data_option: params[:data_option], - active: params[:active], - screens: params[:screens], + object: local_params[:object], + name: local_params[:name], + display: local_params[:display], + data_type: local_params[:data_type], + data_option: local_params[:data_option], + active: local_params[:active], + screens: local_params[:screens], position: 1550, editable: true, ) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 18ed84415..4e3814608 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -252,7 +252,7 @@ curl http://localhost/api/v1/organization/{id} -v -u #{login}:#{password} -H "Co # do pagination if needed if params[:page] && params[:per_page] 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 if params[:expand] diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 7f5e1acf6..0c2500fc6 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -24,7 +24,7 @@ class SessionsController < ApplicationController if params[:remember_me] expire_after = 1.year end - env['rack.session.options'][:expire_after] = expire_after + request.env['rack.session.options'][:expire_after] = expire_after # set session user current_user_set(user) diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index b6c7a6f07..043878288 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -93,7 +93,7 @@ class TicketsController < ApplicationController render json: { error: 'Invalid email of customer' }, status: :unprocessable_entity return end - customer = User.find_by(email: email) + customer = User.find_by(email: email.downcase) if !customer role_ids = Role.signup_role_ids customer = User.create( @@ -122,7 +122,7 @@ class TicketsController < ApplicationController ticket.with_lock do # create tags if given - if params[:tags] && !params[:tags].empty? + if params[:tags].present? tags = params[:tags].split(/,/) tags.each { |tag| ticket.tag_add(tag) @@ -142,12 +142,13 @@ class TicketsController < ApplicationController # child: [ticket_id1, ticket_id2, ...] # }, # } - if params[:links] - raise 'Invalid link structure' if params[:links].to_h.class != Hash - params[:links].each { |target_object, link_types_with_object_ids| - raise 'Invalid link structure (Object)' if link_types_with_object_ids.to_h.class != Hash + if params[:links].present? + link = params[:links].permit!.to_h + raise Exceptions::UnprocessableEntity, 'Invalid link structure' if !link.is_a? 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| - 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| link = Link.add( link_type: link_type, @@ -399,7 +400,7 @@ class TicketsController < ApplicationController # do pagination if needed if params[:page] && params[:per_page] 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 if params[:expand] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1ff08c32c..599deb6c2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -378,7 +378,7 @@ class UsersController < ApplicationController # do pagination if needed if params[:page] && params[:per_page] 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 if params[:expand] diff --git a/app/models/application_model/can_associations.rb b/app/models/application_model/can_associations.rb index 488073ce3..0eb97ee03 100644 --- a/app/models/application_model/can_associations.rb +++ b/app/models/application_model/can_associations.rb @@ -293,6 +293,10 @@ returns def association_name_to_id_convert(params) + if params.respond_to?(:permit!) + params = params.permit!.to_h + end + data = {} params.each { |key, value| data[key.to_sym] = value diff --git a/app/models/application_model/can_cleanup_param.rb b/app/models/application_model/can_cleanup_param.rb index 7823ca0e7..16b823094 100644 --- a/app/models/application_model/can_cleanup_param.rb +++ b/app/models/application_model/can_cleanup_param.rb @@ -23,8 +23,8 @@ returns def param_cleanup(params, new_object = false) - if params.respond_to?('permit!') - params.permit! + if params.respond_to?(:permit!) + params = params.permit!.to_h end if params.nil? diff --git a/app/models/concerns/has_groups.rb b/app/models/concerns/has_groups.rb index b65c6b372..4b5788b19 100644 --- a/app/models/concerns/has_groups.rb +++ b/app/models/concerns/has_groups.rb @@ -257,7 +257,7 @@ module HasGroups end 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 # methods defined here are going to extend the class, not the instance of it diff --git a/app/models/cti/caller_id.rb b/app/models/cti/caller_id.rb index bbfaa26a2..22e77afcc 100644 --- a/app/models/cti/caller_id.rb +++ b/app/models/cti/caller_id.rb @@ -223,9 +223,9 @@ returns lookup(extract_numbers(caller_id)).each { |record| if record.level == 'known' - preferences_known[direction].push record + preferences_known[direction].push record.attributes else - preferences_maybe[direction].push record + preferences_maybe[direction].push record.attributes end comment = '' if record.user_id diff --git a/app/models/cti/log.rb b/app/models/cti/log.rb index 0d23718d7..d151d3d11 100644 --- a/app/models/cti/log.rb +++ b/app/models/cti/log.rb @@ -338,7 +338,7 @@ Cti::Log.process( log.comment = comment log.save else - raise ArgumentError, "Unknown event #{event}" + raise ArgumentError, "Unknown event #{event.inspect}" end end diff --git a/app/models/observer/organization/ref_object_touch.rb b/app/models/observer/organization/ref_object_touch.rb index beec37fd4..e48ab63c6 100644 --- a/app/models/observer/organization/ref_object_touch.rb +++ b/app/models/observer/organization/ref_object_touch.rb @@ -18,10 +18,10 @@ class Observer::Organization::RefObjectTouch < ActiveRecord::Observer def ref_object_touch(record) # 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 - return if User.where(organization_id: record.id).count > 100 + return true if User.where(organization_id: record.id).count > 100 # touch organizations tickets 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 - 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.with_lock do user.touch end } + true end end diff --git a/app/models/observer/user/ref_object_touch.rb b/app/models/observer/user/ref_object_touch.rb index b63f043dd..8aa92c765 100644 --- a/app/models/observer/user/ref_object_touch.rb +++ b/app/models/observer/user/ref_object_touch.rb @@ -18,7 +18,7 @@ class Observer::User::RefObjectTouch < ActiveRecord::Observer def ref_object_touch(record) # return if we run import mode - return if Setting.get('import_mode') + return true if Setting.get('import_mode') # touch old organization if changed member_ids = [] @@ -47,9 +47,9 @@ class Observer::User::RefObjectTouch < ActiveRecord::Observer # touch old/current customer member_ids.uniq.each { |user_id| - if user_id != record.id - User.find(user_id).touch - end + next if user_id == record.id + User.find(user_id).touch } + true end end diff --git a/app/models/organization/search.rb b/app/models/organization/search.rb index 5222842f3..42a8dd1ac 100644 --- a/app/models/organization/search.rb +++ b/app/models/organization/search.rb @@ -73,7 +73,7 @@ returns query.delete! '*' organizations = Organization.where( '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 organizations.length <= 3 diff --git a/app/models/overview.rb b/app/models/overview.rb index 57a3490f9..ffadc7cb6 100644 --- a/app/models/overview.rb +++ b/app/models/overview.rb @@ -42,7 +42,7 @@ class Overview < ApplicationModel def link_name(name) local_link = name.downcase - local_link = local_link.parameterize('_') + local_link = local_link.parameterize(separator: '_') local_link.gsub!(/\s/, '_') local_link.gsub!(/_+/, '_') local_link = URI.escape(local_link) diff --git a/app/models/role.rb b/app/models/role.rb index 2a362a4c0..319b8868a 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -114,7 +114,7 @@ returns permission_ids.push permission.id } 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 } } diff --git a/app/models/taskbar.rb b/app/models/taskbar.rb index 63c64d860..9c1be26c7 100644 --- a/app/models/taskbar.rb +++ b/app/models/taskbar.rb @@ -13,16 +13,15 @@ class Taskbar < ApplicationModel attr_accessor :local_update def state_changed? - return false if !state - return false if state.empty? + return false if state.blank? state.each { |_key, value| - if value.class == Hash || value.class == ActiveSupport::HashWithIndifferentAccess + if value.is_a? Hash value.each { |_key1, value1| - next if value1 && value1.empty? + next if value1.blank? return true } else - next if value && value.empty? + next if value.blank? return true end } diff --git a/app/models/user.rb b/app/models/user.rb index 90528a231..05db0b85d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -505,7 +505,7 @@ returns permission_ids.push permission.id } 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 } total_role_ids.push role_ids diff --git a/config/application.rb b/config/application.rb index 3721b5df5..79eef32c8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -12,11 +12,9 @@ module Zammad # Application configuration should go into files in config/initializers # -- 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. config.autoload_paths += %W(#{config.root}/lib) + config.eager_load_paths += %W(#{config.root}/lib) # Activate observers that should always be running. # config.active_record.observers = :cacher, :garbage_collector, :forum_observer diff --git a/config/environments/production.rb b/config/environments/production.rb index 5600b66ed..fe75e46f4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -22,7 +22,7 @@ Rails.application.configure do # Disable serving static files from the `/public` folder by default since # 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. config.assets.js_compressor = :uglifier diff --git a/config/environments/test.rb b/config/environments/test.rb index 99f46bed0..1fed9b588 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -13,8 +13,8 @@ Rails.application.configure do config.eager_load = false # Configure static file server for tests with Cache-Control for performance. - config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + config.public_file_server.enabled = true + config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' } # Show full error reports and disable caching. config.consider_all_requests_local = true diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 78708a076..0c3f16752 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -1,4 +1,4 @@ -class CreateBase < ActiveRecord::Migration +class CreateBase < ActiveRecord::Migration[4.2] def up # clear old caches to start from scratch diff --git a/db/migrate/20120101000010_create_ticket.rb b/db/migrate/20120101000010_create_ticket.rb index ab36bcfce..c7d5c9bbb 100644 --- a/db/migrate/20120101000010_create_ticket.rb +++ b/db/migrate/20120101000010_create_ticket.rb @@ -1,4 +1,4 @@ -class CreateTicket < ActiveRecord::Migration +class CreateTicket < ActiveRecord::Migration[4.2] def up create_table :ticket_state_types do |t| t.column :name, :string, limit: 250, null: false diff --git a/db/migrate/20120101000020_create_network.rb b/db/migrate/20120101000020_create_network.rb index 39c253342..aaa1fde0d 100644 --- a/db/migrate/20120101000020_create_network.rb +++ b/db/migrate/20120101000020_create_network.rb @@ -1,4 +1,4 @@ -class CreateNetwork < ActiveRecord::Migration +class CreateNetwork < ActiveRecord::Migration[4.2] def up create_table :networks do |t| t.column :name, :string, limit: 100, null: false diff --git a/db/migrate/20150979000001_update_timestamps.rb b/db/migrate/20150979000001_update_timestamps.rb index c4f52869b..4eae2c73b 100644 --- a/db/migrate/20150979000001_update_timestamps.rb +++ b/db/migrate/20150979000001_update_timestamps.rb @@ -1,4 +1,4 @@ -class UpdateTimestamps < ActiveRecord::Migration +class UpdateTimestamps < ActiveRecord::Migration[4.2] def up # get all models Models.all.each { |_model, value| diff --git a/db/migrate/20160217000001_object_manager_update_user.rb b/db/migrate/20160217000001_object_manager_update_user.rb index 0026a1a12..e9a0f007b 100644 --- a/db/migrate/20160217000001_object_manager_update_user.rb +++ b/db/migrate/20160217000001_object_manager_update_user.rb @@ -1,4 +1,4 @@ -class ObjectManagerUpdateUser < ActiveRecord::Migration +class ObjectManagerUpdateUser < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20160921000001_permission_active.rb.rb b/db/migrate/20160921000001_permission_active.rb.rb index e70098a4f..d54f70803 100644 --- a/db/migrate/20160921000001_permission_active.rb.rb +++ b/db/migrate/20160921000001_permission_active.rb.rb @@ -1,4 +1,4 @@ -class PermissionActive < ActiveRecord::Migration +class PermissionActive < ActiveRecord::Migration[4.2] def up # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') diff --git a/db/migrate/20161101131409_create_doorkeeper_tables.rb b/db/migrate/20161101131409_create_doorkeeper_tables.rb index da7c84353..2eee8558d 100644 --- a/db/migrate/20161101131409_create_doorkeeper_tables.rb +++ b/db/migrate/20161101131409_create_doorkeeper_tables.rb @@ -1,4 +1,4 @@ -class CreateDoorkeeperTables < ActiveRecord::Migration +class CreateDoorkeeperTables < ActiveRecord::Migration[4.2] def change create_table :oauth_applications do |t| t.string :name, null: false diff --git a/db/migrate/20161112000001_organization_domain_based_assignment.rb b/db/migrate/20161112000001_organization_domain_based_assignment.rb index 9d1763379..7ca282bc2 100644 --- a/db/migrate/20161112000001_organization_domain_based_assignment.rb +++ b/db/migrate/20161112000001_organization_domain_based_assignment.rb @@ -1,4 +1,4 @@ -class OrganizationDomainBasedAssignment < ActiveRecord::Migration +class OrganizationDomainBasedAssignment < ActiveRecord::Migration[4.2] def up # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') diff --git a/db/migrate/20161117000001_job_unable_to_create_issue_432.rb b/db/migrate/20161117000001_job_unable_to_create_issue_432.rb index db88c4348..4546ac018 100644 --- a/db/migrate/20161117000001_job_unable_to_create_issue_432.rb +++ b/db/migrate/20161117000001_job_unable_to_create_issue_432.rb @@ -1,4 +1,4 @@ -class JobUnableToCreateIssue432 < ActiveRecord::Migration +class JobUnableToCreateIssue432 < ActiveRecord::Migration[4.2] def up # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') diff --git a/db/migrate/20161117000002_ticket_number_generator_issue_427.rb b/db/migrate/20161117000002_ticket_number_generator_issue_427.rb index a0617ce04..05f440bcb 100644 --- a/db/migrate/20161117000002_ticket_number_generator_issue_427.rb +++ b/db/migrate/20161117000002_ticket_number_generator_issue_427.rb @@ -1,4 +1,4 @@ -class TicketNumberGeneratorIssue427 < ActiveRecord::Migration +class TicketNumberGeneratorIssue427 < ActiveRecord::Migration[4.2] def up # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') diff --git a/db/migrate/20161117000003_store_config_name_update_issue_428.rb b/db/migrate/20161117000003_store_config_name_update_issue_428.rb index b58668ed2..84697a0b2 100644 --- a/db/migrate/20161117000003_store_config_name_update_issue_428.rb +++ b/db/migrate/20161117000003_store_config_name_update_issue_428.rb @@ -1,4 +1,4 @@ -class StoreConfigNameUpdateIssue428 < ActiveRecord::Migration +class StoreConfigNameUpdateIssue428 < ActiveRecord::Migration[4.2] def up # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') diff --git a/db/migrate/20161122000001_monitoring_issue_453.rb b/db/migrate/20161122000001_monitoring_issue_453.rb index 769ea181f..03535fe45 100644 --- a/db/migrate/20161122000001_monitoring_issue_453.rb +++ b/db/migrate/20161122000001_monitoring_issue_453.rb @@ -1,4 +1,4 @@ -class MonitoringIssue453 < ActiveRecord::Migration +class MonitoringIssue453 < ActiveRecord::Migration[4.2] def up # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') diff --git a/db/migrate/20161228000001_add_taskbar_meta.rb b/db/migrate/20161228000001_add_taskbar_meta.rb index d67526c7f..a20ef07e7 100644 --- a/db/migrate/20161228000001_add_taskbar_meta.rb +++ b/db/migrate/20161228000001_add_taskbar_meta.rb @@ -1,4 +1,4 @@ -class AddTaskbarMeta < ActiveRecord::Migration +class AddTaskbarMeta < ActiveRecord::Migration[4.2] def up # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') diff --git a/db/migrate/20170113000001_object_manager_attribute_create_middle.rb b/db/migrate/20170113000001_object_manager_attribute_create_middle.rb index b805d7425..8e40c22f1 100644 --- a/db/migrate/20170113000001_object_manager_attribute_create_middle.rb +++ b/db/migrate/20170113000001_object_manager_attribute_create_middle.rb @@ -1,4 +1,4 @@ -class ObjectManagerAttributeCreateMiddle < ActiveRecord::Migration +class ObjectManagerAttributeCreateMiddle < ActiveRecord::Migration[4.2] def up # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') diff --git a/db/migrate/20170113000002_slack_group_config_issue_587.rb b/db/migrate/20170113000002_slack_group_config_issue_587.rb index 49a30f3b8..b3f541447 100644 --- a/db/migrate/20170113000002_slack_group_config_issue_587.rb +++ b/db/migrate/20170113000002_slack_group_config_issue_587.rb @@ -1,4 +1,4 @@ -class SlackGroupConfigIssue587 < ActiveRecord::Migration +class SlackGroupConfigIssue587 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170116000001_add_ticket_time_accounting_373.rb b/db/migrate/20170116000001_add_ticket_time_accounting_373.rb index c7a032ff6..e2b6adc3c 100644 --- a/db/migrate/20170116000001_add_ticket_time_accounting_373.rb +++ b/db/migrate/20170116000001_add_ticket_time_accounting_373.rb @@ -1,4 +1,4 @@ -class AddTicketTimeAccounting373 < ActiveRecord::Migration +class AddTicketTimeAccounting373 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170116000002_fixed_typos_622.rb b/db/migrate/20170116000002_fixed_typos_622.rb index cc52bd511..45af0bb51 100644 --- a/db/migrate/20170116000002_fixed_typos_622.rb +++ b/db/migrate/20170116000002_fixed_typos_622.rb @@ -1,4 +1,4 @@ -class FixedTypos622 < ActiveRecord::Migration +class FixedTypos622 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170117000001_unable_to_enable_time_accounting_633.rb b/db/migrate/20170117000001_unable_to_enable_time_accounting_633.rb index bc77ba80e..3e57eb1ad 100644 --- a/db/migrate/20170117000001_unable_to_enable_time_accounting_633.rb +++ b/db/migrate/20170117000001_unable_to_enable_time_accounting_633.rb @@ -1,4 +1,4 @@ -class UnableToEnableTimeAccounting633 < ActiveRecord::Migration +class UnableToEnableTimeAccounting633 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170119000001_login_email_length_650.rb b/db/migrate/20170119000001_login_email_length_650.rb index 513f8749f..8dde12b99 100644 --- a/db/migrate/20170119000001_login_email_length_650.rb +++ b/db/migrate/20170119000001_login_email_length_650.rb @@ -1,4 +1,4 @@ -class LoginEmailLength650 < ActiveRecord::Migration +class LoginEmailLength650 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170123000001_ui_ticket_zoom_article_new_internal.rb b/db/migrate/20170123000001_ui_ticket_zoom_article_new_internal.rb index 0bcedd951..bf48384d6 100644 --- a/db/migrate/20170123000001_ui_ticket_zoom_article_new_internal.rb +++ b/db/migrate/20170123000001_ui_ticket_zoom_article_new_internal.rb @@ -1,4 +1,4 @@ -class UiTicketZoomArticleNewInternal < ActiveRecord::Migration +class UiTicketZoomArticleNewInternal < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170123000002_fixed_translation.rb b/db/migrate/20170123000002_fixed_translation.rb index 0badda6cb..b11b72eb8 100644 --- a/db/migrate/20170123000002_fixed_translation.rb +++ b/db/migrate/20170123000002_fixed_translation.rb @@ -1,4 +1,4 @@ -class FixedTranslation < ActiveRecord::Migration +class FixedTranslation < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170126091128_application_secret_setting.rb b/db/migrate/20170126091128_application_secret_setting.rb index 6a81251eb..7529caf65 100644 --- a/db/migrate/20170126091128_application_secret_setting.rb +++ b/db/migrate/20170126091128_application_secret_setting.rb @@ -1,4 +1,4 @@ -class ApplicationSecretSetting < ActiveRecord::Migration +class ApplicationSecretSetting < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170130000001_follow_up_possible_check_643.rb b/db/migrate/20170130000001_follow_up_possible_check_643.rb index f2a6658be..392b4a58b 100644 --- a/db/migrate/20170130000001_follow_up_possible_check_643.rb +++ b/db/migrate/20170130000001_follow_up_possible_check_643.rb @@ -1,4 +1,4 @@ -class FollowUpPossibleCheck643 < ActiveRecord::Migration +class FollowUpPossibleCheck643 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170203000001_remove_last_login_from_history_722.rb b/db/migrate/20170203000001_remove_last_login_from_history_722.rb index ddb3a77d3..08e050edb 100644 --- a/db/migrate/20170203000001_remove_last_login_from_history_722.rb +++ b/db/migrate/20170203000001_remove_last_login_from_history_722.rb @@ -1,4 +1,4 @@ -class RemoveLastLoginFromHistory722 < ActiveRecord::Migration +class RemoveLastLoginFromHistory722 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170203000003_do_not_import_onw_notifications_731.rb b/db/migrate/20170203000003_do_not_import_onw_notifications_731.rb index e8a07064a..f0811e96b 100644 --- a/db/migrate/20170203000003_do_not_import_onw_notifications_731.rb +++ b/db/migrate/20170203000003_do_not_import_onw_notifications_731.rb @@ -1,4 +1,4 @@ -class DoNotImportOnwNotifications731 < ActiveRecord::Migration +class DoNotImportOnwNotifications731 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170207081400_ticket_state_priority_defaults.rb b/db/migrate/20170207081400_ticket_state_priority_defaults.rb index 471f8f1c8..7e976ab8f 100644 --- a/db/migrate/20170207081400_ticket_state_priority_defaults.rb +++ b/db/migrate/20170207081400_ticket_state_priority_defaults.rb @@ -1,4 +1,4 @@ -class TicketStatePriorityDefaults < ActiveRecord::Migration +class TicketStatePriorityDefaults < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170214000001_reload_online_browser_after_cors_csrf_changes.rb b/db/migrate/20170214000001_reload_online_browser_after_cors_csrf_changes.rb index bf33fc4ab..9b996c0af 100644 --- a/db/migrate/20170214000001_reload_online_browser_after_cors_csrf_changes.rb +++ b/db/migrate/20170214000001_reload_online_browser_after_cors_csrf_changes.rb @@ -1,4 +1,4 @@ -class ReloadOnlineBrowserAfterCorsCsrfChanges < ActiveRecord::Migration +class ReloadOnlineBrowserAfterCorsCsrfChanges < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170215000001_telegram_support.rb b/db/migrate/20170215000001_telegram_support.rb index af4153081..d9ac61ee8 100644 --- a/db/migrate/20170215000001_telegram_support.rb +++ b/db/migrate/20170215000001_telegram_support.rb @@ -1,4 +1,4 @@ -class TelegramSupport < ActiveRecord::Migration +class TelegramSupport < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170314000001_fixed_translation2.rb b/db/migrate/20170314000001_fixed_translation2.rb index 825dcea71..91d28c758 100644 --- a/db/migrate/20170314000001_fixed_translation2.rb +++ b/db/migrate/20170314000001_fixed_translation2.rb @@ -1,4 +1,4 @@ -class FixedTranslation2 < ActiveRecord::Migration +class FixedTranslation2 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170403000001_fixed_admin_user_permission_920.rb b/db/migrate/20170403000001_fixed_admin_user_permission_920.rb index 7c8b131ba..d132ae953 100644 --- a/db/migrate/20170403000001_fixed_admin_user_permission_920.rb +++ b/db/migrate/20170403000001_fixed_admin_user_permission_920.rb @@ -1,4 +1,4 @@ -class FixedAdminUserPermission920 < ActiveRecord::Migration +class FixedAdminUserPermission920 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170418000001_validate_agent_limit.rb b/db/migrate/20170418000001_validate_agent_limit.rb index 9b648d77c..32e9f30b6 100644 --- a/db/migrate/20170418000001_validate_agent_limit.rb +++ b/db/migrate/20170418000001_validate_agent_limit.rb @@ -1,4 +1,4 @@ -class ValidateAgentLimit < ActiveRecord::Migration +class ValidateAgentLimit < ActiveRecord::Migration[4.2] def up # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') diff --git a/db/migrate/20170419000001_ldap_support.rb b/db/migrate/20170419000001_ldap_support.rb index cd77b881a..1429e6627 100644 --- a/db/migrate/20170419000001_ldap_support.rb +++ b/db/migrate/20170419000001_ldap_support.rb @@ -1,4 +1,4 @@ -class LdapSupport < ActiveRecord::Migration +class LdapSupport < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170419000002_overview_role_ids.rb b/db/migrate/20170419000002_overview_role_ids.rb index be488bd07..a78d18492 100644 --- a/db/migrate/20170419000002_overview_role_ids.rb +++ b/db/migrate/20170419000002_overview_role_ids.rb @@ -1,4 +1,4 @@ -class OverviewRoleIds < ActiveRecord::Migration +class OverviewRoleIds < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170420000001_chat_increase_message_size.rb b/db/migrate/20170420000001_chat_increase_message_size.rb index 6b14384cd..382bdfa6d 100644 --- a/db/migrate/20170420000001_chat_increase_message_size.rb +++ b/db/migrate/20170420000001_chat_increase_message_size.rb @@ -1,4 +1,4 @@ -class ChatIncreaseMessageSize < ActiveRecord::Migration +class ChatIncreaseMessageSize < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170421000001_pretty_date_options_added.rb b/db/migrate/20170421000001_pretty_date_options_added.rb index 343def0f7..18ab212e2 100644 --- a/db/migrate/20170421000001_pretty_date_options_added.rb +++ b/db/migrate/20170421000001_pretty_date_options_added.rb @@ -1,4 +1,4 @@ -class PrettyDateOptionsAdded < ActiveRecord::Migration +class PrettyDateOptionsAdded < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170421110000_add_origin_by_id.rb b/db/migrate/20170421110000_add_origin_by_id.rb index 72887d8c6..c010e9cca 100644 --- a/db/migrate/20170421110000_add_origin_by_id.rb +++ b/db/migrate/20170421110000_add_origin_by_id.rb @@ -1,4 +1,4 @@ -class AddOriginById < ActiveRecord::Migration +class AddOriginById < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170426135500_add_reply_to.rb b/db/migrate/20170426135500_add_reply_to.rb index 51c5e5a2e..86cfec2fb 100644 --- a/db/migrate/20170426135500_add_reply_to.rb +++ b/db/migrate/20170426135500_add_reply_to.rb @@ -1,4 +1,4 @@ -class AddReplyTo < ActiveRecord::Migration +class AddReplyTo < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170504144100_follow_up_merged.rb b/db/migrate/20170504144100_follow_up_merged.rb index 6b0427763..73f31c66b 100644 --- a/db/migrate/20170504144100_follow_up_merged.rb +++ b/db/migrate/20170504144100_follow_up_merged.rb @@ -1,4 +1,4 @@ -class FollowUpMerged < ActiveRecord::Migration +class FollowUpMerged < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170515000001_scheduler_status.rb b/db/migrate/20170515000001_scheduler_status.rb index 6c55b2ff7..dcaa8ef87 100644 --- a/db/migrate/20170515000001_scheduler_status.rb +++ b/db/migrate/20170515000001_scheduler_status.rb @@ -1,4 +1,4 @@ -class SchedulerStatus < ActiveRecord::Migration +class SchedulerStatus < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170516000001_trigger_recipient_update.rb b/db/migrate/20170516000001_trigger_recipient_update.rb index a2ed60e87..bdeb18a96 100644 --- a/db/migrate/20170516000001_trigger_recipient_update.rb +++ b/db/migrate/20170516000001_trigger_recipient_update.rb @@ -1,4 +1,4 @@ -class TriggerRecipientUpdate < ActiveRecord::Migration +class TriggerRecipientUpdate < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170525000001_reply_to_sender_feature.rb b/db/migrate/20170525000001_reply_to_sender_feature.rb index ace1d8d5f..25982e6fa 100644 --- a/db/migrate/20170525000001_reply_to_sender_feature.rb +++ b/db/migrate/20170525000001_reply_to_sender_feature.rb @@ -1,4 +1,4 @@ -class ReplyToSenderFeature < ActiveRecord::Migration +class ReplyToSenderFeature < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170529000002_setting_delivery_permanent_failed.rb b/db/migrate/20170529000002_setting_delivery_permanent_failed.rb index aa299bb42..c830e1a90 100644 --- a/db/migrate/20170529000002_setting_delivery_permanent_failed.rb +++ b/db/migrate/20170529000002_setting_delivery_permanent_failed.rb @@ -1,4 +1,4 @@ -class SettingDeliveryPermanentFailed < ActiveRecord::Migration +class SettingDeliveryPermanentFailed < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170529132120_ldap_multi_group_mapping.rb b/db/migrate/20170529132120_ldap_multi_group_mapping.rb index 3c277aa23..25d450d51 100644 --- a/db/migrate/20170529132120_ldap_multi_group_mapping.rb +++ b/db/migrate/20170529132120_ldap_multi_group_mapping.rb @@ -1,4 +1,4 @@ -class LdapMultiGroupMapping < ActiveRecord::Migration +class LdapMultiGroupMapping < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170531144425_foreign_keys.rb b/db/migrate/20170531144425_foreign_keys.rb index 64bcedab0..696b79134 100644 --- a/db/migrate/20170531144425_foreign_keys.rb +++ b/db/migrate/20170531144425_foreign_keys.rb @@ -1,4 +1,4 @@ -class ForeignKeys < ActiveRecord::Migration +class ForeignKeys < ActiveRecord::Migration[4.2] disable_ddl_transaction! def change diff --git a/db/migrate/20170608151442_enhanced_permissions.rb b/db/migrate/20170608151442_enhanced_permissions.rb index 558741b10..4547c607b 100644 --- a/db/migrate/20170608151442_enhanced_permissions.rb +++ b/db/migrate/20170608151442_enhanced_permissions.rb @@ -1,4 +1,4 @@ -class EnhancedPermissions < ActiveRecord::Migration +class EnhancedPermissions < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170619000001_tree_select.rb b/db/migrate/20170619000001_tree_select.rb index 69dddaad7..8416568ac 100644 --- a/db/migrate/20170619000001_tree_select.rb +++ b/db/migrate/20170619000001_tree_select.rb @@ -1,4 +1,4 @@ -class TreeSelect < ActiveRecord::Migration +class TreeSelect < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170626000001_locale_add_direction.rb b/db/migrate/20170626000001_locale_add_direction.rb index 66fd8583c..5302ff115 100644 --- a/db/migrate/20170626000001_locale_add_direction.rb +++ b/db/migrate/20170626000001_locale_add_direction.rb @@ -1,4 +1,4 @@ -class LocaleAddDirection < ActiveRecord::Migration +class LocaleAddDirection < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170628000001_form_group_selection.rb b/db/migrate/20170628000001_form_group_selection.rb index a7a1b6c60..08ab93599 100644 --- a/db/migrate/20170628000001_form_group_selection.rb +++ b/db/migrate/20170628000001_form_group_selection.rb @@ -1,4 +1,4 @@ -class FormGroupSelection < ActiveRecord::Migration +class FormGroupSelection < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170629000001_exchange_integration.rb b/db/migrate/20170629000001_exchange_integration.rb index 88447f2c6..0db4f53ab 100644 --- a/db/migrate/20170629000001_exchange_integration.rb +++ b/db/migrate/20170629000001_exchange_integration.rb @@ -1,4 +1,4 @@ -class ExchangeIntegration < ActiveRecord::Migration +class ExchangeIntegration < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170713000001_omniauth_office365_setting.rb b/db/migrate/20170713000001_omniauth_office365_setting.rb index 147dbd508..59b2f1c17 100644 --- a/db/migrate/20170713000001_omniauth_office365_setting.rb +++ b/db/migrate/20170713000001_omniauth_office365_setting.rb @@ -1,4 +1,4 @@ -class OmniauthOffice365Setting < ActiveRecord::Migration +class OmniauthOffice365Setting < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170713000002_ticket_zoom_setting2.rb b/db/migrate/20170713000002_ticket_zoom_setting2.rb index 8147edc1f..a8025af44 100644 --- a/db/migrate/20170713000002_ticket_zoom_setting2.rb +++ b/db/migrate/20170713000002_ticket_zoom_setting2.rb @@ -1,4 +1,4 @@ -class TicketZoomSetting2 < ActiveRecord::Migration +class TicketZoomSetting2 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170714000001_object_manager_user_email_optional.rb b/db/migrate/20170714000001_object_manager_user_email_optional.rb index 4536130b6..447b5f257 100644 --- a/db/migrate/20170714000001_object_manager_user_email_optional.rb +++ b/db/migrate/20170714000001_object_manager_user_email_optional.rb @@ -1,4 +1,4 @@ -class ObjectManagerUserEmailOptional < ActiveRecord::Migration +class ObjectManagerUserEmailOptional < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170714000002_user_email_multiple_use.rb b/db/migrate/20170714000002_user_email_multiple_use.rb index 5d89d8d59..e260307bc 100644 --- a/db/migrate/20170714000002_user_email_multiple_use.rb +++ b/db/migrate/20170714000002_user_email_multiple_use.rb @@ -1,4 +1,4 @@ -class UserEmailMultipleUse < ActiveRecord::Migration +class UserEmailMultipleUse < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170714000003_cleanup_cti_log.rb b/db/migrate/20170714000003_cleanup_cti_log.rb index 4b9e59cbe..d46902091 100644 --- a/db/migrate/20170714000003_cleanup_cti_log.rb +++ b/db/migrate/20170714000003_cleanup_cti_log.rb @@ -1,4 +1,4 @@ -class CleanupCtiLog < ActiveRecord::Migration +class CleanupCtiLog < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170725000001_fixed_twitter_ticket_article_preferences3.rb b/db/migrate/20170725000001_fixed_twitter_ticket_article_preferences3.rb index 23e21acdb..71359ebc4 100644 --- a/db/migrate/20170725000001_fixed_twitter_ticket_article_preferences3.rb +++ b/db/migrate/20170725000001_fixed_twitter_ticket_article_preferences3.rb @@ -1,4 +1,4 @@ -class FixedTwitterTicketArticlePreferences3 < ActiveRecord::Migration +class FixedTwitterTicketArticlePreferences3 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170727000001_setting_proxy.rb b/db/migrate/20170727000001_setting_proxy.rb index 2634c3beb..0f69b9ed5 100644 --- a/db/migrate/20170727000001_setting_proxy.rb +++ b/db/migrate/20170727000001_setting_proxy.rb @@ -1,4 +1,4 @@ -class SettingProxy < ActiveRecord::Migration +class SettingProxy < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170816000001_idoit_support.rb b/db/migrate/20170816000001_idoit_support.rb index 8a8185b3e..acf8d7123 100644 --- a/db/migrate/20170816000001_idoit_support.rb +++ b/db/migrate/20170816000001_idoit_support.rb @@ -1,4 +1,4 @@ -class IdoitSupport < ActiveRecord::Migration +class IdoitSupport < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170820000001_check_mk_integration.rb b/db/migrate/20170820000001_check_mk_integration.rb index 8952108b6..c8d390a2b 100644 --- a/db/migrate/20170820000001_check_mk_integration.rb +++ b/db/migrate/20170820000001_check_mk_integration.rb @@ -1,4 +1,4 @@ -class CheckMkIntegration < ActiveRecord::Migration +class CheckMkIntegration < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170822000001_agend_based_sender_issue_1351.rb b/db/migrate/20170822000001_agend_based_sender_issue_1351.rb index 8095b238e..94c47d4a6 100644 --- a/db/migrate/20170822000001_agend_based_sender_issue_1351.rb +++ b/db/migrate/20170822000001_agend_based_sender_issue_1351.rb @@ -1,4 +1,4 @@ -class AgendBasedSenderIssue1351 < ActiveRecord::Migration +class AgendBasedSenderIssue1351 < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170826000001_out_of_office.rb b/db/migrate/20170826000001_out_of_office.rb index 133771c67..26cce7957 100644 --- a/db/migrate/20170826000001_out_of_office.rb +++ b/db/migrate/20170826000001_out_of_office.rb @@ -1,4 +1,4 @@ -class OutOfOffice < ActiveRecord::Migration +class OutOfOffice < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170830000001_last_owner_update.rb b/db/migrate/20170830000001_last_owner_update.rb index 004e12daf..58c633fea 100644 --- a/db/migrate/20170830000001_last_owner_update.rb +++ b/db/migrate/20170830000001_last_owner_update.rb @@ -1,4 +1,4 @@ -class LastOwnerUpdate < ActiveRecord::Migration +class LastOwnerUpdate < ActiveRecord::Migration[4.2] def up # return if it's a new setup diff --git a/db/migrate/20170905140038_cti_log_preferences_migration.rb b/db/migrate/20170905140038_cti_log_preferences_migration.rb new file mode 100644 index 000000000..56dcb6087 --- /dev/null +++ b/db/migrate/20170905140038_cti_log_preferences_migration.rb @@ -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 diff --git a/test/controllers/api_auth_controller_test.rb b/test/controllers/api_auth_controller_test.rb index 6b180fcb8..019ffd696 100644 --- a/test/controllers/api_auth_controller_test.rb +++ b/test/controllers/api_auth_controller_test.rb @@ -55,7 +55,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest admin_credentials = ActionController::HttpAuthentication::Basic.encode_credentials('api-admin@example.com', 'adminpw') 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_not(@response.header.key?('Access-Control-Allow-Origin')) result = JSON.parse(@response.body) @@ -63,7 +63,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest assert_equal('API password access disabled!', result['error']) 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_equal('*', @response.header['Access-Control-Allow-Origin']) 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') 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_not(@response.header.key?('Access-Control-Allow-Origin')) result = JSON.parse(@response.body) @@ -84,7 +84,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest assert_equal('API password access disabled!', result['error']) 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_equal('*', @response.header['Access-Control-Allow-Origin']) 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') 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_not(@response.header.key?('Access-Control-Allow-Origin')) result = JSON.parse(@response.body) @@ -105,7 +105,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest assert_equal('API password access disabled!', result['error']) 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_equal('*', @response.header['Access-Control-Allow-Origin']) result = JSON.parse(@response.body) @@ -126,7 +126,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest admin_credentials = "Token token=#{admin_token.name}" 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_not(@response.header.key?('Access-Control-Allow-Origin')) result = JSON.parse(@response.body) @@ -134,7 +134,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest assert_equal('API token access disabled!', result['error']) 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_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.save! - get '/api/v1/sessions', {}, @headers.merge('Authorization' => admin_credentials) + get '/api/v1/sessions', params: {}, headers: @headers.merge('Authorization' => admin_credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -154,7 +154,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest admin_token.preferences[:permission] = [] 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -163,7 +163,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest @admin.active = false @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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -172,7 +172,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest admin_token.preferences[:permission] = ['admin.session'] 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -181,13 +181,13 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest @admin.active = true @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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) 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) result = JSON.parse(@response.body) 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.save! - get '/api/v1/roles', {}, @headers.merge('Authorization' => admin_credentials) + get '/api/v1/roles', params: {}, headers: @headers.merge('Authorization' => admin_credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -205,14 +205,14 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest admin_token.preferences[:permission] = ['ticket.agent'] 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) result = JSON.parse(@response.body) assert_equal(Array, result.class) assert(result) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -220,7 +220,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest assert(result) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -230,14 +230,14 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest admin_token.preferences[:permission] = ['admin.organization'] 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) result = JSON.parse(@response.body) assert_equal(Array, result.class) assert(result) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -245,7 +245,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest assert(result) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -255,14 +255,14 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest admin_token.preferences[:permission] = ['admin'] 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) result = JSON.parse(@response.body) assert_equal(Array, result.class) assert(result) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -270,7 +270,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest assert(result) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -289,7 +289,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest agent_credentials = "Token token=#{agent_token.name}" 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_not(@response.header.key?('Access-Control-Allow-Origin')) result = JSON.parse(@response.body) @@ -297,21 +297,21 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest assert_equal('API token access disabled!', result['error']) 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_equal('*', @response.header['Access-Control-Allow-Origin']) result = JSON.parse(@response.body) assert_equal(Array, result.class) 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) result = JSON.parse(@response.body) assert_equal(Array, result.class) assert(result) 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) end @@ -326,7 +326,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest customer_credentials = "Token token=#{customer_token.name}" 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_not(@response.header.key?('Access-Control-Allow-Origin')) result = JSON.parse(@response.body) @@ -334,21 +334,21 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest assert_equal('API token access disabled!', result['error']) 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_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) 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) result = JSON.parse(@response.body) assert_equal(Array, result.class) assert(result) 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) end @@ -365,7 +365,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest @admin.save! 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_not(@response.header.key?('Access-Control-Allow-Origin')) result = JSON.parse(@response.body) @@ -373,7 +373,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest assert_equal('API token access disabled!', result['error']) 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_not(@response.header.key?('Access-Control-Allow-Origin')) result = JSON.parse(@response.body) @@ -393,7 +393,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest ) 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_not(@response.header.key?('Access-Control-Allow-Origin')) result = JSON.parse(@response.body) @@ -416,7 +416,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest ) 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_equal('*', @response.header['Access-Control-Allow-Origin']) result = JSON.parse(@response.body) @@ -429,11 +429,11 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest 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_response(201) - get '/api/v1/sessions', {} + get '/api/v1/sessions', params: {} assert_response(200) assert_not(@response.header.key?('Access-Control-Allow-Origin')) result = JSON.parse(@response.body) diff --git a/test/controllers/basic_controller_test.rb b/test/controllers/basic_controller_test.rb index 789058286..7c7c1bf5b 100644 --- a/test/controllers/basic_controller_test.rb +++ b/test/controllers/basic_controller_test.rb @@ -8,49 +8,49 @@ class BasicControllerTest < ActionDispatch::IntegrationTest @headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' } # 404 - get '/not_existing_url', {}, @headers + get '/not_existing_url', params: {}, headers: @headers assert_response(404) result = JSON.parse(@response.body) assert_equal(result.class, Hash) assert(result['error'], 'No route matches [GET] /not_existing_url') # 401 - get '/api/v1/organizations', {}, @headers + get '/api/v1/organizations', params: {}, headers: @headers assert_response(401) result = JSON.parse(@response.body) assert_equal(result.class, Hash) assert(result['error'], 'authentication failed') # 422 - get '/tests/unprocessable_entity', {}, @headers + get '/tests/unprocessable_entity', params: {}, headers: @headers assert_response(422) result = JSON.parse(@response.body) assert_equal(result.class, Hash) assert(result['error'], 'some error message') # 401 - get '/tests/not_authorized', {}, @headers + get '/tests/not_authorized', params: {}, headers: @headers assert_response(401) result = JSON.parse(@response.body) assert_equal(result.class, Hash) assert(result['error'], 'some error message') # 401 - get '/tests/ar_not_found', {}, @headers + get '/tests/ar_not_found', params: {}, headers: @headers assert_response(404) result = JSON.parse(@response.body) assert_equal(result.class, Hash) assert(result['error'], 'some error message') # 500 - get '/tests/standard_error', {}, @headers + get '/tests/standard_error', params: {}, headers: @headers assert_response(500) result = JSON.parse(@response.body) assert_equal(result.class, Hash) assert(result['error'], 'some error message') # 422 - get '/tests/argument_error', {}, @headers + get '/tests/argument_error', params: {}, headers: @headers assert_response(422) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -61,7 +61,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest test 'html requests' do # 404 - get '/not_existing_url', {}, @headers + get '/not_existing_url', params: {}, headers: @headers assert_response(404) assert_match(/404: Not Found}, @response.body) @@ -69,7 +69,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest assert_match(%r{No route matches \[GET\] /not_existing_url}, @response.body) # 401 - get '/api/v1/organizations', {}, @headers + get '/api/v1/organizations', params: {}, headers: @headers assert_response(401) assert_match(/401: Unauthorized}, @response.body) @@ -77,7 +77,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest assert_match(/authentication failed/, @response.body) # 422 - get '/tests/unprocessable_entity', {}, @headers + get '/tests/unprocessable_entity', params: {}, headers: @headers assert_response(422) assert_match(/422: Unprocessable Entity}, @response.body) @@ -85,7 +85,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest assert_match(/some error message/, @response.body) # 401 - get '/tests/not_authorized', {}, @headers + get '/tests/not_authorized', params: {}, headers: @headers assert_response(401) assert_match(/401: Unauthorized}, @response.body) @@ -93,7 +93,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest assert_match(/some error message/, @response.body) # 401 - get '/tests/ar_not_found', {}, @headers + get '/tests/ar_not_found', params: {}, headers: @headers assert_response(404) assert_match(/404: Not Found}, @response.body) @@ -101,7 +101,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest assert_match(/some error message/, @response.body) # 500 - get '/tests/standard_error', {}, @headers + get '/tests/standard_error', params: {}, headers: @headers assert_response(500) assert_match(/500: Something went wrong}, @response.body) @@ -109,7 +109,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest assert_match(/some error message/, @response.body) # 422 - get '/tests/argument_error', {}, @headers + get '/tests/argument_error', params: {}, headers: @headers assert_response(422) assert_match(/422: Unprocessable Entity}, @response.body) diff --git a/test/controllers/form_controller_test.rb b/test/controllers/form_controller_test.rb index 7637802d0..8aacf1157 100644 --- a/test/controllers/form_controller_test.rb +++ b/test/controllers/form_controller_test.rb @@ -41,7 +41,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest end 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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -50,7 +50,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest test '02 - get config call' do 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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -61,7 +61,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest test '03 - get config call & do submit' do Setting.set('form_ticket_create', true) 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) result = JSON.parse(@response.body) @@ -71,13 +71,13 @@ class FormControllerTest < ActionDispatch::IntegrationTest assert(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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) 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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -88,7 +88,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest assert_equal(result['errors']['title'], '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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -99,7 +99,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest assert_equal(result['errors']['title'], '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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -111,7 +111,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) @@ -124,7 +124,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest 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) end @@ -132,7 +132,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest test '04 - get config call & do submit' do Setting.set('form_ticket_create', true) 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) result = JSON.parse(@response.body) @@ -142,13 +142,13 @@ class FormControllerTest < ActionDispatch::IntegrationTest assert(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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) 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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -159,7 +159,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest assert_equal(result['errors']['title'], '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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -170,7 +170,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest assert_equal(result['errors']['title'], '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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -185,7 +185,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest Setting.set('form_ticket_create', true) 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) result = JSON.parse(@response.body) @@ -197,7 +197,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest (1..20).each { |count| 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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -212,7 +212,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -222,7 +222,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest (1..20).each { |count| 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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -237,7 +237,7 @@ class FormControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(result.class, Hash) diff --git a/test/controllers/integration_check_mk_controller_test.rb b/test/controllers/integration_check_mk_controller_test.rb index 6bef50bea..ae0465fe2 100644 --- a/test/controllers/integration_check_mk_controller_test.rb +++ b/test/controllers/integration_check_mk_controller_test.rb @@ -9,12 +9,12 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest end test '01 without token' do - post '/api/v1/integration/check_mk/', {} + post '/api/v1/integration/check_mk/', params: {} assert_response(404) end 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) result = JSON.parse(@response.body) @@ -25,7 +25,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest test '01 invalid token & disabled feature' do 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) result = JSON.parse(@response.body) @@ -40,7 +40,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest host: 'some host', 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) result = JSON.parse(@response.body) @@ -60,7 +60,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest host: 'some host', 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) result = JSON.parse(@response.body) @@ -81,7 +81,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest host: 'some host', 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) result = JSON.parse(@response.body) @@ -101,7 +101,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest host: 'some host', 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) result = JSON.parse(@response.body) @@ -120,7 +120,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest host: 'some host', 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) result = JSON.parse(@response.body) @@ -141,7 +141,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest host: 'some host', 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) result = JSON.parse(@response.body) @@ -158,7 +158,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest host: 'some host', 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) result = JSON.parse(@response.body) @@ -178,7 +178,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest host: 'some host', 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) result = JSON.parse(@response.body) @@ -197,7 +197,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest host: 'some host', 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) result = JSON.parse(@response.body) @@ -217,7 +217,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest state: 'down', 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) result = JSON.parse(@response.body) @@ -236,7 +236,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest state: 'down', 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) result = JSON.parse(@response.body) @@ -254,7 +254,7 @@ class IntegationCheckMkControllerTest < ActionDispatch::IntegrationTest state: 'up', 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) result = JSON.parse(@response.body) diff --git a/test/controllers/monitoring_controller_test.rb b/test/controllers/monitoring_controller_test.rb index fcd066e62..a511a95ee 100644 --- a/test/controllers/monitoring_controller_test.rb +++ b/test/controllers/monitoring_controller_test.rb @@ -80,7 +80,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest test '01 monitoring without token' do # health_check - get '/api/v1/monitoring/health_check', {}, @headers + get '/api/v1/monitoring/health_check', params: {}, headers: @headers assert_response(401) result = JSON.parse(@response.body) @@ -89,7 +89,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('Not authorized', result['error']) # status - get '/api/v1/monitoring/status', {}, @headers + get '/api/v1/monitoring/status', params: {}, headers: @headers assert_response(401) result = JSON.parse(@response.body) @@ -101,7 +101,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('Not authorized', result['error']) # token - post '/api/v1/monitoring/token', {}, @headers + post '/api/v1/monitoring/token', params: {}, headers: @headers assert_response(401) result = JSON.parse(@response.body) @@ -114,7 +114,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest test '02 monitoring with wrong token' do # 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) result = JSON.parse(@response.body) @@ -123,7 +123,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('Not authorized', result['error']) # status - get '/api/v1/monitoring/status?token=abc', {}, @headers + get '/api/v1/monitoring/status?token=abc', params: {}, headers: @headers assert_response(401) result = JSON.parse(@response.body) @@ -135,7 +135,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('Not authorized', result['error']) # 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) result = JSON.parse(@response.body) @@ -148,7 +148,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest test '03 monitoring with correct token' do # 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) result = JSON.parse(@response.body) @@ -158,7 +158,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('success', result['message']) # status - get "/api/v1/monitoring/status?token=#{@token}", {}, @headers + get "/api/v1/monitoring/status?token=#{@token}", params: {}, headers: @headers assert_response(200) result = JSON.parse(@response.body) @@ -170,7 +170,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert(result.key?('last_created_at')) # 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) result = JSON.parse(@response.body) @@ -185,7 +185,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-admin@example.com', 'adminpw') # 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) result = JSON.parse(@response.body) @@ -195,7 +195,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('success', result['message']) # status - get '/api/v1/monitoring/status', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/monitoring/status', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) @@ -207,7 +207,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert(result.key?('last_created_at')) # 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) result = JSON.parse(@response.body) @@ -223,7 +223,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-agent@example.com', 'agentpw') # 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) result = JSON.parse(@response.body) @@ -232,7 +232,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('Not authorized (user)!', result['error']) # status - get '/api/v1/monitoring/status', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/monitoring/status', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) @@ -244,7 +244,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('Not authorized (user)!', result['error']) # 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) result = JSON.parse(@response.body) @@ -263,7 +263,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('monitoring-admin@example.com', 'adminpw') # 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) result = JSON.parse(@response.body) @@ -272,7 +272,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('Not authorized (user)!', result['error']) # status - get '/api/v1/monitoring/status', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/monitoring/status', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) @@ -284,7 +284,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('Not authorized (user)!', result['error']) # 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) result = JSON.parse(@response.body) @@ -303,7 +303,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest permission.save! # 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) result = JSON.parse(@response.body) @@ -313,7 +313,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert_equal('success', result['message']) # status - get "/api/v1/monitoring/status?token=#{@token}", {}, @headers + get "/api/v1/monitoring/status?token=#{@token}", params: {}, headers: @headers assert_response(200) result = JSON.parse(@response.body) @@ -325,7 +325,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest assert(result.key?('last_created_at')) # 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) result = JSON.parse(@response.body) @@ -348,7 +348,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest channel.save! # 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) result = JSON.parse(@response.body) @@ -364,7 +364,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest scheduler.save! # 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) result = JSON.parse(@response.body) @@ -379,7 +379,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest FileUtils.touch("#{dir}/test.eml") # 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) result = JSON.parse(@response.body) @@ -393,7 +393,7 @@ class MonitoringControllerTest < ActionDispatch::IntegrationTest test '09 check restart_failed_jobs' do 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) end diff --git a/test/controllers/packages_controller_test.rb b/test/controllers/packages_controller_test.rb index 2ed452405..36d79343e 100644 --- a/test/controllers/packages_controller_test.rb +++ b/test/controllers/packages_controller_test.rb @@ -53,7 +53,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest test '01 packages index with nobody' do # index - get '/api/v1/packages', {}, @headers + get '/api/v1/packages', params: {}, headers: @headers assert_response(401) result = JSON.parse(@response.body) @@ -67,7 +67,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'adminpw') # index - get '/api/v1/packages', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/packages', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -79,7 +79,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'wrongadminpw') # index - get '/api/v1/packages', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/packages', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -93,7 +93,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'adminpw') # index - get '/api/v1/packages', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/packages', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -105,7 +105,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-agent@example.com', 'agentpw') # index - get '/api/v1/packages', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/packages', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) @@ -119,7 +119,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-customer1@example.com', 'customer1pw') # index - get '/api/v1/packages', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/packages', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) diff --git a/test/controllers/search_controller_test.rb b/test/controllers/search_controller_test.rb index dea48e6be..c483dab67 100644 --- a/test/controllers/search_controller_test.rb +++ b/test/controllers/search_controller_test.rb @@ -191,21 +191,21 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) assert_not(result.empty?) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) assert_not(result.empty?) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -220,7 +220,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest query: '1234*', 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -236,7 +236,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -256,7 +256,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -274,7 +274,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -291,7 +291,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -307,7 +307,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -327,7 +327,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -345,7 +345,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -362,7 +362,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -376,7 +376,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -390,7 +390,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -405,7 +405,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -421,7 +421,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -437,7 +437,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) diff --git a/test/controllers/settings_controller_test.rb b/test/controllers/settings_controller_test.rb index 06edbec7a..6206b8730 100644 --- a/test/controllers/settings_controller_test.rb +++ b/test/controllers/settings_controller_test.rb @@ -75,7 +75,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest test 'settings index with nobody' do # index - get '/api/v1/settings', {}, @headers + get '/api/v1/settings', params: {}, headers: @headers assert_response(401) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -83,7 +83,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest # show 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) result = JSON.parse(@response.body) 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') # index - get '/api/v1/settings', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/settings', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -114,14 +114,14 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest # show 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) assert_equal('product_name', result['name']) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -137,7 +137,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -156,7 +156,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -167,7 +167,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest # delete 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) result = JSON.parse(@response.body) 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') # index - get '/api/v1/settings', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/settings', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -198,13 +198,13 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest # show 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) result = JSON.parse(@response.body) assert_equal('Not authorized (required ["admin.branding"])', result['error']) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -220,7 +220,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal('Not authorized (required ["admin.branding"])', result['error']) @@ -235,7 +235,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -246,7 +246,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest # delete 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) result = JSON.parse(@response.body) 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') # index - get '/api/v1/settings', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/settings', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -266,7 +266,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest # show 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) result = JSON.parse(@response.body) 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') # index - get '/api/v1/settings', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/settings', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -286,14 +286,14 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest # show 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) result = JSON.parse(@response.body) assert_equal('Not authorized (user)!', result['error']) # delete 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) result = JSON.parse(@response.body) assert_equal('Not authorized (user)!', result['error']) diff --git a/test/controllers/ticket_article_attachments_controller_test.rb b/test/controllers/ticket_article_attachments_controller_test.rb index 5183a6abe..35bbc74eb 100644 --- a/test/controllers/ticket_article_attachments_controller_test.rb +++ b/test/controllers/ticket_article_attachments_controller_test.rb @@ -95,12 +95,12 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest ) 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_equal('some content', @response.body) 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_match(/401: Unauthorized/, @response.body) @@ -119,23 +119,23 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest ) 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_equal('some content', @response.body) 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_match(/401: Unauthorized/, @response.body) # allow access via merged ticket id also 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_equal('some content', @response.body) 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_match(/401: Unauthorized/, @response.body) diff --git a/test/controllers/ticket_articles_controller_test.rb b/test/controllers/ticket_articles_controller_test.rb index 78c054446..9119426bf 100644 --- a/test/controllers/ticket_articles_controller_test.rb +++ b/test/controllers/ticket_articles_controller_test.rb @@ -61,7 +61,7 @@ class TicketArticlesControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) @@ -71,7 +71,7 @@ class TicketArticlesControllerTest < ActionDispatch::IntegrationTest body: 'some body', 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -94,7 +94,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />', 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -127,7 +127,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO '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) result = JSON.parse(@response.body) 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[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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -164,7 +164,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 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) result = JSON.parse(@response.body) @@ -174,7 +174,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO body: 'some body', 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -197,7 +197,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO sender: 'Agent', 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -223,7 +223,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO type: 'note', 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) result = JSON.parse(@response.body) 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[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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -293,7 +293,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -317,7 +317,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) diff --git a/test/controllers/tickets_controller_test.rb b/test/controllers/tickets_controller_test.rb index 799eb78d4..b21aaee60 100644 --- a/test/controllers/tickets_controller_test.rb +++ b/test/controllers/tickets_controller_test.rb @@ -61,7 +61,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -80,7 +80,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -97,7 +97,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest customer_id: @customer_without_org.id, 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -116,7 +116,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -140,7 +140,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -160,7 +160,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest 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) #result = JSON.parse(@response.body) #assert_equal(Hash, result.class) @@ -188,7 +188,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -208,7 +208,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -231,7 +231,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -252,7 +252,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -273,7 +273,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest 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) result = JSON.parse(@response.body) 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) result = JSON.parse(@response.body) 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) result = JSON.parse(@response.body) 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) result = JSON.parse(@response.body) 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) result = JSON.parse(@response.body) 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) result = JSON.parse(@response.body) 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) result = JSON.parse(@response.body) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -540,7 +540,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO created_by_id: 1, ) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -549,13 +549,13 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO params = { 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -574,7 +574,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO created_by_id: 1, ) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -588,7 +588,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO title: "#{title} - 2", 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -603,7 +603,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO subject: 'some subject', 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) article_result = JSON.parse(@response.body) 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']) 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) result = JSON.parse(@response.body) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) assert_equal(ticket.id, result['tickets'][0]) 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) params = { @@ -651,7 +651,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO type: 'email', 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -668,7 +668,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO params = { 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) result = JSON.parse(@response.body) 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::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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -706,7 +706,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO created_by_id: 1, ) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -720,7 +720,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO title: 'ticket with corret ticket id - 2', 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -736,7 +736,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO subject: 'some subject', 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -754,7 +754,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO subject: 'new subject', 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) result = JSON.parse(@response.body) 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::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) params = { @@ -777,7 +777,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO body: 'some body', 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) result = JSON.parse(@response.body) 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::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) - 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) end @@ -826,7 +826,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO } 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -834,7 +834,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO assert_equal(tickets[0].id, result['tickets'][19]) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -842,7 +842,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO assert_equal(tickets[10].id, result['tickets'][9]) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -850,7 +850,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO assert_equal(tickets[15].id, result['tickets'][4]) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -858,7 +858,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO assert_equal(tickets[10].id, result['tickets'][4]) 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) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -867,7 +867,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO assert_equal(tickets[4].id, result[4]['id']) 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) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -889,7 +889,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -914,7 +914,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -936,7 +936,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO created_by_id: 1, ) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -945,13 +945,13 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO params = { 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -970,7 +970,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO created_by_id: 1, ) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -984,7 +984,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO title: "#{title} - 2", 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -999,7 +999,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO subject: 'some subject', 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) article_result = JSON.parse(@response.body) 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']) 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) result = JSON.parse(@response.body) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) assert_equal(ticket.id, result['tickets'][0]) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -1048,7 +1048,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO type: 'email', 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) result = JSON.parse(@response.body) 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::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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -1077,7 +1077,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) @@ -1094,13 +1094,13 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO params = { 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) 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) result = JSON.parse(@response.body) assert_equal(Hash, result.class) diff --git a/test/controllers/user_organization_controller_test.rb b/test/controllers/user_organization_controller_test.rb index 4754a75de..e4b453c5f 100644 --- a/test/controllers/user_organization_controller_test.rb +++ b/test/controllers/user_organization_controller_test.rb @@ -87,7 +87,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest test 'user create tests - no user' do - post '/api/v1/signshow', {}, @headers + post '/api/v1/signshow', params: {}, headers: @headers # create user with disabled feature Setting.set('user_create_account', false) @@ -95,7 +95,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # token based on form params = { email: 'some_new_customer@example.com', authenticity_token: token } - post '/api/v1/users', params.to_json, @headers + post '/api/v1/users', params: params.to_json, headers: @headers assert_response(422) result = JSON.parse(@response.body) assert(result['error']) @@ -104,7 +104,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # token based on headers headers = @headers.merge('X-CSRF-Token' => token) params = { email: 'some_new_customer@example.com' } - post '/api/v1/users', params.to_json, headers + post '/api/v1/users', params: params.to_json, headers: headers assert_response(422) result = JSON.parse(@response.body) assert(result['error']) @@ -114,7 +114,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # no signup param with enabled feature params = { email: 'some_new_customer@example.com' } - post '/api/v1/users', params.to_json, headers + post '/api/v1/users', params: params.to_json, headers: headers assert_response(422) result = JSON.parse(@response.body) assert(result['error']) @@ -122,7 +122,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # already existing user with enabled feature params = { email: 'rest-customer1@example.com', signup: true } - post '/api/v1/users', params.to_json, headers + post '/api/v1/users', params: params.to_json, headers: headers assert_response(422) result = JSON.parse(@response.body) assert(result['error']) @@ -130,7 +130,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # email missing with enabled feature params = { firstname: 'some firstname', signup: true } - post '/api/v1/users', params.to_json, headers + post '/api/v1/users', params: params.to_json, headers: headers assert_response(422) result = JSON.parse(@response.body) assert(result['error']) @@ -138,7 +138,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # email missing with enabled feature params = { firstname: 'some firstname', signup: true } - post '/api/v1/users', params.to_json, headers + post '/api/v1/users', params: params.to_json, headers: headers assert_response(422) result = JSON.parse(@response.body) assert(result['error']) @@ -146,7 +146,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # create user with enabled feature (take customer role) params = { firstname: 'Me First', lastname: 'Me Last', email: 'new_here@example.com', signup: true } - post '/api/v1/users', params.to_json, headers + post '/api/v1/users', params: params.to_json, headers: headers assert_response(201) result = JSON.parse(@response.body) assert(result) @@ -163,7 +163,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # create user with admin role (not allowed for signup, take customer role) role = Role.lookup(name: 'Admin') params = { firstname: 'Admin First', lastname: 'Admin Last', email: 'new_admin@example.com', role_ids: [ role.id ], signup: true } - post '/api/v1/users', params.to_json, headers + post '/api/v1/users', params: params.to_json, headers: headers assert_response(201) result = JSON.parse(@response.body) assert(result) @@ -175,7 +175,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # create user with agent role (not allowed for signup, take customer role) role = Role.lookup(name: 'Agent') params = { firstname: 'Agent First', lastname: 'Agent Last', email: 'new_agent@example.com', role_ids: [ role.id ], signup: true } - post '/api/v1/users', params.to_json, headers + post '/api/v1/users', params: params.to_json, headers: headers assert_response(201) result = JSON.parse(@response.body) assert(result) @@ -185,13 +185,13 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest assert(user.role?('Customer')) # no user (because of no session) - get '/api/v1/users', {}, headers + get '/api/v1/users', params: {}, headers: headers assert_response(401) result = JSON.parse(@response.body) assert_equal('authentication failed', result['error']) # me - get '/api/v1/users/me', {}, headers + get '/api/v1/users/me', params: {}, headers: headers assert_response(401) result = JSON.parse(@response.body) assert_equal('authentication failed', result['error']) @@ -201,12 +201,12 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('not_existing@example.com', 'adminpw') # me - get '/api/v1/users/me', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users/me', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal('authentication failed', result['error']) - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal('authentication failed', result['error']) @@ -215,7 +215,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest test 'auth tests - username auth, wrong pw' do credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-admin', 'not_existing') - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal('authentication failed', result['error']) @@ -224,7 +224,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest test 'auth tests - email auth, wrong pw' do credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-admin@example.com', 'not_existing') - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal('authentication failed', result['error']) @@ -233,7 +233,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest test 'auth tests - username auth' do credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-admin', 'adminpw') - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) @@ -242,7 +242,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest test 'auth tests - email auth' do credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-admin@example.com', 'adminpw') - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) @@ -254,20 +254,20 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-admin@example.com', 'adminpw') # me - get '/api/v1/users/me', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users/me', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) assert_equal(result['email'], 'rest-admin@example.com') # index - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) # index - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) @@ -275,14 +275,14 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest assert(result.length >= 3) # show/:id - get "/api/v1/users/#{@agent.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/#{@agent.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) assert_equal(result.class, Hash) assert_equal(result['email'], 'rest-agent@example.com') - get "/api/v1/users/#{@customer_without_org.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/#{@customer_without_org.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) @@ -292,7 +292,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # create user with admin role role = Role.lookup(name: 'Admin') params = { firstname: 'Admin First', lastname: 'Admin Last', email: 'new_admin_by_admin@example.com', role_ids: [ role.id ] } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(201) result = JSON.parse(@response.body) assert(result) @@ -306,7 +306,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # create user with agent role role = Role.lookup(name: 'Agent') params = { firstname: 'Agent First', lastname: 'Agent Last', email: 'new_agent_by_admin1@example.com', role_ids: [ role.id ] } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(201) result = JSON.parse(@response.body) assert(result) @@ -319,7 +319,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest role = Role.lookup(name: 'Agent') params = { firstname: 'Agent First', email: 'new_agent_by_admin2@example.com', role_ids: [ role.id ] } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(201) result = JSON.parse(@response.body) assert(result) @@ -334,7 +334,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest role = Role.lookup(name: 'Agent') params = { firstname: 'Agent First', email: 'new_agent_by_admin2@example.com', role_ids: [ role.id ] } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(422) result = JSON.parse(@response.body) assert(result) @@ -342,7 +342,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # missing required attributes params = { note: 'some note' } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(422) result = JSON.parse(@response.body) assert(result) @@ -350,7 +350,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # invalid email params = { firstname: 'newfirstname123', email: 'some_what', note: 'some note' } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(422) result = JSON.parse(@response.body) assert(result) @@ -358,7 +358,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # with valid attributes params = { firstname: 'newfirstname123', note: 'some note' } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(201) result = JSON.parse(@response.body) assert(result) @@ -377,27 +377,27 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-agent@example.com', 'agentpw') # me - get '/api/v1/users/me', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users/me', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) assert_equal(result['email'], 'rest-agent@example.com') # index - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) # index - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) assert_equal(result.class, Array) assert(result.length >= 3) - get '/api/v1/users?limit=40&page=1&per_page=2', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users?limit=40&page=1&per_page=2', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -406,7 +406,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest assert_equal(users[1].id, result[1]['id']) assert_equal(2, result.count) - get '/api/v1/users?limit=40&page=2&per_page=2', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users?limit=40&page=2&per_page=2', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -419,7 +419,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest firstname = "First test#{rand(999_999_999)}" role = Role.lookup(name: 'Admin') params = { firstname: "Admin#{firstname}", lastname: 'Admin Last', email: 'new_admin_by_agent@example.com', role_ids: [ role.id ] } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(201) result_user1 = JSON.parse(@response.body) assert(result_user1) @@ -433,7 +433,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # create user with agent role role = Role.lookup(name: 'Agent') params = { firstname: "Agent#{firstname}", lastname: 'Agent Last', email: 'new_agent_by_agent@example.com', role_ids: [ role.id ] } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(201) result_user1 = JSON.parse(@response.body) assert(result_user1) @@ -447,7 +447,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # create user with customer role role = Role.lookup(name: 'Customer') params = { firstname: "Customer#{firstname}", lastname: 'Customer Last', email: 'new_customer_by_agent@example.com', role_ids: [ role.id ] } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(201) result_user1 = JSON.parse(@response.body) assert(result_user1) @@ -460,7 +460,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # search as agent Scheduler.worker(true) - get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -470,7 +470,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest assert(result[0]['role_ids']) assert_not(result[0]['roles']) - get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&expand=true", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&expand=true", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -480,7 +480,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest assert(result[0]['role_ids']) assert(result[0]['roles']) - get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&label=true", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&label=true", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -496,27 +496,27 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-customer1@example.com', 'customer1pw') # me - get '/api/v1/users/me', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users/me', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) assert_equal(result['email'], 'rest-customer1@example.com') # index - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Array) assert_equal(result.length, 1) # show/:id - get "/api/v1/users/#{@customer_without_org.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/#{@customer_without_org.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Hash) assert_equal(result['email'], 'rest-customer1@example.com') - get "/api/v1/users/#{@customer_with_org.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/#{@customer_with_org.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -525,18 +525,18 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # create user with admin role role = Role.lookup(name: 'Admin') params = { firstname: 'Admin First', lastname: 'Admin Last', email: 'new_admin_by_customer1@example.com', role_ids: [ role.id ] } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(401) # create user with agent role role = Role.lookup(name: 'Agent') params = { firstname: 'Agent First', lastname: 'Agent Last', email: 'new_agent_by_customer1@example.com', role_ids: [ role.id ] } - post '/api/v1/users', params.to_json, @headers.merge('Authorization' => credentials) + post '/api/v1/users', params: params.to_json, headers: @headers.merge('Authorization' => credentials) assert_response(401) # search Scheduler.worker(true) - get "/api/v1/users/search?query=#{CGI.escape('First')}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/search?query=#{CGI.escape('First')}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) end @@ -545,27 +545,27 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-customer2@example.com', 'customer2pw') # me - get '/api/v1/users/me', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users/me', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert(result) assert_equal(result['email'], 'rest-customer2@example.com') # index - get '/api/v1/users', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/users', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Array) assert_equal(result.length, 1) # show/:id - get "/api/v1/users/#{@customer_with_org.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/#{@customer_with_org.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Hash) assert_equal(result['email'], 'rest-customer2@example.com') - get "/api/v1/users/#{@customer_without_org.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/#{@customer_without_org.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -573,7 +573,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # search Scheduler.worker(true) - get "/api/v1/users/search?query=#{CGI.escape('First')}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/users/search?query=#{CGI.escape('First')}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) end @@ -582,14 +582,14 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-agent@example.com', 'agentpw') # index - get '/api/v1/organizations', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/organizations', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Array) assert_equal(result[0]['member_ids'].class, Array) assert(result.length >= 3) - get '/api/v1/organizations?limit=40&page=1&per_page=2', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/organizations?limit=40&page=1&per_page=2', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -600,7 +600,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest assert_equal(organizations[1].member_ids, result[1]['member_ids']) assert_equal(2, result.count) - get '/api/v1/organizations?limit=40&page=2&per_page=2', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/organizations?limit=40&page=2&per_page=2', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -613,7 +613,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest assert_equal(2, result.count) # show/:id - get "/api/v1/organizations/#{@organization.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/#{@organization.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -621,7 +621,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest assert_not(result['members']) assert_equal(result['name'], 'Rest Org') - get "/api/v1/organizations/#{@organization2.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/#{@organization2.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -631,7 +631,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # search as agent Scheduler.worker(true) - get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -639,7 +639,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest assert(result[0]['member_ids']) assert_not(result[0]['members']) - get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}&expand=true", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}&expand=true", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -647,7 +647,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest assert(result[0]['member_ids']) assert(result[0]['members']) - get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}&label=true", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}&label=true", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(Array, result.class) @@ -662,20 +662,20 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-customer1@example.com', 'customer1pw') # index - get '/api/v1/organizations', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/organizations', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Array) assert_equal(result.length, 0) # show/:id - get "/api/v1/organizations/#{@organization.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/#{@organization.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Hash) assert_nil(result['name']) - get "/api/v1/organizations/#{@organization2.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/#{@organization2.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -683,7 +683,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # search Scheduler.worker(true) - get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) end @@ -692,20 +692,20 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-customer2@example.com', 'customer2pw') # index - get '/api/v1/organizations', {}, @headers.merge('Authorization' => credentials) + get '/api/v1/organizations', params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Array) assert_equal(result.length, 1) # show/:id - get "/api/v1/organizations/#{@organization.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/#{@organization.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result.class, Hash) assert_equal(result['name'], 'Rest Org') - get "/api/v1/organizations/#{@organization2.id}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/#{@organization2.id}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) result = JSON.parse(@response.body) assert_equal(result.class, Hash) @@ -713,7 +713,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest # search Scheduler.worker(true) - get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", {}, @headers.merge('Authorization' => credentials) + get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", params: {}, headers: @headers.merge('Authorization' => credentials) assert_response(401) end diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration/sipgate_controller_test.rb b/test/integration/sipgate_controller_test.rb index 4eca490a4..26eecf6e6 100644 --- a/test/integration/sipgate_controller_test.rb +++ b/test/integration/sipgate_controller_test.rb @@ -95,7 +95,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - I params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&callId=4991155921769858278-1&user%5B%5D=user+1&user%5B%5D=user+2' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) on_hangup = nil on_answer = nil @@ -110,7 +110,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - II - block caller params = 'event=newCall&direction=in&from=491715000000&to=4930600000000&callId=4991155921769858278-2&user%5B%5D=user+1&user%5B%5D=user+2' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) on_hangup = nil on_answer = nil @@ -130,7 +130,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # outbound - I - set default_caller_id params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&callId=8621106404543334274-3&user%5B%5D=user+1' - post '/api/v1/sipgate/out', params + post '/api/v1/sipgate/out', params: params assert_response(200) on_hangup = nil on_answer = nil @@ -155,7 +155,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # outbound - II - set caller_id based on routing_table by explicite number params = 'event=newCall&direction=out&from=4930600000000&to=491714000000&callId=8621106404543334274-4&user%5B%5D=user+1' - post '/api/v1/sipgate/out', params + post '/api/v1/sipgate/out', params: params assert_response(200) on_hangup = nil on_answer = nil @@ -180,7 +180,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # outbound - III - set caller_id based on routing_table by 41* params = 'event=newCall&direction=out&from=4930600000000&to=4147110000000&callId=8621106404543334274-5&user%5B%5D=user+1' - post '/api/v1/sipgate/out', params + post '/api/v1/sipgate/out', params: params assert_response(200) on_hangup = nil on_answer = nil @@ -206,7 +206,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # no config Setting.set('sipgate_config', {}) params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&callId=4991155921769858278-6&user%5B%5D=user+1&user%5B%5D=user+2' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(422) error = nil content = @response.body @@ -222,7 +222,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # outbound - I - new call params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&callId=1234567890-1&user%5B%5D=user+1' - post '/api/v1/sipgate/out', params + post '/api/v1/sipgate/out', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-1') assert(log) @@ -237,7 +237,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # outbound - I - hangup by agent params = 'event=hangup&direction=out&callId=1234567890-1&cause=cancel' - post '/api/v1/sipgate/out', params + post '/api/v1/sipgate/out', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-1') assert(log) @@ -252,7 +252,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # outbound - II - new call params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&callId=1234567890-2&user%5B%5D=user+1' - post '/api/v1/sipgate/out', params + post '/api/v1/sipgate/out', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-2') assert(log) @@ -267,7 +267,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # outbound - II - answer by customer params = 'event=answer&direction=out&callId=1234567890-2&from=4930600000000&to=4912347114711' - post '/api/v1/sipgate/out', params + post '/api/v1/sipgate/out', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-2') assert(log) @@ -282,7 +282,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # outbound - II - hangup by customer params = 'event=hangup&direction=out&callId=1234567890-2&cause=normalClearing&from=4930600000000&to=4912347114711' - post '/api/v1/sipgate/out', params + post '/api/v1/sipgate/out', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-2') assert(log) @@ -297,7 +297,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - I - new call params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&callId=1234567890-3&user%5B%5D=user+1' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-3') assert(log) @@ -312,7 +312,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - I - answer by customer params = 'event=answer&direction=in&callId=1234567890-3&to=4930600000000&from=4912347114711' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-3') assert(log) @@ -327,7 +327,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - I - hangup by customer params = 'event=hangup&direction=in&callId=1234567890-3&cause=normalClearing&to=4930600000000&from=4912347114711' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-3') assert(log) @@ -342,7 +342,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - II - new call params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&callId=1234567890-4&user%5B%5D=user+1,user+2' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-4') assert(log) @@ -357,7 +357,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - II - answer by voicemail params = 'event=answer&direction=in&callId=1234567890-4&to=4930600000000&from=4912347114711&user=voicemail' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-4') assert(log) @@ -372,7 +372,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - II - hangup by customer params = 'event=hangup&direction=in&callId=1234567890-4&cause=normalClearing&to=4930600000000&from=4912347114711' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-4') assert(log) @@ -387,7 +387,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - III - new call params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&callId=1234567890-5&user%5B%5D=user+1,user+2' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-5') assert(log) @@ -402,7 +402,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - III - hangup by customer params = 'event=hangup&direction=in&callId=1234567890-5&cause=normalClearing&to=4930600000000&from=4912347114711' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-5') assert(log) @@ -417,7 +417,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest # inbound - IV - new call params = 'event=newCall&direction=in&to=4930600000000&from=49999992222222&callId=1234567890-6&user%5B%5D=user+1,user+2' - post '/api/v1/sipgate/in', params + post '/api/v1/sipgate/in', params: params assert_response(200) log = Cti::Log.find_by(call_id: '1234567890-6') assert(log) @@ -441,7 +441,7 @@ class SipgateControllerTest < ActionDispatch::IntegrationTest headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' } credentials = ActionController::HttpAuthentication::Basic.encode_credentials('cti-agent@example.com', 'agentpw') - get '/api/v1/cti/log', {}, headers.merge('Authorization' => credentials) + get '/api/v1/cti/log', headers: headers.merge('Authorization' => credentials) assert_response(200) result = JSON.parse(@response.body) assert_equal(result['list'].class, Array) diff --git a/test/integration/telegram_controller_test.rb b/test/integration/telegram_controller_test.rb index 25d0d5604..83d73971b 100644 --- a/test/integration/telegram_controller_test.rb +++ b/test/integration/telegram_controller_test.rb @@ -72,27 +72,27 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest UserInfo.current_user_id = nil # start communication #1 - post '/api/v1/channels/telegram_webhook', read_messaage('personal1_message_start'), @headers + post '/api/v1/channels/telegram_webhook', params: read_messaage('personal1_message_start'), headers: @headers assert_response(404) result = JSON.parse(@response.body) - post '/api/v1/channels_telegram_webhook/not_existing', read_messaage('personal1_message_start'), @headers + post '/api/v1/channels_telegram_webhook/not_existing', params: read_messaage('personal1_message_start'), headers: @headers assert_response(422) result = JSON.parse(@response.body) assert_equal('bot param missing', result['error']) callback_url = "/api/v1/channels_telegram_webhook/not_existing?bid=#{channel.options[:bot][:id]}" - post callback_url, read_messaage('personal1_message_start'), @headers + post callback_url, params: read_messaage('personal1_message_start'), headers: @headers assert_response(422) result = JSON.parse(@response.body) assert_equal('invalid callback token', result['error']) callback_url = "/api/v1/channels_telegram_webhook/#{channel.options[:callback_token]}?bid=#{channel.options[:bot][:id]}" - post callback_url, read_messaage('personal1_message_start'), @headers + post callback_url, params: read_messaage('personal1_message_start'), headers: @headers assert_response(200) # send message1 - post callback_url, read_messaage('personal1_message_content1'), @headers + post callback_url, params: read_messaage('personal1_message_content1'), headers: @headers assert_response(200) assert_equal(1, Ticket.count) ticket = Ticket.last @@ -103,7 +103,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest assert_equal('text/plain', ticket.articles.first.content_type) # send same message again, ignore it - post callback_url, read_messaage('personal1_message_content1'), @headers + post callback_url, params: read_messaage('personal1_message_content1'), headers: @headers assert_response(200) ticket = Ticket.last assert_equal('Hello, I need your Help', ticket.title) @@ -113,7 +113,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest assert_equal('text/plain', ticket.articles.first.content_type) # send message2 - post callback_url, read_messaage('personal1_message_content2'), @headers + post callback_url, params: read_messaage('personal1_message_content2'), headers: @headers assert_response(200) ticket = Ticket.last assert_equal('Hello, I need your Help', ticket.title) @@ -123,7 +123,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest assert_equal('text/plain', ticket.articles.last.content_type) # send end message - post callback_url, read_messaage('personal1_message_end'), @headers + post callback_url, params: read_messaage('personal1_message_end'), headers: @headers assert_response(200) ticket = Ticket.last assert_equal('Hello, I need your Help', ticket.title) @@ -133,11 +133,11 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest assert_equal('text/plain', ticket.articles.last.content_type) # start communication #2 - post callback_url, read_messaage('personal2_message_start'), @headers + post callback_url, params: read_messaage('personal2_message_start'), headers: @headers assert_response(200) # send message1 - post callback_url, read_messaage('personal2_message_content1'), @headers + post callback_url, params: read_messaage('personal2_message_content1'), headers: @headers assert_response(200) assert_equal(2, Ticket.count) ticket = Ticket.last @@ -148,7 +148,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest assert_equal('text/plain', ticket.articles.first.content_type) # send message2 - post callback_url, read_messaage('personal2_message_content2'), @headers + post callback_url, params: read_messaage('personal2_message_content2'), headers: @headers assert_response(200) assert_equal(2, Ticket.count) ticket = Ticket.last @@ -159,11 +159,11 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest assert_equal('text/plain', ticket.articles.last.content_type) # start communication #3 - post callback_url, read_messaage('personal3_message_start'), @headers + post callback_url, params: read_messaage('personal3_message_start'), headers: @headers assert_response(200) # send message1 - post callback_url, read_messaage('personal3_message_content1'), @headers + post callback_url, params: read_messaage('personal3_message_content1'), headers: @headers assert_response(200) assert_equal(3, Ticket.count) ticket = Ticket.last @@ -179,7 +179,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest stub_request(:get, "https://api.telegram.org/file/bot#{token}/abc123") .to_return(status: 200, body: 'ABC1', headers: {}) - post callback_url, read_messaage('personal3_message_content2'), @headers + post callback_url, params: read_messaage('personal3_message_content2'), headers: @headers assert_response(200) assert_equal(3, Ticket.count) ticket = Ticket.last @@ -197,7 +197,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest stub_request(:get, "https://api.telegram.org/bot#{token}/getFile?file_id=BQADAgADDgAD7x6ZSC_-1LMkOEmoAg") .to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123BQADAgADDgAD7x6ZSC_-1LMkOEmoAg","file_path":"abc123"}}', headers: {}) - post callback_url, read_messaage('personal3_message_content3'), @headers + post callback_url, params: read_messaage('personal3_message_content3'), headers: @headers assert_response(200) assert_equal(3, Ticket.count) ticket = Ticket.last @@ -209,7 +209,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest assert_equal(1, ticket.articles.last.attachments.count) # update message1 - post callback_url, read_messaage('personal3_message_content4'), @headers + post callback_url, params: read_messaage('personal3_message_content4'), headers: @headers assert_response(200) assert_equal(3, Ticket.count) ticket = Ticket.last @@ -227,7 +227,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest stub_request(:get, "https://api.telegram.org/bot#{token}/getFile?file_id=AwADAgADVQADCEIYSZwyOmSZK9iZAg") .to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123AwADAgADVQADCEIYSZwyOmSZK9iZAg","file_path":"abc123"}}', headers: {}) - post callback_url, read_messaage('personal3_message_content5'), @headers + post callback_url, params: read_messaage('personal3_message_content5'), headers: @headers assert_response(200) assert_equal(3, Ticket.count) ticket = Ticket.last @@ -243,7 +243,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest stub_request(:get, "https://api.telegram.org/bot#{token}/getFile?file_id=BQADAwAD0QIAAqbJWAAB8OkQqgtDQe0C") .to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123BQADAwAD0QIAAqbJWAAB8OkQqgtDQe0C","file_path":"abc123"}}', headers: {}) - post callback_url, read_messaage('personal4_message_content1'), @headers + post callback_url, params: read_messaage('personal4_message_content1'), headers: @headers assert_response(200) assert_equal(4, Ticket.count) ticket = Ticket.last @@ -262,7 +262,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest stub_request(:get, "https://api.telegram.org/bot#{token}/getFile?file_id=AgADAgADwacxGxk5MUmim45lijOwsKk1Sw0ABNQoaI8BwR_z_2MFAAEC") .to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123AgADAgADwacxGxk5MUmim45lijOwsKk1Sw0ABNQoaI8BwR_z_2MFAAEC","file_path":"abc123"}}', headers: {}) - post callback_url, read_messaage('personal5_message_content1'), @headers + post callback_url, params: read_messaage('personal5_message_content1'), headers: @headers assert_response(200) assert_equal(5, Ticket.count) ticket = Ticket.last @@ -273,7 +273,7 @@ class TelegramControllerTest < ActionDispatch::IntegrationTest assert_equal('text/html', ticket.articles.last.content_type) assert_equal(0, ticket.articles.last.attachments.count) - post callback_url, read_messaage('personal5_message_content2'), @headers + post callback_url, params: read_messaage('personal5_message_content2'), headers: @headers assert_response(200) assert_equal(5, Ticket.count) ticket = Ticket.last diff --git a/test/integration_test_helper.rb b/test/integration_test_helper.rb index 37e183bbe..bd2991608 100644 --- a/test/integration_test_helper.rb +++ b/test/integration_test_helper.rb @@ -5,7 +5,7 @@ require 'cache' class ActiveSupport::TestCase # disable transactions - #self.use_transactional_fixtures = false + #self.use_transactional_tests = false ActiveRecord::Base.logger = Rails.logger.clone ActiveRecord::Base.logger.level = Logger::INFO diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_helper.rb b/test/test_helper.rb index 7be5849fc..169cae892 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -28,7 +28,7 @@ class ActiveSupport::TestCase fixtures :all # disable transactions - self.use_transactional_fixtures = false + self.use_transactional_tests = false # clear cache Cache.clear diff --git a/test/unit/assets_test.rb b/test/unit/assets_test.rb index 52b065de7..526144336 100644 --- a/test/unit/assets_test.rb +++ b/test/unit/assets_test.rb @@ -87,7 +87,7 @@ class AssetsTest < ActiveSupport::TestCase travel 2.seconds org2 = Organization.find(org1.id) org2.note = "some note...#{rand(9_999_999_999_999)}" - org2.save + org2.save! attributes = org2.attributes_with_association_ids attributes.delete('user_ids') @@ -132,12 +132,11 @@ class AssetsTest < ActiveSupport::TestCase assert( diff(attributes, assets[:User][user3.id]), 'check assets' ) travel_back - user3.destroy - user2.destroy - user1.destroy - org1.destroy - org2.destroy - + user3.destroy! + user2.destroy! + user1.destroy! + org1.destroy! + assert_not(Organization.find_by(id: org2.id)) end test 'organization' do @@ -242,7 +241,7 @@ class AssetsTest < ActiveSupport::TestCase travel 2.seconds user_new_2 = User.find(user2.id) user_new_2.lastname = 'assets2' - user_new_2.save + user_new_2.save! org_new = Organization.find(org.id) attributes = org_new.attributes_with_association_ids @@ -270,12 +269,11 @@ class AssetsTest < ActiveSupport::TestCase assert( diff(attributes, assets[:User][user_new_2.id]), 'check assets' ) travel_back - user3.destroy - user2.destroy - user1.destroy - org.destroy - org_new.destroy - + user3.destroy! + user2.destroy! + user1.destroy! + org.destroy! + assert_not(Organization.find_by(id: org_new.id)) end def diff(o1, o2) diff --git a/test/unit/organization_ref_object_touch_test.rb b/test/unit/organization_ref_object_touch_test.rb index 04a7c9ebe..59e3c83e6 100644 --- a/test/unit/organization_ref_object_touch_test.rb +++ b/test/unit/organization_ref_object_touch_test.rb @@ -61,7 +61,7 @@ class OrganizationRefObjectTouchTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket = Ticket.create( + ticket = Ticket.create!( title: "some title1\n äöüß", group: Group.lookup(name: 'Users'), customer_id: customer1.id, @@ -78,7 +78,7 @@ class OrganizationRefObjectTouchTest < ActiveSupport::TestCase travel 4.seconds organization1.name = 'Ref Object Update Org 1/1' - organization1.save + organization1.save! # check if ticket and customer has been touched ticket = Ticket.find(ticket.id) @@ -88,7 +88,7 @@ class OrganizationRefObjectTouchTest < ActiveSupport::TestCase assert(false, 'ticket.updated_at has not been updated') end - customer1 = User.find(customer1.id) + customer1.reload if customer1.updated_at > 2.seconds.ago assert(true, 'customer1.updated_at has been updated') else @@ -98,25 +98,24 @@ class OrganizationRefObjectTouchTest < ActiveSupport::TestCase travel 4.seconds customer2.organization_id = organization1.id - customer2.save + customer2.save! # check if customer1 and organization has been touched - customer1 = User.find(customer1.id) + customer1.reload if customer1.updated_at > 2.seconds.ago assert(true, 'customer1.updated_at has been updated') else assert(false, 'customer1.updated_at has not been updated') end - organization1 = Organization.find(organization1.id) + organization1.reload if organization1.updated_at > 2.seconds.ago assert(true, 'organization1.updated_at has been updated') else assert(false, 'organization1.updated_at has not been updated') end - delete = ticket.destroy - assert(delete, 'ticket destroy') + assert(ticket.destroy, 'ticket destroy') travel_back end @@ -193,7 +192,7 @@ class OrganizationRefObjectTouchTest < ActiveSupport::TestCase ) } - ticket = Ticket.create( + ticket = Ticket.create!( title: "some title1\n äöüß", group: Group.lookup(name: 'Users'), customer_id: customer1.id, @@ -208,36 +207,35 @@ class OrganizationRefObjectTouchTest < ActiveSupport::TestCase assert_equal(ticket.customer.id, customer1.id) assert_equal(ticket.organization.id, organization1.id) - customer1 = User.find(customer1.id) + customer1.reload assert_not_equal('2015-02-05 16:37:00 UTC', customer1.updated_at.to_s) customer1_updated_at = customer1.updated_at travel 4.seconds organization1.name = 'Ref Object Update Org 1 (no update)/1' - organization1.save + organization1.save! organization1_updated_at = organization1.updated_at # check if ticket and customer has been touched ticket = Ticket.find(ticket.id) assert_equal('2015-02-05 16:39:00 UTC', ticket.updated_at.to_s) - customer1 = User.find(customer1.id) + customer1.reload assert_equal(customer1_updated_at.to_s, customer1.updated_at.to_s) travel 4.seconds customer2.organization_id = organization1.id - customer2.save + customer2.save! # check if customer1 and organization has been touched - customer1 = User.find(customer1.id) + customer1.reload assert_equal(customer1_updated_at.to_s, customer1.updated_at.to_s) - organization1 = Organization.find(organization1.id) + organization1.reload assert_equal(organization1_updated_at.to_s, organization1.updated_at.to_s) - delete = ticket.destroy - assert(delete, 'ticket destroy') + assert(ticket.destroy, 'ticket destroy') travel_back end diff --git a/test/unit/session_basic_test.rb b/test/unit/session_basic_test.rb index b7756008c..bcf9405c9 100644 --- a/test/unit/session_basic_test.rb +++ b/test/unit/session_basic_test.rb @@ -128,7 +128,7 @@ class SessionBasicTest < ActiveSupport::TestCase sleep 0.6 result2 = collection_client2.push assert(!result2.empty?, 'check collections') - assert_equal(result1.to_yaml, result2.to_yaml, 'check collections') + assert_equal(result1, result2, 'check collections') # next check should be empty result1 = collection_client1.push @@ -149,7 +149,7 @@ class SessionBasicTest < ActiveSupport::TestCase result2 = collection_client2.push assert(!result2.empty?, 'check collections - after touch') - assert_equal(result1.to_yaml, result2.to_yaml, 'check collections') + assert_equal(result1, result2, 'check collections') # check again after touch result1 = collection_client1.push