Maintenance: Updated rubocop(-* gems) to latest version (0.80.0).

This commit is contained in:
Thorsten Eckel 2020-02-18 20:51:31 +01:00
parent ed8a152f28
commit a976b9fb43
93 changed files with 287 additions and 330 deletions

View file

@ -32,7 +32,7 @@ Rails:
Style/FrozenStringLiteralComment:
Enabled: false
Metrics/LineLength:
Layout/LineLength:
Description: 'Limit lines to 80 characters.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
Enabled: false
@ -106,7 +106,7 @@ Style/MethodDefParentheses:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
Enabled: false
Layout/AlignHash:
Layout/HashAlignment:
Description: >-
Align the elements of a hash literal if they span more than
one line.
@ -155,6 +155,15 @@ Style/PerlBackrefs:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
Enabled: false
Style/HashEachMethods:
Enabled: true
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
Style/SelfAssignment:
Description: >-
Checks for places where self-assignment shorthand should have
@ -162,10 +171,6 @@ Style/SelfAssignment:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
Enabled: false
Style/BracesAroundHashParameters:
Description: 'Enforce braces style around hash parameters.'
Enabled: false
Rails/ApplicationRecord:
Exclude:
- 'app/models/application_model.rb'
@ -210,7 +215,7 @@ Naming/VariableNumber:
Description: 'Use the configured style when numbering variables.'
Enabled: false
Naming/UncommunicativeMethodParamName:
Naming/MethodParameterName:
Description: >-
Checks for method parameter names that contain capital letters,
end in numbers, or do not meet a minimal length.

View file

@ -170,6 +170,7 @@ RSpec/ScatteredSetup:
# Offense count: 8
RSpec/SubjectStub:
Exclude:
- 'spec/lib/import/exchange/folder_spec.rb'
- 'spec/models/concerns/has_groups_examples.rb'
- 'spec/models/concerns/has_roles_examples.rb'
- 'spec/models/job_spec.rb'

View file

@ -255,7 +255,7 @@ GEM
ice_cube (0.16.3)
inflection (1.0.0)
interception (0.5)
jaro_winkler (1.5.3)
jaro_winkler (1.5.4)
json (2.2.0)
jwt (2.2.1)
kgio (2.11.2)
@ -354,8 +354,8 @@ GEM
omniauth-weibo-oauth2 (0.5.2)
omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0)
parallel (1.17.0)
parser (2.6.4.0)
parallel (1.19.1)
parser (2.7.0.2)
ast (~> 2.4.0)
pg (0.21.0)
pluginator (1.5.0)
@ -426,6 +426,7 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
retriable (2.1.0)
rexml (3.2.4)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
@ -444,20 +445,21 @@ GEM
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rszr (0.5.2)
rubocop (0.74.0)
rubocop (0.80.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.6)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.4.1)
rubocop-performance (1.5.2)
rubocop (>= 0.71.0)
rubocop-rails (2.3.2)
rubocop-rails (2.4.2)
rack (>= 1.1)
rubocop (>= 0.72.0)
rubocop-rspec (1.35.0)
rubocop (>= 0.60.0)
rubocop-rspec (1.38.1)
rubocop (>= 0.68.1)
ruby-progressbar (1.10.1)
ruby-saml (1.10.2)
nokogiri (>= 1.5.10)
@ -526,7 +528,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.6.0)
unicode-display_width (1.6.1)
unicorn (5.5.0)
kgio (~> 2.6)
raindrops (~> 0.7)

View file

@ -66,7 +66,7 @@ class ChannelsSmsController < ApplicationChannelController
def channels_config
list = []
Dir.glob(Rails.root.join('app', 'models', 'channel', 'driver', 'sms', '*.rb')).each do |path|
Dir.glob(Rails.root.join('app/models/channel/driver/sms/*.rb')).each do |path|
filename = File.basename(path)
require_dependency "channel/driver/sms/#{filename.sub('.rb', '')}"
list.push Channel.driver_class("sms/#{filename}").definition

View file

@ -64,7 +64,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
end
# unprocessable mail check
directory = Rails.root.join('tmp', 'unprocessable_mail').to_s
directory = Rails.root.join('tmp/unprocessable_mail').to_s
if File.exist?(directory)
count = 0
Dir.glob("#{directory}/*.eml") do |_entry|

View file

@ -54,7 +54,7 @@ store attachments for this object
self.attachments_buffer = attachments
# update if object already exists
return if !(id&.nonzero?)
return if !id&.nonzero?
attachments_buffer_check
end

View file

@ -86,7 +86,7 @@ returns
=end
def self.ical_feeds
data = YAML.load_file(Rails.root.join('config', 'holiday_calendars.yml'))
data = YAML.load_file(Rails.root.join('config/holiday_calendars.yml'))
url = data['url']
data['countries'].map do |country, domain|
@ -256,7 +256,7 @@ returns
# get day and comment by event
def self.day_and_comment_by_event(event, start_time)
day = "#{start_time.year}-#{format('%02d', start_time.month)}-#{format('%02d', start_time.day)}"
day = "#{start_time.year}-#{format('%<month>02d', month: start_time.month)}-#{format('%<day>02d', day: start_time.day)}"
comment = event.summary || event.description
comment = comment.to_utf8(fallback: :read_as_sanitized_binary)

View file

@ -58,7 +58,7 @@ fetch one account
self.last_log_in = result[:notice]
preferences[:last_fetch] = Time.zone.now
save!
return true
true
rescue => e
error = "Can't use Channel::Driver::#{adapter.to_classname}: #{e.inspect}"
logger.error error
@ -67,7 +67,7 @@ fetch one account
self.last_log_in = error
preferences[:last_fetch] = Time.zone.now
save!
return false
false
end
end
@ -98,7 +98,7 @@ stream instance of account
# set scheduler job to active
return driver_instance
driver_instance
rescue => e
error = "Can't use Channel::Driver::#{adapter.to_classname}: #{e.inspect}"
logger.error error

View file

@ -153,7 +153,7 @@ Check if string is a complete html document. If not, add head and css styles.
return html if html.match?(/<html>/i)
html_email_body = File.read(Rails.root.join('app', 'views', 'mailer', 'application_wrapper.html.erb').to_s)
html_email_body = File.read(Rails.root.join('app/views/mailer/application_wrapper.html.erb').to_s)
html_email_body.gsub!('###html_email_css_font###', Setting.get('html_email_css_font'))

View file

@ -473,7 +473,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
=end
def self.process_unprocessable_mails(params = {})
path = Rails.root.join('tmp', 'unprocessable_mail')
path = Rails.root.join('tmp/unprocessable_mail')
files = []
Dir.glob("#{path}/*.eml") do |entry|
ticket, _article, _user, _mail = Channel::EmailParser.new.process(params, IO.binread(entry))
@ -847,7 +847,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
mail = OpenStruct.new
mail.from_display_name = parsed_incoming_mail[:from_display_name]
mail.subject = parsed_incoming_mail[:subject]
mail.msg_size = format('%.2f', raw_incoming_mail.size.to_f / 1024 / 1024)
mail.msg_size = format('%<MB>.2f', MB: raw_incoming_mail.size.to_f / 1024 / 1024)
reply = NotificationFactory::Mailer.template(
template: 'email_oversized',

View file

@ -25,7 +25,7 @@ class ObjectManager::Attribute < ApplicationModel
belongs_to :object_lookup, optional: true
validates :name, presence: true
validates :data_type, inclusion: { in: DATA_TYPES, msg: '%{value} is not a valid data type' }
validates :data_type, inclusion: { in: DATA_TYPES, msg: '%{value} is not a valid data type' } # rubocop:disable Style/FormatStringToken
validate :data_option_must_have_appropriate_values
validate :data_type_must_not_change, on: :update

View file

@ -79,7 +79,7 @@ class Store::Provider::File
def self.get_location(sha)
# generate directory
base = Rails.root.join('storage', 'fs').to_s
base = Rails.root.join('storage/fs').to_s
parts = []
length1 = 4
length2 = 5

View file

@ -18,7 +18,7 @@ module Ticket::Number::Date
counter.update(content: "#{counter_increment};#{date}")
end
number = date.delete('-') + Setting.get('system_id').to_s + format('%04d', counter.content.split(';').first)
number = date.delete('-') + Setting.get('system_id').to_s + format('%<counter>04d', counter: counter.content.split(';').first)
number += checksum(number) if config[:checksum]
number

View file

@ -246,15 +246,15 @@ or
record = Translation.where(locale: locale, source: 'timestamp', format: 'time').pluck(:target).first
return timestamp.to_s if !record
record.sub!('dd', format('%02d', timestamp.day))
record.sub!('dd', format('%<day>02d', day: timestamp.day))
record.sub!('d', timestamp.day.to_s)
record.sub!('mm', format('%02d', timestamp.month))
record.sub!('mm', format('%<month>02d', month: timestamp.month))
record.sub!('m', timestamp.month.to_s)
record.sub!('yyyy', timestamp.year.to_s)
record.sub!('yy', timestamp.year.to_s.last(2))
record.sub!('SS', format('%02d', timestamp.sec.to_s))
record.sub!('MM', format('%02d', timestamp.min.to_s))
record.sub!('HH', format('%02d', timestamp.hour.to_s))
record.sub!('SS', format('%<second>02d', second: timestamp.sec.to_s))
record.sub!('MM', format('%<minute>02d', minute: timestamp.min.to_s))
record.sub!('HH', format('%<hour>02d', hour: timestamp.hour.to_s))
"#{record} (#{timezone})"
end
@ -288,9 +288,9 @@ or
record = Translation.where(locale: locale, source: 'date', format: 'time').pluck(:target).first
return date.to_s if !record
record.sub!('dd', format('%02d', date.day))
record.sub!('dd', format('%<day>02d', day: date.day))
record.sub!('d', date.day.to_s)
record.sub!('mm', format('%02d', date.month))
record.sub!('mm', format('%<month>02d', month: date.month))
record.sub!('m', date.month.to_s)
record.sub!('yyyy', date.year.to_s)
record.sub!('yy', date.year.to_s.last(2))
@ -313,7 +313,7 @@ all:
def self.load_from_file(dedicated_locale = nil)
version = Version.get
directory = Rails.root.join('config', 'translations')
directory = Rails.root.join('config/translations')
locals_to_sync(dedicated_locale).each do |locale|
file = Rails.root.join(directory, "#{locale}-#{version}.yml")
return false if !File.exist?(file)
@ -358,7 +358,7 @@ all:
)
raise "Can't load translations from #{url}: #{result.error}" if !result.success?
directory = Rails.root.join('config', 'translations')
directory = Rails.root.join('config/translations')
if !File.directory?(directory)
Dir.mkdir(directory, 0o755)
end

