Updated to rails 5.0.

This commit is contained in:
Jens Pfeifer 2017-09-08 08:28:34 +00:00
parent c6e40ce818
commit 533b44af8f
110 changed files with 696 additions and 645 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
class CreateBase < ActiveRecord::Migration
class CreateBase < ActiveRecord::Migration[4.2]
def up
# clear old caches to start from scratch

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -55,7 +55,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
admin_credentials = ActionController::HttpAuthentication::Basic.encode_credentials('api-admin@example.com', 'adminpw')
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)

View File

@ -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(/<html/, @response.body)
assert_match(%r{<title>404: Not Found</title>}, @response.body)
@ -69,7 +69,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(%r{No route matches \[GET\] /not_existing_url}, @response.body)
# 401
get '/api/v1/organizations', {}, @headers
get '/api/v1/organizations', params: {}, headers: @headers
assert_response(401)
assert_match(/<html/, @response.body)
assert_match(%r{<title>401: Unauthorized</title>}, @response.body)
@ -77,7 +77,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(/authentication failed/, @response.body)
# 422
get '/tests/unprocessable_entity', {}, @headers
get '/tests/unprocessable_entity', params: {}, headers: @headers
assert_response(422)
assert_match(/<html/, @response.body)
assert_match(%r{<title>422: Unprocessable Entity</title>}, @response.body)
@ -85,7 +85,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(/some error message/, @response.body)
# 401
get '/tests/not_authorized', {}, @headers
get '/tests/not_authorized', params: {}, headers: @headers
assert_response(401)
assert_match(/<html/, @response.body)
assert_match(%r{<title>401: Unauthorized</title>}, @response.body)
@ -93,7 +93,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(/some error message/, @response.body)
# 401
get '/tests/ar_not_found', {}, @headers
get '/tests/ar_not_found', params: {}, headers: @headers
assert_response(404)
assert_match(/<html/, @response.body)
assert_match(%r{<title>404: Not Found</title>}, @response.body)
@ -101,7 +101,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(/some error message/, @response.body)
# 500
get '/tests/standard_error', {}, @headers
get '/tests/standard_error', params: {}, headers: @headers
assert_response(500)
assert_match(/<html/, @response.body)
assert_match(%r{<title>500: Something went wrong</title>}, @response.body)
@ -109,7 +109,7 @@ class BasicControllerTest < ActionDispatch::IntegrationTest
assert_match(/some error message/, @response.body)
# 422
get '/tests/argument_error', {}, @headers
get '/tests/argument_error', params: {}, headers: @headers
assert_response(422)
assert_match(/<html/, @response.body)
assert_match(%r{<title>422: Unprocessable Entity</title>}, @response.body)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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