View file

@ -14,7 +14,7 @@ Rails.application.configure do
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.public_file_server.headers = {

View file

@ -1,5 +1,5 @@
# load all core_ext extensions
Dir.glob( Rails.root.join('lib', 'core_ext', '**', '*') ).each do |file|
Dir.glob( Rails.root.join('lib/core_ext/**/*') ).sort.each do |file|
if File.file?(file)
require file
end

View file

@ -1,4 +1,4 @@
Dir[ Rails.root.join('lib', 'omniauth', '*') ].each do |file|
Dir[ Rails.root.join('lib/omniauth/*') ].sort.each do |file|
if File.file?(file)
require file
end

View file

@ -60,7 +60,7 @@ class String
=end
def to_filename
camel_cased_word = "#{self}" # rubocop:disable Style/UnneededInterpolation
camel_cased_word = dup
camel_cased_word.gsub(/::/, '/')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
@ -77,7 +77,7 @@ class String
=end
def to_classname
camel_cased_word = "#{self}" # rubocop:disable Style/UnneededInterpolation
camel_cased_word = dup
camel_cased_word.gsub!(/\.rb$/, '')
camel_cased_word.split('/').map(&:camelize).join('::')
end
@ -109,7 +109,7 @@ class String
=end
def html2text(string_only = false, strict = false)
string = "#{self}" # rubocop:disable Style/UnneededInterpolation
string = dup
# in case of invalid encoding, strip invalid chars
# see also test/data/mail/mail021.box
@ -322,7 +322,7 @@ class String
=end
def html2html_strict
string = "#{self}" # rubocop:disable Style/UnneededInterpolation
string = dup
string = HtmlSanitizer.cleanup_replace_tags(string)
string = HtmlSanitizer.strict(string, true).strip
string = HtmlSanitizer.cleanup(string).strip

View file

@ -176,7 +176,7 @@ satinize html string based on whiltelist
# remove attributes if not whitelisted
node.each do |attribute, _value|
attribute_name = attribute.downcase
next if attributes_whitelist[:all].include?(attribute_name) || (attributes_whitelist[node.name]&.include?(attribute_name))
next if attributes_whitelist[:all].include?(attribute_name) || attributes_whitelist[node.name]&.include?(attribute_name)
node.delete(attribute)
end

View file

@ -27,7 +27,7 @@ returns
def self.all
@all ||= begin
all = {}
dir = Rails.root.join('app', 'models').to_s
dir = Rails.root.join('app/models').to_s
tables = ActiveRecord::Base.connection.tables
Dir.glob("#{dir}/**/*.rb") do |entry|
next if entry.match?(/application_model/i)

View file

@ -1,6 +1,6 @@
module NotificationFactory
TEMPLATE_PATH_STRING = Rails.root.join('app', 'views', '%<type>s', '%<template>s', '%<filename>s').to_s.freeze
APPLICATION_TEMPLATE_PATH_STRING = Rails.root.join('app', 'views', '%<type>s', 'application.%<format>s.erb').to_s.freeze
TEMPLATE_PATH_STRING = Rails.root.join('app/views/%<type>s/%<template>s/%<filename>s').to_s.freeze
APPLICATION_TEMPLATE_PATH_STRING = Rails.root.join('app/views/%<type>s/application.%<format>s.erb').to_s.freeze
=begin

View file

@ -462,10 +462,10 @@ returns
return if message.blank?
begin
return JSON.parse(message)
JSON.parse(message)
rescue => e
log('error', "can't parse queue message: #{message}, #{e.inspect}")
return
nil
end
end

View file

@ -18,7 +18,7 @@ class Sessions::Event
rescue => e
Rails.logger.error e.inspect
Rails.logger.error e.backtrace
return { event: 'error', data: { error: e.message, payload: params[:payload] } }
{ event: 'error', data: { error: e.message, payload: params[:payload] } }
end
end

View file

@ -308,7 +308,7 @@ end
def es_version_supported?
version_split = es_version.split('.')
version = "#{version_split[0]}#{format('%03d', version_split[1])}#{format('%03d', version_split[2])}".to_i
version = "#{version_split[0]}#{format('%<minor>03d', minor: version_split[1])}#{format('%<patch>03d', patch: version_split[2])}".to_i
# only versions greater/equal than 5.6.0 are supported
return if version < 5_006_000

View file

@ -5,7 +5,7 @@ namespace :zammad do
namespace :app do
desc 'Starts the application and uses BROWSER_PORT, RAILS_ENV and WS_PORT ENVs'
task :start do
task :start do # rubocop:disable Rails/RakeEnvironment
Rake::Task['zammad:ci:service:puma:start'].invoke(ENV['BROWSER_PORT'], ENV['RAILS_ENV'])
Rake::Task['zammad:ci:service:websocket:start'].invoke(ENV['WS_PORT'])
Rake::Task['zammad:ci:service:scheduler:start'].invoke

View file

@ -7,7 +7,7 @@ namespace :zammad do
namespace :puma do
desc 'Starts the puma application webserver'
task :start, [:port, :env] do |_task, args|
task :start, [:port, :env] do |_task, args| # rubocop:disable Rails/RakeEnvironment
port = args.fetch(:port, '3000')
env = args.fetch(:env, 'production')

View file

@ -7,9 +7,9 @@ namespace :zammad do
namespace :puma do
desc 'Stops the puma application webserver'
task :stop do
task :stop do # rubocop:disable Rails/RakeEnvironment
file = Rails.root.join('tmp', 'pids', 'server.pid')
file = Rails.root.join('tmp/pids/server.pid')
pid = File.read(file).to_i
Process.kill('SIGTERM', pid)

View file

@ -7,7 +7,7 @@ namespace :zammad do
namespace :scheduler do
desc 'Starts the scheduler'
task :start do
task :start do # rubocop:disable Rails/RakeEnvironment
command = [
'bundle',

View file

@ -7,7 +7,7 @@ namespace :zammad do
namespace :scheduler do
desc 'Stops the scheduler'
task :stop do
task :stop do # rubocop:disable Rails/RakeEnvironment
command = [
'bundle',

View file

@ -7,7 +7,7 @@ namespace :zammad do
namespace :websocket do
desc 'Starts the websocket server'
task :start, [:port] do |_task, args|
task :start, [:port] do |_task, args| # rubocop:disable Rails/RakeEnvironment
port = args.fetch(:port, '6042')
command = [

View file

@ -7,7 +7,7 @@ namespace :zammad do
namespace :websocket do
desc 'Stops the websocket server'
task :stop do
task :stop do # rubocop:disable Rails/RakeEnvironment
command = [
'bundle',

View file

@ -5,7 +5,7 @@ namespace :zammad do
namespace :test do
desc 'Stops all of Zammads services and exists the rake task with exit code 1'
task :fail, [:no_app] do |_task, args|
task :fail, [:no_app] do |_task, args| # rubocop:disable Rails/RakeEnvironment
Rake::Task['zammad:ci:test:stop'].invoke if args[:no_app].blank?
abort('Abort further test processing')
end

View file

@ -5,7 +5,7 @@ namespace :zammad do
namespace :test do
desc 'Prepares Zammad system for CI env'
task :prepare, [:elasticsearch] do |_task, args|
task :prepare, [:elasticsearch] do |_task, args| # rubocop:disable Rails/RakeEnvironment
ENV['RAILS_ENV'] ||= 'production'
ENV['DISABLE_DATABASE_ENVIRONMENT_CHECK'] = 'true'
# we have to enforce the env

View file

@ -5,7 +5,7 @@ namespace :zammad do
namespace :test do
desc 'Starts all of Zammads services for CI test'
task :start, [:elasticsearch] do |_task, args|
task :start, [:elasticsearch] do |_task, args| # rubocop:disable Rails/RakeEnvironment
Rake::Task['zammad:ci:test:prepare'].invoke(args[:elasticsearch])
Rake::Task['zammad:ci:app:start'].invoke
end

View file

@ -5,7 +5,7 @@ namespace :zammad do
namespace :test do
desc 'Stop of all Zammad services and cleans up the database(s)'
task :stop, [:no_app] do |_task, args|
task :stop, [:no_app] do |_task, args| # rubocop:disable Rails/RakeEnvironment
ENV['RAILS_ENV'] ||= 'production'
ENV['DISABLE_DATABASE_ENVIRONMENT_CHECK'] = 'true'

View file

@ -3,8 +3,8 @@ namespace :zammad do
namespace :flush do
desc 'Flushes all caches'
task :cache do
FileUtils.rm_rf(Rails.root.join('tmp', 'cache*'))
task :cache do # rubocop:disable Rails/RakeEnvironment
FileUtils.rm_rf(Rails.root.join('tmp/cache*'))
end
end
end

View file

@ -5,7 +5,7 @@ namespace :zammad do
namespace :log do
desc 'Flushes all scheduler log files'
task :scheduler do
task :scheduler do # rubocop:disable Rails/RakeEnvironment
%w[err out].each do |suffix|
File.write(Rails.root.join('log', "scheduler_#{suffix}.log"), '')
end

View file

@ -5,7 +5,7 @@ namespace :zammad do
namespace :log do
desc 'Flushes the log Rails file of the given or active environment'
task :rails, [:env] do |_task, args|
task :rails, [:env] do |_task, args| # rubocop:disable Rails/RakeEnvironment
env = args.fetch(:env, Rails.env)
File.write(Rails.root.join('log', "#{env}.log"), '')
end

View file

@ -5,7 +5,7 @@ namespace :zammad do
namespace :log do
desc 'Flushes all websocket server log files'
task :websocket do
task :websocket do # rubocop:disable Rails/RakeEnvironment
%w[err out].each do |suffix|
File.write(Rails.root.join('log', "websocket-server_#{suffix}.log"), '')
end

View file

@ -3,7 +3,7 @@ namespace :zammad do
namespace :setup do
desc 'Copies the database config template file to config/database.yml'
task :db_config do
task :db_config do # rubocop:disable Rails/RakeEnvironment
config_dir = Rails.root.join('config')
template = config_dir.join('database', 'database.yml')

View file

@ -9,7 +9,7 @@ class Twitter::Streaming::ConnectionCustom < Twitter::Streaming::Connection
ssl_client.connect
request.stream(ssl_client)
while body = ssl_client.readpartial(1024) # rubocop:disable AssignmentInCondition
while body = ssl_client.readpartial(1024) # rubocop:disable Lint/AssignmentInCondition
response << body
end
end

View file

@ -68,7 +68,7 @@ returns
end
rescue => e
log(url, request, nil, options)
return Result.new(
Result.new(
error: e.inspect,
success: false,
code: 0,
@ -124,7 +124,7 @@ returns
end
rescue => e
log(url, request, nil, options)
return Result.new(
Result.new(
error: e.inspect,
success: false,
code: 0,
@ -179,7 +179,7 @@ returns
end
rescue => e
log(url, request, nil, options)
return Result.new(
Result.new(
error: e.inspect,
success: false,
code: 0,
@ -226,7 +226,7 @@ returns
end
rescue => e
log(url, request, nil, options)
return Result.new(
Result.new(
error: e.inspect,
success: false,
code: 0,

View file

@ -42,7 +42,7 @@ module Zammad
MSG
end
# Setting.get will fail if 'settings' table does not exist
rescue ActiveRecord::StatementInvalid # rubocop:disable Lint/HandleExceptions
rescue ActiveRecord::StatementInvalid # rubocop:disable Lint/SuppressedException
end
def self.connection

View file

@ -6,7 +6,7 @@ RSpec.describe Auth::Base do
let(:user) { create(:user) }
let(:instance) { described_class.new({ adapter: described_class.name }) }
context '#valid?' do
describe '#valid?' do
it_behaves_like 'Auth backend'
it "requires an implementation of the 'valid?' method" do

View file

@ -6,7 +6,7 @@ RSpec.describe Auth::Developer do
let(:user) { create(:user) }
let(:instance) { described_class.new({ adapter: described_class.name }) }
context '#valid?' do
describe '#valid?' do
it_behaves_like 'Auth backend'
it "authenticates users with password 'test'" do

View file

@ -7,7 +7,7 @@ RSpec.describe Auth::Internal do
let(:user) { create(:user, password: password) }
let(:instance) { described_class.new({ adapter: described_class.name }) }
context '#valid?' do
describe '#valid?' do
it_behaves_like 'Auth backend'
it 'authenticates via password' do

View file

@ -8,7 +8,7 @@ RSpec.describe ::Auth::Ldap do
let(:password) { 'somepassword' }
let(:instance) { described_class.new({ adapter: described_class.name }) }
context '#valid?' do
describe '#valid?' do
it_behaves_like 'Auth backend'
it 'authenticates users' do

View file

@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.describe Auth do
context '.can_login?' do
describe '.can_login?' do
it 'responds to can_login?' do
expect(described_class).to respond_to(:can_login?)
end
@ -34,7 +34,7 @@ RSpec.describe Auth do
end
end
context '.valid?' do
describe '.valid?' do
it 'responds to valid?' do
expect(described_class).to respond_to(:valid?)
end
@ -47,7 +47,7 @@ RSpec.describe Auth do
end
end
context '.backends' do
describe '.backends' do
it 'responds to backends' do
expect(described_class).to respond_to(:backends)
end

View file

@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.describe ExternalSync do
context '#changed?' do
describe '#changed?' do
it 'keeps ActiveRecord instance unchanged on local but no remote changes' do
object = create(:group)
@ -68,7 +68,7 @@ RSpec.describe ExternalSync do
end
context '#map' do
describe '#map' do
it 'maps to symbol keys' do
mapping = {
'key' => 'key'

View file

@ -6,12 +6,15 @@ RSpec.shared_examples 'Import::BaseFactory' do
it 'responds to pre_import_hook' do
expect(described_class).to respond_to('pre_import_hook')
end
it 'responds to post_import_hook' do
expect(described_class).to respond_to('post_import_hook')
end
it 'responds to backend_class' do
expect(described_class).to respond_to('backend_class')
end
it 'responds to skip?' do
expect(described_class).to respond_to('skip?')
end

View file

@ -2,6 +2,7 @@ RSpec.shared_examples 'Import::ImportStats' do
it 'responds to current_state' do
expect(described_class).to respond_to('current_state')
end
it 'responds to statistic' do
expect(described_class).to respond_to('statistic')
end

View file

@ -48,14 +48,14 @@ RSpec.describe Import::OTRS::ArticleCustomer do
expect(User.last.login).to eq('user@example.com')
end
context '.find' do
describe '.find' do
it 'returns nil if no email could be found' do
expect(described_class.find({})).to be nil
end
end
context '.local_email' do
describe '.local_email' do
it 'returns nil if no email could be found' do
expect(described_class.local_email(nil)).to be nil

View file

@ -117,7 +117,7 @@ RSpec.describe Import::OTRS::CustomerUser do
end
end
context 'regular user' do
context 'regular user with capitalized email' do
let(:object_structure) { load_customer_json('capital_email') }
let(:zammad_structure) do

View file

@ -2,13 +2,13 @@ require 'rails_helper'
RSpec.describe Import::OTRS::Requester do
context '.list' do
describe '.list' do
it 'responds to list' do
expect(described_class).to respond_to(:list)
end
end
context '.load' do
describe '.load' do
it 'responds to load' do
expect(described_class).to respond_to(:load)
@ -39,7 +39,7 @@ RSpec.describe Import::OTRS::Requester do
end
end
context '.connection_test' do
describe '.connection_test' do
it 'responds to connection_test' do
expect(described_class).to respond_to(:connection_test)
end

View file

@ -10,7 +10,7 @@ RSpec.describe Ldap::Group do
# as additional parameter
let(:mocked_ldap) { double() }
context '.uid_attribute' do
describe '.uid_attribute' do
it 'responds to .uid_attribute' do
expect(described_class).to respond_to(:uid_attribute)
@ -73,7 +73,7 @@ RSpec.describe Ldap::Group do
described_class.new(initialization_config, ldap: mocked_ldap)
end
context '#list' do
describe '#list' do
it 'responds to #list' do
expect(instance).to respond_to(:list)
@ -86,7 +86,7 @@ RSpec.describe Ldap::Group do
end
end
context '#filter' do
describe '#filter' do
let(:initialization_config) do
{
@ -109,7 +109,7 @@ RSpec.describe Ldap::Group do
end
end
context '#uid_attribute' do
describe '#uid_attribute' do
it 'responds to #uid_attribute' do
expect(instance).to respond_to(:uid_attribute)

View file

@ -5,7 +5,7 @@ RSpec.describe Ldap::Guid do
let(:string) { 'f742b361-32c6-4a92-baaa-eaae7df657ee' }
let(:hex) { "a\xB3B\xF7\xC62\x92J\xBA\xAA\xEA\xAE}\xF6W\xEE".b }
context '.valid?' do
describe '.valid?' do
it 'responds to .valid?' do
expect(described_class).to respond_to(:valid?)
@ -21,7 +21,7 @@ RSpec.describe Ldap::Guid do
end
end
context '.hex' do
describe '.hex' do
it 'responds to .hex' do
expect(described_class).to respond_to(:hex)
@ -37,7 +37,7 @@ RSpec.describe Ldap::Guid do
end
end
context '.string' do
describe '.string' do
it 'responds to .string' do
expect(described_class).to respond_to(:string)
@ -53,7 +53,7 @@ RSpec.describe Ldap::Guid do
end
end
context '#string' do
describe '#string' do
let(:instance) { described_class.new(hex) }
@ -66,7 +66,7 @@ RSpec.describe Ldap::Guid do
end
end
context '#hex' do
describe '#hex' do
let(:instance) { described_class.new(string) }

View file

@ -8,7 +8,7 @@ RSpec.describe Ldap::User do
let(:mocked_ldap) { double() }
context '.uid_attribute' do
describe '.uid_attribute' do
it 'responds to .uid_attribute' do
expect(described_class).to respond_to(:uid_attribute)
@ -86,7 +86,7 @@ RSpec.describe Ldap::User do
described_class.new(initialization_config, ldap: mocked_ldap)
end
context '#valid?' do
describe '#valid?' do
it 'responds to #valid?' do
expect(instance).to respond_to(:valid?)
@ -117,7 +117,7 @@ RSpec.describe Ldap::User do
end
end
context '#attributes' do
describe '#attributes' do
it 'responds to #attributes' do
expect(instance).to respond_to(:attributes)
@ -146,7 +146,7 @@ RSpec.describe Ldap::User do
end
end
context '#filter' do
describe '#filter' do
let(:initialization_config) do
{
@ -169,7 +169,7 @@ RSpec.describe Ldap::User do
end
end
context '#uid_attribute' do
describe '#uid_attribute' do
let(:initialization_config) do
{

View file

@ -214,7 +214,7 @@ RSpec.describe Ldap do
)
end
context '#preferences' do
describe '#preferences' do
it 'responds to #preferences' do
expect(instance).to respond_to(:preferences)
@ -231,7 +231,7 @@ RSpec.describe Ldap do
end
end
context '#search' do
describe '#search' do
let(:base) { 'DC=domain,DC=tld' }
let(:filter) { '(objectClass=user)' }
@ -307,7 +307,7 @@ RSpec.describe Ldap do
end
end
context '#entries?' do
describe '#entries?' do
let(:filter) { '(objectClass=user)' }

View file

@ -4,7 +4,7 @@ require 'ostruct'
RSpec.describe NotificationFactory::Mailer do
describe '#template' do
context 'for postmaster oversized mail' do
let(:raw_incoming_mail) { File.read(Rails.root.join('test', 'data', 'mail', 'mail010.box')) }
let(:raw_incoming_mail) { File.read(Rails.root.join('test/data/mail/mail010.box')) }
let(:parsed_incoming_mail) { Channel::EmailParser.new.parse raw_incoming_mail }
@ -12,7 +12,7 @@ RSpec.describe NotificationFactory::Mailer do
mail = OpenStruct.new
mail.from_display_name = parsed_incoming_mail[:from_display_name]
mail.subject = parsed_incoming_mail[:subject]
mail.msg_size = format('%.2f', raw_incoming_mail.size.to_f / 1024 / 1024)
mail.msg_size = format('%<MB>.2f', MB: raw_incoming_mail.size.to_f / 1024 / 1024)
mail
end

View file

@ -8,7 +8,7 @@ RSpec.describe NotificationFactory do
let(:rendered_locale) { 'en' }
let(:parsed_template) { { subject: template_lines.first, body: template_lines.drop(1).join } }
let(:template_lines) { File.readlines(template_path) }
let(:template_path) { Rails.root.join('app', 'views', 'mailer', 'signup', "#{rendered_locale}.html.erb") }
let(:template_path) { Rails.root.join("app/views/mailer/signup/#{rendered_locale}.html.erb") }
let(:read_params) do
{ type: 'mailer', template: 'signup', locale: 'en', format: 'html' }
@ -89,7 +89,7 @@ RSpec.describe NotificationFactory do
describe '::application_template_read' do
let(:read_params) { { type: 'mailer', format: 'html' } }
let(:template_path) { Rails.root.join('app', 'views', 'mailer', 'application.html.erb') }
let(:template_path) { Rails.root.join('app/views/mailer/application.html.erb') }
it 'returns template file content as string' do
expect(described_class.application_template_read(read_params))

View file

@ -14,9 +14,9 @@ RSpec.describe SignatureDetection do
let(:raw_message_files) do
[
Rails.root.join('test', 'data', 'email_signature_detection', 'client_a_1.txt'),
Rails.root.join('test', 'data', 'email_signature_detection', 'client_a_2.txt'),
Rails.root.join('test', 'data', 'email_signature_detection', 'client_a_3.txt')
Rails.root.join('test/data/email_signature_detection/client_a_1.txt'),
Rails.root.join('test/data/email_signature_detection/client_a_2.txt'),
Rails.root.join('test/data/email_signature_detection/client_a_3.txt')
]
end
@ -41,9 +41,9 @@ RSpec.describe SignatureDetection do
let(:raw_message_files) do
[
Rails.root.join('test', 'data', 'email_signature_detection', 'client_b_1.txt'),
Rails.root.join('test', 'data', 'email_signature_detection', 'client_b_2.txt'),
Rails.root.join('test', 'data', 'email_signature_detection', 'client_b_3.txt')
Rails.root.join('test/data/email_signature_detection/client_b_1.txt'),
Rails.root.join('test/data/email_signature_detection/client_b_2.txt'),
Rails.root.join('test/data/email_signature_detection/client_b_3.txt')
]
end
@ -68,9 +68,9 @@ RSpec.describe SignatureDetection do
let(:raw_message_files) do
[
Rails.root.join('test', 'data', 'email_signature_detection', 'client_c_1.html'),
Rails.root.join('test', 'data', 'email_signature_detection', 'client_c_2.html'),
Rails.root.join('test', 'data', 'email_signature_detection', 'client_c_3.html')
Rails.root.join('test/data/email_signature_detection/client_c_1.html'),
Rails.root.join('test/data/email_signature_detection/client_c_2.html'),
Rails.root.join('test/data/email_signature_detection/client_c_3.html')
]
end
@ -110,7 +110,7 @@ RSpec.describe SignatureDetection do
describe '.find_signature_line' do
context 'when given a plain text message' do
let(:content_type) { 'text/plain' }
let(:content) { File.read(Rails.root.join('test', 'data', 'email_signature_detection', 'client_a_1.txt')) }
let(:content) { File.read(Rails.root.join('test/data/email_signature_detection/client_a_1.txt')) }
context 'and a substring it contains' do
let(:signature) { <<~SIG.chomp }
@ -134,7 +134,7 @@ RSpec.describe SignatureDetection do
context 'when given an HTML message' do
let(:content_type) { 'text/html' }
let(:content) { File.read(Rails.root.join('test', 'data', 'email_signature_detection', 'example1.html')) }
let(:content) { File.read(Rails.root.join('test/data/email_signature_detection/example1.html')) }
context 'and a substring it contains' do
let(:signature) { <<~SIG.chomp }

View file

@ -45,7 +45,7 @@ RSpec.describe UserInfo do
described_class.ensure_current_user_id do
raise 'error'
end
rescue # rubocop:disable Lint/HandleExceptions
rescue # rubocop:disable Lint/SuppressedException
end
expect(described_class.current_user_id).to be nil

View file

@ -46,7 +46,7 @@ RSpec.describe Calendar, type: :model do
describe '#public_holidays' do
subject(:calendar) do
create(:calendar, ical_url: Rails.root.join('test', 'data', 'calendar', 'calendar1.ics'))
create(:calendar, ical_url: Rails.root.join('test/data/calendar/calendar1.ics'))
end
before { travel_to Time.zone.parse('2017-08-24T01:04:44Z0') }
@ -63,7 +63,7 @@ RSpec.describe Calendar, type: :model do
context 'with one-time and n-time (recurring) events' do
subject(:calendar) do
create(:calendar, ical_url: Rails.root.join('test', 'data', 'calendar', 'calendar3.ics'))
create(:calendar, ical_url: Rails.root.join('test/data/calendar/calendar3.ics'))
end
it 'accurately computes/imports events' do
@ -87,7 +87,7 @@ RSpec.describe Calendar, type: :model do
describe '#sync' do
subject(:calendar) do
create(:calendar, ical_url: Rails.root.join('test', 'data', 'calendar', 'calendar1.ics'), default: false)
create(:calendar, ical_url: Rails.root.join('test/data/calendar/calendar1.ics'), default: false)
end
before { travel_to Time.zone.parse('2017-08-24T01:04:44Z0') }
@ -106,6 +106,7 @@ RSpec.describe Calendar, type: :model do
expect { calendar.sync }
.not_to change(calendar, :public_holidays)
end
it 'does not create a background job for escalation rebuild' do
calendar # create and sync (1 inital background job is created)
expect { calendar.sync } # a second sync right after calendar create
@ -123,6 +124,7 @@ RSpec.describe Calendar, type: :model do
expect { calendar.sync }
.not_to change(calendar, :public_holidays)
end
it 'does not create a background job for escalation rebuild' do
expect { calendar.sync }
.not_to change { Delayed::Job.count }
@ -152,7 +154,7 @@ RSpec.describe Calendar, type: :model do
end
context 'and iCal URL has changed' do
before { calendar.assign_attributes(ical_url: Rails.root.join('test', 'data', 'calendar', 'calendar2.ics')) }
before { calendar.assign_attributes(ical_url: Rails.root.join('test/data/calendar/calendar2.ics')) }
it 'replaces #public_holidays with event data computed from new iCal URL' do
expect { calendar.save }

View file

@ -689,11 +689,6 @@ RSpec.describe Channel::EmailParser, type: :model do
include_examples 'creates a new ticket'
end
context 'when image/jpg attachment contains ticket reference' do
include_context 'ticket reference in image/jpg attachment'
include_examples 'creates a new ticket'
end
context 'when In-Reply-To header contains article message-id' do
include_context 'ticket reference in In-Reply-To header'
include_examples 'adds message to ticket'
@ -847,7 +842,7 @@ RSpec.describe Channel::EmailParser, type: :model do
describe 'formatting to/from addresses' do
# see https://github.com/zammad/zammad/issues/2198
context 'when sender address contains spaces (#2198)' do
let(:mail_file) { Rails.root.join('test', 'data', 'mail', 'mail071.box') }
let(:mail_file) { Rails.root.join('test/data/mail/mail071.box') }
let(:sender_email) { 'powerquadrantsystem@example.com' }
it 'removes them before creating a new user' do
@ -867,7 +862,7 @@ RSpec.describe Channel::EmailParser, type: :model do
# see https://github.com/zammad/zammad/issues/2254
context 'when sender address contains > (#2254)' do
let(:mail_file) { Rails.root.join('test', 'data', 'mail', 'mail076.box') }
let(:mail_file) { Rails.root.join('test/data/mail/mail076.box') }
let(:sender_email) { 'millionslotteryspaintransfer@example.com' }
it 'removes them before creating a new user' do
@ -897,7 +892,7 @@ RSpec.describe Channel::EmailParser, type: :model do
HEADER
context 'for emails from an unrecognized email address' do
let(:message_file) { Rails.root.join('test', 'data', 'email_signature_detection', 'client_a_1.txt') }
let(:message_file) { Rails.root.join('test/data/email_signature_detection/client_a_1.txt') }
it 'does not detect signatures' do
described_class.new.process({}, raw_mail)
@ -913,9 +908,9 @@ RSpec.describe Channel::EmailParser, type: :model do
described_class.new.process({}, header + File.read(previous_message_file))
end
let(:previous_message_file) { Rails.root.join('test', 'data', 'email_signature_detection', 'client_a_1.txt') }
let(:previous_message_file) { Rails.root.join('test/data/email_signature_detection/client_a_1.txt') }
let(:message_file) { Rails.root.join('test', 'data', 'email_signature_detection', 'client_a_2.txt') }
let(:message_file) { Rails.root.join('test/data/email_signature_detection/client_a_2.txt') }
it 'sets detected signature on user (in a background job)' do
described_class.new.process({}, raw_mail)
@ -936,7 +931,7 @@ RSpec.describe Channel::EmailParser, type: :model do
describe 'charset handling' do
# see https://github.com/zammad/zammad/issues/2224
context 'when header specifies Windows-1258 charset (#2224)' do
let(:mail_file) { Rails.root.join('test', 'data', 'mail', 'mail072.box') }
let(:mail_file) { Rails.root.join('test/data/mail/mail072.box') }
it 'does not raise Encoding::ConverterNotFoundError' do
expect { described_class.new.process({}, raw_mail) }
@ -945,7 +940,7 @@ RSpec.describe Channel::EmailParser, type: :model do
end
context 'when attachment for follow up check contains invalid charsets (#2808)' do
let(:mail_file) { Rails.root.join('test', 'data', 'mail', 'mail085.box') }
let(:mail_file) { Rails.root.join('test/data/mail/mail085.box') }
before { Setting.set('postmaster_follow_up_search_in', %w[attachment body]) }
@ -959,7 +954,7 @@ RSpec.describe Channel::EmailParser, type: :model do
describe 'attachment handling' do
context 'with header "Content-Transfer-Encoding: x-uuencode"' do
let(:mail_file) { Rails.root.join('test', 'data', 'mail', 'mail078-content_transfer_encoding_x_uuencode.box') }
let(:mail_file) { Rails.root.join('test/data/mail/mail078-content_transfer_encoding_x_uuencode.box') }
let(:article) { described_class.new.process({}, raw_mail).second }
it 'does not raise RuntimeError' do
@ -977,7 +972,7 @@ RSpec.describe Channel::EmailParser, type: :model do
describe 'inline image handling' do
# see https://github.com/zammad/zammad/issues/2486
context 'when image is large but not resizable' do
let(:mail_file) { Rails.root.join('test', 'data', 'mail', 'mail079.box') }
let(:mail_file) { Rails.root.join('test/data/mail/mail079.box') }
let(:attachment) { article.attachments.to_a.find { |i| i.filename == 'a.jpg' } }
let(:article) { described_class.new.process({}, raw_mail).second }
@ -1026,7 +1021,7 @@ RSpec.describe Channel::EmailParser, type: :model do
let(:message_id) { raw_mail[/(?<=^(References|Message-ID): )\S*/] }
context 'with future retries (delayed)' do
let(:mail_file) { Rails.root.join('test', 'data', 'mail', 'mail078.box') }
let(:mail_file) { Rails.root.join('test/data/mail/mail078.box') }
context 'on a closed ticket' do
before { ticket.update(state: Ticket::State.find_by(name: 'closed')) }
@ -1055,7 +1050,7 @@ RSpec.describe Channel::EmailParser, type: :model do
end
context 'with no future retries (undeliverable): sample input 1' do
let(:mail_file) { Rails.root.join('test', 'data', 'mail', 'mail033-undelivered-mail-returned-to-sender.box') }
let(:mail_file) { Rails.root.join('test/data/mail/mail033-undelivered-mail-returned-to-sender.box') }
context 'for original message sent by Agent' do
it 'sets #preferences on resulting ticket to { "send-auto-responses" => false, "is-auto-reponse" => true }' do
@ -1097,7 +1092,7 @@ RSpec.describe Channel::EmailParser, type: :model do
end
context 'with no future retries (undeliverable): sample input 2' do
let(:mail_file) { Rails.root.join('test', 'data', 'mail', 'mail055.box') }
let(:mail_file) { Rails.root.join('test/data/mail/mail055.box') }
it 'finds the article referenced in the bounce message headers, then adds the bounce message to its ticket' do
expect { described_class.new.process({}, raw_mail) }
@ -1181,67 +1176,7 @@ RSpec.describe Channel::EmailParser, type: :model do
end
describe '#compose_postmaster_reply' do
let(:raw_incoming_mail) { File.read(Rails.root.join('test', 'data', 'mail', 'mail010.box')) }
shared_examples 'postmaster reply' do
it 'composes postmaster reply' do
reply = described_class.new.send(:compose_postmaster_reply, raw_incoming_mail, locale)
expect(reply[:to]).to eq('smith@example.com')
expect(reply[:content_type]).to eq('text/plain')
expect(reply[:subject]).to eq(expected_subject)
expect(reply[:body]).to eq(expected_body)
end
end
context 'for English locale (en)' do
include_examples 'postmaster reply' do
let(:locale) { 'en' }
let(:expected_subject) { '[undeliverable] Message too large' }
let(:expected_body) do
body = <<~BODY
Dear Smith Sepp,
Unfortunately your email titled \"Gruß aus Oberalteich\" could not be delivered to one or more recipients.
Your message was 0.01 MB but we only accept messages up to 10 MB.
Please reduce the message size and try again. Thank you for your understanding.
Regretfully,
Postmaster of zammad.example.com
BODY
body.gsub(/\n/, "\r\n")
end
end
end
context 'for German locale (de)' do
include_examples 'postmaster reply' do
let(:locale) { 'de' }
let(:expected_subject) { '[Unzustellbar] Nachricht zu groß' }
let(:expected_body) do
body = <<~BODY
Hallo Smith Sepp,
Ihre E-Mail mit dem Betreff \"Gruß aus Oberalteich\" konnte nicht an einen oder mehrere Empfänger zugestellt werden.
Die Nachricht hatte eine Größe von 0.01 MB, wir akzeptieren jedoch nur E-Mails mit einer Größe von bis zu 10 MB.
Bitte reduzieren Sie die Größe Ihrer Nachricht und versuchen Sie es erneut. Vielen Dank für Ihr Verständnis.
Mit freundlichen Grüßen
Postmaster von zammad.example.com
BODY
body.gsub(/\n/, "\r\n")
end
end
end
end
describe '#compose_postmaster_reply' do
let(:raw_incoming_mail) { File.read(Rails.root.join('test', 'data', 'mail', 'mail010.box')) }
let(:raw_incoming_mail) { File.read(Rails.root.join('test/data/mail/mail010.box')) }
shared_examples 'postmaster reply' do
it 'composes postmaster reply' do

View file

@ -46,7 +46,7 @@ RSpec.describe Channel::Filter::Match::EmailRegex do
it { is_expected.to be(false) }
end
context 'and invalid regex (misused ? repeat operator)' do
context 'and invalid regex (unassociated wild card operator)' do
let(:sender) { 'regex:*' }
it { is_expected.to be(false) }
@ -102,7 +102,7 @@ RSpec.describe Channel::Filter::Match::EmailRegex do
ERR
end
context 'and invalid regex (misused ? repeat operator)' do
context 'and invalid regex (unassociated wild card operator)' do
let(:sender) { 'regex:*' }
it { expect { subject }.to raise_error(<<~ERR.chomp) }

View file

@ -6,7 +6,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
let(:group_read) { create(:group) }
let(:group_inactive) { create(:group, active: false) }
context '.group_through_identifier' do
describe '.group_through_identifier' do
it 'responds to group_through_identifier' do
expect(described_class).to respond_to(:group_through_identifier)
@ -21,7 +21,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '.group_through' do
describe '.group_through' do
it 'responds to group_through' do
expect(described_class).to respond_to(:group_through)
@ -32,13 +32,13 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#groups' do
describe '#groups' do
it 'responds to groups' do
expect(subject).to respond_to(:groups)
end
context '#groups.access' do
describe '#groups.access' do
it 'responds to groups.access' do
expect(subject.groups).to respond_to(:access)
@ -77,7 +77,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#group_access?' do
describe '#group_access?' do
before do
subject.group_names_access_map = {
@ -120,7 +120,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#group_ids_access' do
describe '#group_ids_access' do
before do
subject.group_names_access_map = {
@ -179,7 +179,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#groups_access' do
describe '#groups_access' do
it 'responds to groups_access' do
expect(subject).to respond_to(:groups_access)
@ -199,7 +199,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#group_names_access_map=' do
describe '#group_names_access_map=' do
it 'responds to group_names_access_map=' do
expect(subject).to respond_to(:group_names_access_map=)
@ -300,7 +300,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#group_names_access_map' do
describe '#group_names_access_map' do
it 'responds to group_names_access_map' do
expect(subject).to respond_to(:group_names_access_map)
@ -341,7 +341,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#group_ids_access_map=' do
describe '#group_ids_access_map=' do
it 'responds to group_ids_access_map=' do
expect(subject).to respond_to(:group_ids_access_map=)
@ -424,7 +424,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#group_ids_access_map' do
describe '#group_ids_access_map' do
it 'responds to group_ids_access_map' do
expect(subject).to respond_to(:group_ids_access_map)
@ -465,7 +465,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#associations_from_param' do
describe '#associations_from_param' do
it 'handles group_ids parameter as group_ids_access_map' do
expected = {
@ -488,7 +488,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#attributes_with_association_ids' do
describe '#attributes_with_association_ids' do
it 'includes group_ids as group_ids_access_map' do
expected = {
@ -503,7 +503,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '#attributes_with_association_names' do
describe '#attributes_with_association_names' do
it 'includes group_ids as group_ids_access_map' do
expected = {
@ -530,7 +530,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '.group_access' do
describe '.group_access' do
before do
subject.group_names_access_map = {
@ -566,7 +566,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
end
end
context '.group_access_ids' do
describe '.group_access_ids' do
it 'responds to group_access_ids' do
expect(described_class).to respond_to(:group_access_ids)

View file

@ -10,56 +10,56 @@ RSpec.shared_examples 'HasGroups and Permissions' do |group_access_no_permission
}
end
context '#group_access?' do
describe '#group_access?' do
it 'prevents instances without permissions' do
expect(subject.group_access?(group_read, 'read')).to be false
end
end
context '#group_ids_access' do
describe '#group_ids_access' do
it 'prevents instances without permissions' do
expect(subject.group_ids_access('read')).to be_empty
end
end
context '#groups_access' do
describe '#groups_access' do
it 'prevents instances without permissions' do
expect(subject.groups_access('read')).to be_empty
end
end
context '#group_names_access_map' do
describe '#group_names_access_map' do
it 'prevents instances without permissions' do
expect(subject.group_names_access_map).to be_empty
end
end
context '#group_ids_access_map' do
describe '#group_ids_access_map' do
it 'prevents instances without permissions' do
expect(subject.group_ids_access_map).to be_empty
end
end
context '#attributes_with_association_ids' do
describe '#attributes_with_association_ids' do
it 'prevents instances without permissions' do
expect(subject.attributes_with_association_ids['group_ids']).to be_empty
end
end
context '#attributes_with_association_names' do
describe '#attributes_with_association_names' do
it 'prevents instances without permissions' do
expect(subject.attributes_with_association_names['group_ids']).to be_empty
end
end
context '.group_access' do
describe '.group_access' do
it 'prevents instances without permissions' do
result = described_class.group_access(group_read.id, 'read')
@ -67,7 +67,7 @@ RSpec.shared_examples 'HasGroups and Permissions' do |group_access_no_permission
end
end
context '.group_access_ids' do
describe '.group_access_ids' do
it 'prevents instances without permissions' do
result = described_class.group_access(group_read.id, 'read')

View file

@ -7,7 +7,7 @@ RSpec.shared_examples 'HasRoles' do |group_access_factory:|
let(:group_role) { create(:group) }
let(:group_inactive) { create(:group, active: false) }
context '#role_access?' do
describe '#role_access?' do
it 'responds to role_access?' do
expect(subject).to respond_to(:role_access?)
@ -57,7 +57,7 @@ RSpec.shared_examples 'HasRoles' do |group_access_factory:|
end
end
context '.role_access_ids' do
describe '.role_access_ids' do
before do
role.group_names_access_map = {
@ -115,7 +115,7 @@ RSpec.shared_examples 'HasRoles' do |group_access_factory:|
}
end
context '#group_access?' do
describe '#group_access?' do
it 'falls back to #role_access?' do
expect(subject).to receive(:role_access?)
@ -128,7 +128,7 @@ RSpec.shared_examples 'HasRoles' do |group_access_factory:|
end
end
context '#group_ids_access' do
describe '#group_ids_access' do
before do
role.group_names_access_map = {
@ -198,7 +198,7 @@ RSpec.shared_examples 'HasRoles' do |group_access_factory:|
end
end
context '.group_access_ids' do
describe '.group_access_ids' do
it 'includes the result of .role_access_ids' do
result = described_class.group_access_ids(group_role, 'read')

View file

@ -1,6 +1,6 @@
RSpec.shared_examples 'HasSearchIndexBackend' do |indexed_factory:|
context '#search_index_update', performs_jobs: true do
describe '#search_index_update', performs_jobs: true do
subject { create(indexed_factory) }
before do

View file

@ -7,6 +7,7 @@ RSpec.describe Ticket::Subject do
it 'build subject based on new title' do
expect(ticket.subject_build('other title')).to eq("other title [Ticket##{ticket.number}]")
end
it 'build subject based on new title with ticket_hook_position left' do
Setting.set('ticket_hook_position', 'left')
expect(ticket.subject_build('other title')).to eq("[Ticket##{ticket.number}] other title")
@ -16,9 +17,11 @@ RSpec.describe Ticket::Subject do
Setting.set('ticket_hook_position', '')
expect(ticket.subject_build('other title')).to eq('other title')
end
it 'build subject based with forward argument' do
expect(ticket.subject_build('other title', 'forward')).to eq("FWD: other title [Ticket##{ticket.number}]")
end
it 'build subject based with reply argument' do
expect(ticket.subject_build('other title', 'reply')).to eq("RE: other title [Ticket##{ticket.number}]")
end
@ -28,21 +31,27 @@ RSpec.describe Ticket::Subject do
it 'cleanup subject with undefined string' do
expect(ticket.subject_clean(nil)).to eq('')
end
it 'cleanup subject with empty string' do
expect(ticket.subject_clean('')).to eq('')
end
it 'cleanup subject with long string which need to be truncated by [...]' do
expect(ticket.subject_clean('123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890')).to eq('12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[...]')
end
it 'cleanup subject with regular ticket#' do
expect(ticket.subject_clean("something [Ticket##{ticket.number}]")).to eq('something')
end
it 'cleanup subject with regular ticket# multiple time' do
expect(ticket.subject_clean("[Ticket##{ticket.number}] [Ticket##{ticket.number}] something [Ticket##{ticket.number}]")).to eq('something')
end
it 'cleanup subject with foreign ticket#' do
expect(ticket.subject_clean('something [Ticket#123456]')).to eq('something [Ticket#123456]')
end
it 'cleanup subject with some reply signs' do
expect(ticket.subject_clean('RE: RE: Re[5]: something [Ticket#123456]')).to eq('something [Ticket#123456]')
end

View file

@ -924,7 +924,7 @@ RSpec.describe Ticket, type: :model do
context 'when ticket is generated from email (with attachments)' do
subject(:ticket) { Channel::EmailParser.new.process({}, raw_email).first }
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail001.box')) }
let(:raw_email) { File.read(Rails.root.join('test/data/mail/mail001.box')) }
it 'adds attachments to the Store{::File,::Provider::DB} tables' do
expect { ticket }
@ -965,9 +965,7 @@ RSpec.describe Ticket, type: :model do
.and change { Store::File.count }.by(0)
.and change { Store::Provider::DB.count }.by(0)
end
end
context 'when only the duplicate ticket is destroyed' do
it 'deletes all related attachments' do
duplicate.destroy

View file

@ -259,7 +259,7 @@ RSpec.describe Translation do
it 'check download of translations' do
version = Version.get
locale = 'de-de'
directory = Rails.root.join('config', 'translations')
directory = Rails.root.join('config/translations')
if File.directory?(directory)
FileUtils.rm_rf(directory)
end

View file

@ -40,7 +40,7 @@ RSpec.describe Trigger, type: :model do
context 'when ticket is created via Channel::EmailParser.process' do
before { create(:email_address, groups: [Group.first]) }
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail001.box')) }
let(:raw_email) { File.read(Rails.root.join('test/data/mail/mail001.box')) }
it 'fires (without altering ticket state)' do
expect { Channel::EmailParser.new.process({}, raw_email) }
@ -54,7 +54,7 @@ RSpec.describe Trigger, type: :model do
context 'when ticket is created via Channel::EmailParser.process with inline image' do
before { create(:email_address, groups: [Group.first]) }
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail010.box')) }
let(:raw_email) { File.read(Rails.root.join('test/data/mail/mail010.box')) }
it 'fires (without altering ticket state)' do
expect { Channel::EmailParser.new.process({}, raw_email) }
@ -130,7 +130,7 @@ RSpec.describe Trigger, type: :model do
subject: raw_email[/(?<=^Subject: Re: ).*$/])
end
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail005.box')) }
let(:raw_email) { File.read(Rails.root.join('test/data/mail/mail005.box')) }
it 'fires (without altering ticket state)' do
expect { Channel::EmailParser.new.process({}, raw_email) }
@ -147,7 +147,7 @@ RSpec.describe Trigger, type: :model do
message_id: raw_email[/(?<=^Message-ID: )\S*/])
end
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail055.box')) }
let(:raw_email) { File.read(Rails.root.join('test/data/mail/mail055.box')) }
it 'does not fire' do
expect { Channel::EmailParser.new.process({}, raw_email) }

View file

@ -21,7 +21,7 @@ require 'rspec/rails'
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
Dir[Rails.root.join('spec/support/**/*.rb')].sort.each { |f| require f }
# Checks for pending migration and applies them before tests are run.
# If you are not using ActiveRecord, you can remove this line.

View file

@ -27,7 +27,7 @@ RSpec.describe 'Monitoring', type: :request do
channel.last_log_out = nil
channel.save!
end
dir = Rails.root.join('tmp', 'unprocessable_mail')
dir = Rails.root.join('tmp/unprocessable_mail')
Dir.glob("#{dir}/*.eml") do |entry|
File.delete(entry)
end
@ -457,7 +457,7 @@ RSpec.describe 'Monitoring', type: :request do
travel_back
# health_check - unprocessable mail
dir = Rails.root.join('tmp', 'unprocessable_mail')
dir = Rails.root.join('tmp/unprocessable_mail')
FileUtils.mkdir_p(dir)
FileUtils.touch("#{dir}/test.eml")

View file

@ -133,6 +133,7 @@ RSpec.describe 'Telegram Webhook Integration', type: :request do
post '/api/v1/channels_telegram_webhook', params: read_message('private', 'start'), as: :json
expect(response).to have_http_status(:not_found)
end
it 'bot id is missing' do
post '/api/v1/channels_telegram_webhook/not_existing', params: read_message('private', 'start'), as: :json
expect(response).to have_http_status(:unprocessable_entity)

View file

@ -140,7 +140,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
describe 'auto-creation of tickets/articles on webhook receipt' do
let(:webhook_payload) do
JSON.parse(File.read(Rails.root.join('test', 'data', 'twitter', payload_file))).symbolize_keys
JSON.parse(File.read(Rails.root.join('test/data/twitter', payload_file))).symbolize_keys
end
context 'for outbound DMs' do
@ -238,7 +238,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
before { post '/api/v1/channels_twitter_webhook', **previous_webhook_payload, as: :json }
let(:previous_webhook_payload) do
JSON.parse(File.read(Rails.root.join('test', 'data', 'twitter', 'webhook2_direct_message.json'))).symbolize_keys
JSON.parse(File.read(Rails.root.join('test/data/twitter/webhook2_direct_message.json'))).symbolize_keys
end
it 'returns 200' do

View file

@ -66,7 +66,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
Store.add(
object: 'Ticket::Article',
o_id: article.id,
data: File.binread(Rails.root.join('test', 'data', 'elasticsearch', 'es-normal.txt')),
data: File.binread(Rails.root.join('test/data/elasticsearch/es-normal.txt')),
filename: 'es-normal.txt',
preferences: {},
created_by_id: 1,

View file

@ -66,7 +66,7 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
end
it 'does test attachments for split' do
email_file_path = Rails.root.join('test', 'data', 'mail', 'mail024.box')
email_file_path = Rails.root.join('test/data/mail/mail024.box')
email_raw_string = File.read(email_file_path)
ticket_p, article_p, _user_p = Channel::EmailParser.new.process({}, email_raw_string)
@ -81,7 +81,7 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
end
it 'does test attachments for forward' do
email_file_path = Rails.root.join('test', 'data', 'mail', 'mail008.box')
email_file_path = Rails.root.join('test/data/mail/mail008.box')
email_raw_string = File.read(email_file_path)
_ticket_p, article_p, _user_p = Channel::EmailParser.new.process({}, email_raw_string)
@ -96,7 +96,7 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
expect(json_response['attachments']).to be_a_kind_of(Array)
expect(json_response['attachments']).to be_blank
email_file_path = Rails.root.join('test', 'data', 'mail', 'mail024.box')
email_file_path = Rails.root.join('test/data/mail/mail024.box')
email_raw_string = File.read(email_file_path)
_ticket_p, article_p, _user_p = Channel::EmailParser.new.process({}, email_raw_string)

View file

@ -71,7 +71,7 @@ module BrowserTestHelper
self.until do
yield
rescue Capybara::ElementNotFound # rubocop:disable Lint/HandleExceptions
rescue Capybara::ElementNotFound # rubocop:disable Lint/SuppressedException
end
rescue Selenium::WebDriver::Error::TimeOutError => e

View file

@ -1,5 +1,5 @@
# require all database migrations so we can test them without manual require
Rails.root.join('db', 'migrate').children.each do |migration|
Rails.root.join('db/migrate').children.each do |migration|
require migration.to_s
end

View file

@ -5,7 +5,7 @@ RSpec.describe 'Auto wizard', type: :system, set_up: false do
it 'Automatic setup and login' do
FileUtils.ln(
Rails.root.join('contrib', 'auto_wizard_test.json'),
Rails.root.join('contrib/auto_wizard_test.json'),
Rails.root.join('auto_wizard.json'),
force: true
)

View file

@ -44,8 +44,8 @@ class AgentTicketAttachmentTest < TestCase
# add attachment, attachment check should quiet
file_upload(
css: '.content.active .attachmentPlaceholder-inputHolder input',
files: [Rails.root.join('test', 'data', 'upload', 'upload1.txt'),
Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
files: [Rails.root.join('test/data/upload/upload1.txt'),
Rails.root.join('test/data/upload/upload2.jpg')],
)
# upload might take a while
@ -98,7 +98,7 @@ class AgentTicketAttachmentTest < TestCase
# add attachment, attachment check should quiet
file_upload(
css: '.content.active .attachmentPlaceholder-inputHolder input',
files: [Rails.root.join('test', 'data', 'upload', 'upload1.txt')],
files: [Rails.root.join('test/data/upload/upload1.txt')],
)
# upload might take a while
@ -145,8 +145,8 @@ class AgentTicketAttachmentTest < TestCase
# add attachment without body
file_upload(
css: '.content.active .attachmentPlaceholder-inputHolder input',
files: [Rails.root.join('test', 'data', 'upload', 'upload1.txt'),
Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
files: [Rails.root.join('test/data/upload/upload1.txt'),
Rails.root.join('test/data/upload/upload2.jpg')],
)
# upload might take a while

View file

@ -43,7 +43,7 @@ class AgentTicketZoomHideTest < TestCase
ticket_update(
data: {
body: 'added image attachment',
files: [Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
files: [Rails.root.join('test/data/upload/upload2.jpg')],
},
)

View file

@ -1,5 +1,5 @@
ENV['RAILS_ENV'] = 'test'
# rubocop:disable HandleExceptions, NonLocalExitFromIterator, Style/GuardClause, Lint/MissingCopEnableDirective
# rubocop:disable Lint/SuppressedException, Lint/NonLocalExitFromIterator, Style/GuardClause, Lint/MissingCopEnableDirective
require File.expand_path('../config/environment', __dir__)
require 'selenium-webdriver'
require 'json'
@ -1475,7 +1475,7 @@ set type of task (closeTab, closeNextInOverview, stayOnTab)
return true
end
end
rescue
rescue # rubocop:disable Lint/SuppressedException
# try again
end
end
@ -1537,7 +1537,7 @@ wait untill text in selector disabppears
sleep 1
return true
end
rescue
rescue # rubocop:disable Lint/SuppressedException
# try again
end
end
@ -1700,7 +1700,7 @@ wait untill text in selector disabppears
else
break
end
rescue
rescue # rubocop:disable Lint/SuppressedException
# try again
end
end
@ -2542,7 +2542,7 @@ wait untill text in selector disabppears
if text.match?(/(Discard your unsaved changes.|Verwerfen der)/)
found = true
end
rescue
rescue # rubocop:disable Lint/SuppressedException
# try again
end
sleep 1
@ -2580,7 +2580,7 @@ wait untill text in selector disabppears
sleep 1
return true
end
rescue
rescue # rubocop:disable Lint/SuppressedException
# try again
end
sleep 1
@ -4485,7 +4485,7 @@ wait untill text in selector disabppears
puts "#{time}/#{log.level}: #{log.message}"
end
end
rescue
rescue # rubocop:disable Lint/SuppressedException
# failed to get logs
end
return if !DEBUG

View file

@ -143,7 +143,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
Store.add(
object: 'Ticket::Article',
o_id: article1.id,
data: File.binread(Rails.root.join('test', 'data', 'elasticsearch', 'es-normal.txt')),
data: File.binread(Rails.root.join('test/data/elasticsearch/es-normal.txt')),
filename: 'es-normal.txt',
preferences: {},
created_by_id: 1,
@ -205,7 +205,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
Store.add(
object: 'Ticket::Article',
o_id: article1.id,
data: File.binread(Rails.root.join('test', 'data', 'elasticsearch', 'es-normal.txt')),
data: File.binread(Rails.root.join('test/data/elasticsearch/es-normal.txt')),
filename: 'es-normal.txt',
preferences: {},
created_by_id: 1,
@ -216,7 +216,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
Store.add(
object: 'Ticket::Article',
o_id: article1.id,
data: File.binread(Rails.root.join('test', 'data', 'elasticsearch', 'es-pdf1.pdf')),
data: File.binread(Rails.root.join('test/data/elasticsearch/es-pdf1.pdf')),
filename: 'es-pdf1.pdf',
preferences: {},
created_by_id: 1,
@ -227,7 +227,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
Store.add(
object: 'Ticket::Article',
o_id: article1.id,
data: File.binread(Rails.root.join('test', 'data', 'elasticsearch', 'es-box1.box')),
data: File.binread(Rails.root.join('test/data/elasticsearch/es-box1.box')),
filename: 'mail1.box',
preferences: {},
created_by_id: 1,
@ -238,7 +238,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
Store.add(
object: 'Ticket::Article',
o_id: article1.id,
data: File.binread(Rails.root.join('test', 'data', 'elasticsearch', 'es-too-big.txt')),
data: File.binread(Rails.root.join('test/data/elasticsearch/es-too-big.txt')),
filename: 'es-too-big.txt',
preferences: {},
created_by_id: 1,

View file

@ -93,7 +93,7 @@ Oversized Email Message Body #{'#' * 120_000}
".gsub(/\n/, "\r\n")
large_message_md5 = Digest::MD5.hexdigest(large_message)
large_message_size = format('%.2f', large_message.size.to_f / 1024 / 1024)
large_message_size = format('%<MB>.2f', MB: large_message.size.to_f / 1024 / 1024)
imap.append(@folder, large_message, [], Time.zone.now)
@ -101,7 +101,7 @@ Oversized Email Message Body #{'#' * 120_000}
# 1. verify that the oversized email has been saved locally to:
# /tmp/oversized_mail/yyyy-mm-ddThh:mm:ss-:md5.eml
path = Rails.root.join('tmp', 'oversized_mail')
path = Rails.root.join('tmp/oversized_mail')
target_files = Dir.entries(path).select do |filename|
filename =~ /^#{large_message_md5}\.eml$/
end
@ -111,7 +111,7 @@ Oversized Email Message Body #{'#' * 120_000}
target_file = target_files.max
# verify that the file is byte for byte identical to the sent message
file_path = Rails.root.join('tmp', 'oversized_mail', target_file)
file_path = Rails.root.join('tmp/oversized_mail', target_file)
eml_data = File.read(file_path)
assert_equal(large_message, eml_data)
@ -181,7 +181,7 @@ Oversized Email Message Body #{'#' * 120_000}
# 1. verify that the oversized email has been saved locally to:
# /tmp/oversized_mail/yyyy-mm-ddThh:mm:ss-:md5.eml
path = Rails.root.join('tmp', 'oversized_mail')
path = Rails.root.join('tmp/oversized_mail')
target_files = Dir.entries(path).select do |filename|
filename =~ /^.+?\.eml$/
end

View file

@ -17,8 +17,8 @@ class ActiveSupport::TestCase
Cache.clear
# load seeds
load Rails.root.join('db', 'seeds.rb')
load Rails.root.join('test', 'fixtures', 'seeds.rb')
load Rails.root.join('db/seeds.rb')
load Rails.root.join('test/fixtures/seeds.rb')
# set system mode to done / to activate
Setting.set('system_init_done', true)

View file

@ -14,8 +14,8 @@ class ActiveSupport::TestCase
Cache.clear
# load seeds
load Rails.root.join('db', 'seeds.rb')
load Rails.root.join('test', 'fixtures', 'seeds.rb')
load Rails.root.join('db/seeds.rb')
load Rails.root.join('test/fixtures/seeds.rb')
# set system mode to done / to activate
Setting.set('system_init_done', true)

View file

@ -1,2 +1,2 @@
# automatically require all helpers in test/support
Dir[Rails.root.join('test', 'support', '**', '*.rb')].each { |f| require f }
Dir[Rails.root.join('test/support/**/*.rb')].sort.each { |f| require f }

View file

@ -4,7 +4,7 @@ class StoreTest < ActiveSupport::TestCase
test 'store fs - get_location' do
sha = 'ed7002b439e9ac845f22357d822bac1444730fbdb6016d3ec9432297b9ec9f73'
location = Store::Provider::File.get_location(sha)
assert_equal(Rails.root.join('storage', 'fs', 'ed70', '02b4', '39e9a', 'c845f', '22357d8', '22bac14', '44730fbdb6016d3ec9432297b9ec9f73').to_s, location)
assert_equal(Rails.root.join('storage/fs/ed70/02b4/39e9a/c845f/22357d8/22bac14/44730fbdb6016d3ec9432297b9ec9f73').to_s, location)
end
test 'store fs - empty dir remove' do
@ -18,11 +18,11 @@ class StoreTest < ActiveSupport::TestCase
Store::Provider::File.delete(sha)
exists = File.exist?(location)
assert_not(exists)
exists = File.exist?(Rails.root.join('storage', 'fs', 'ed70', '02b4'))
exists = File.exist?(Rails.root.join('storage/fs/ed70/02b4'))
assert_not(exists)
exists = File.exist?(Rails.root.join('storage', 'fs', 'ed70'))
exists = File.exist?(Rails.root.join('storage/fs/ed70'))
assert_not(exists)
exists = File.exist?(Rails.root.join('storage', 'fs'))
exists = File.exist?(Rails.root.join('storage/fs'))
assert(exists)
exists = File.exist?(Rails.root.join('storage'))
assert(exists)
@ -41,12 +41,12 @@ class StoreTest < ActiveSupport::TestCase
o_id: 2,
},
{
data: File.binread(Rails.root.join('test', 'data', 'pdf', 'test1.pdf')),
data: File.binread(Rails.root.join('test/data/pdf/test1.pdf')),
filename: 'test.pdf',
o_id: 3,
},
{
data: File.binread(Rails.root.join('test', 'data', 'pdf', 'test1.pdf')),
data: File.binread(Rails.root.join('test/data/pdf/test1.pdf')),
filename: 'test-again.pdf',
o_id: 4,
},
@ -158,7 +158,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject1',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'upload', 'upload1.txt')),
data: File.binread(Rails.root.join('test/data/upload/upload1.txt')),
filename: 'test1.pdf',
preferences: {
content_type: 'text/plain',
@ -180,7 +180,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject2',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'upload', 'upload1.txt')),
data: File.binread(Rails.root.join('test/data/upload/upload1.txt')),
filename: 'test1.pdf',
preferences: {
content_type: 'image/jpg',
@ -202,7 +202,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject3',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'upload', 'upload2.jpg')),
data: File.binread(Rails.root.join('test/data/upload/upload2.jpg')),
filename: 'test1.pdf',
preferences: {
content_type: 'image/jpg',
@ -228,7 +228,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject4',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'image', '1000x1000.png')),
data: File.binread(Rails.root.join('test/data/image/1000x1000.png')),
filename: 'test1.png',
preferences: {
content_type: 'image/png',
@ -252,7 +252,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject5',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'image', '1x1.png')),
data: File.binread(Rails.root.join('test/data/image/1x1.png')),
filename: 'test1.png',
preferences: {
content_type: 'image/png',
@ -274,7 +274,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject6',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'image', '4000x1.jpg')),
data: File.binread(Rails.root.join('test/data/image/4000x1.jpg')),
filename: 'test1.jpg',
preferences: {
content_type: 'image/jpg',
@ -290,7 +290,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject7',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'image', '8000x25.jpg')),
data: File.binread(Rails.root.join('test/data/image/8000x25.jpg')),
filename: 'test1.jpg',
preferences: {
content_type: 'image/jpg',
@ -306,7 +306,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject8',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'image', '8000x300.jpg')),
data: File.binread(Rails.root.join('test/data/image/8000x300.jpg')),
filename: 'test1.jpg',
preferences: {
content_type: 'image/jpg',
@ -323,7 +323,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject3',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'upload', 'upload2.jpg')),
data: File.binread(Rails.root.join('test/data/upload/upload2.jpg')),
filename: 'test1.pdf',
preferences: {
content_type: 'image/jpg',
@ -340,7 +340,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject1',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'upload', 'upload1.txt')),
data: File.binread(Rails.root.join('test/data/upload/upload1.txt')),
filename: 'test1.pdf',
preferences: {
content_type: 'text/plain',
@ -358,7 +358,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject1',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'upload', 'upload1.txt')),
data: File.binread(Rails.root.join('test/data/upload/upload1.txt')),
filename: 'test1.pdf',
preferences: {
content_type: 'text/plain',
@ -385,7 +385,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject1',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'upload', 'upload1.txt')),
data: File.binread(Rails.root.join('test/data/upload/upload1.txt')),
filename: 'test1.pdf',
preferences: preferences,
created_by_id: 1,
@ -408,7 +408,7 @@ class StoreTest < ActiveSupport::TestCase
store = Store.add(
object: 'SomeObject1',
o_id: rand(1_234_567_890),
data: File.binread(Rails.root.join('test', 'data', 'upload', 'upload1.txt')),
data: File.binread(Rails.root.join('test/data/upload/upload1.txt')),
filename: 'test1.pdf',
preferences: preferences,
created_by_id: 1,

View file

@ -707,7 +707,7 @@ class TicketTriggerRecursiveDisabledTest < ActiveSupport::TestCase
)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('aaäöüßad asd', ticket_p.title)
@ -833,21 +833,21 @@ class TicketTriggerRecursiveDisabledTest < ActiveSupport::TestCase
assert_equal('text/html', article_p.content_type)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('new', ticket_p.state.name)
assert_equal(2, ticket_p.articles.count)
# process mail with Precedence header (no auto response)
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail2.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail2.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('new', ticket_p.state.name)
assert_equal(1, ticket_p.articles.count)
# process mail with abuse@ (no auto response)
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail3.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail3.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('new', ticket_p.state.name)
@ -926,7 +926,7 @@ class TicketTriggerRecursiveDisabledTest < ActiveSupport::TestCase
)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('aaäöüßad asd', ticket_p.title)
@ -990,7 +990,7 @@ class TicketTriggerRecursiveDisabledTest < ActiveSupport::TestCase
)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('aaäöüßad asd', ticket_p.title)
@ -1074,7 +1074,7 @@ class TicketTriggerRecursiveDisabledTest < ActiveSupport::TestCase
)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('aaäöüßad asd', ticket_p.title)
@ -1153,7 +1153,7 @@ class TicketTriggerRecursiveDisabledTest < ActiveSupport::TestCase
)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal(1, ticket_p.articles.count)
@ -4231,7 +4231,7 @@ class TicketTriggerRecursiveDisabledTest < ActiveSupport::TestCase
updated_by_id: 1,
)
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test', 'data', 'mail', 'mail065.box')))
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test/data/mail/mail065.box')))
assert_equal('aaäöüßad asd', ticket1.title, 'ticket1.title verify')
assert_equal('Users', ticket1.group.name, 'ticket1.group verify')
@ -4272,7 +4272,7 @@ class TicketTriggerRecursiveDisabledTest < ActiveSupport::TestCase
updated_by_id: 1,
)
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test', 'data', 'mail', 'mail065.box')))
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test/data/mail/mail065.box')))
assert_equal('aaäöüßad asd', ticket1.title, 'ticket1.title verify')
assert_equal('Users', ticket1.group.name, 'ticket1.group verify')

View file

@ -721,7 +721,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('aaäöüßad asd', ticket_p.title)
@ -847,7 +847,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
assert_equal('text/html', article_p.content_type)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p1, _article_p1, _user_p1, _mail = Channel::EmailParser.new.process({}, content)
assert_not_equal(ticket_p.id, ticket_p1.id)
@ -855,7 +855,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
assert_equal(2, ticket_p1.articles.count)
# process mail with Precedence header (no auto response)
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail2.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail2.box'))
ticket_p2, _article_p2, _user_p2, _mail = Channel::EmailParser.new.process({}, content)
assert_not_equal(ticket_p.id, ticket_p1.id)
@ -865,7 +865,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
assert_equal(1, ticket_p2.articles.count)
# process mail with abuse@ (no auto response)
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail3.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail3.box'))
ticket_p3, _article_p3, _user_p3, _mail = Channel::EmailParser.new.process({}, content)
assert_not_equal(ticket_p.id, ticket_p1.id)
@ -951,7 +951,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('aaäöüßad asd', ticket_p.title)
@ -1016,7 +1016,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('aaäöüßad asd', ticket_p.title)
@ -1100,7 +1100,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal('aaäöüßad asd', ticket_p.title)
@ -1179,7 +1179,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
)
# process mail without Precedence header
content = File.read(Rails.root.join('test', 'data', 'ticket_trigger', 'mail1.box'))
content = File.read(Rails.root.join('test/data/ticket_trigger/mail1.box'))
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, content)
assert_equal(1, ticket_p.articles.count)
@ -4257,7 +4257,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
updated_by_id: 1,
)
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test', 'data', 'mail', 'mail065.box')))
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test/data/mail/mail065.box')))
assert_equal('aaäöüßad asd', ticket1.title, 'ticket1.title verify')
assert_equal('Users', ticket1.group.name, 'ticket1.group verify')
@ -4298,7 +4298,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
updated_by_id: 1,
)
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test', 'data', 'mail', 'mail065.box')))
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test/data/mail/mail065.box')))
assert_equal('aaäöüßad asd', ticket1.title, 'ticket1.title verify')
assert_equal('Users', ticket1.group.name, 'ticket1.group verify')
@ -4626,7 +4626,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
updated_by_id: 1,
)
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test', 'data', 'mail', 'mail048.box')))
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test/data/mail/mail048.box')))
assert_equal('AW: OTRS / Anfrage OTRS Einführung/Präsentation [Ticket#11545]', ticket1.title, 'ticket1.title verify')
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
@ -4671,7 +4671,7 @@ class TicketTriggerTest < ActiveSupport::TestCase
updated_by_id: 1,
)
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test', 'data', 'mail', 'mail069.box')))
ticket1, _article1, _user, _mail = Channel::EmailParser.new.process({}, File.read(Rails.root.join('test/data/mail/mail069.box')))
assert_equal('Online-apotheke. Günstigster Preis. Ohne Rezepte', ticket1.title, 'ticket1.title verify')
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')