Relocate test data files from test/fixtures to test/data

This commit is contained in:
Ryan Lue 2018-06-05 11:28:12 +08:00
parent 13ef5d4246
commit dfebe8d767
149 changed files with 337 additions and 327 deletions

View file

@ -10,11 +10,11 @@ process emails from STDIN
e. g.
cat test/fixtures/mail1.box | rails r 'Channel::Driver::MailStdin.new'
cat test/data/mail/mail001.box | rails r 'Channel::Driver::MailStdin.new'
e. g. if you want to trust on mail headers
cat test/fixtures/mail1.box | rails r 'Channel::Driver::MailStdin.new(trusted: true)'
cat test/data/mail/mail001.box | rails r 'Channel::Driver::MailStdin.new(trusted: true)'
=end

View file

@ -190,7 +190,7 @@ class Channel::EmailParser
# get attachments
mail.parts&.each do |part|
# protect process to work fine with spam emails, see test/fixtures/mail15.box
# protect process to work fine with spam emails, see test/data/mail/mail015.box
begin
attachs = _get_attachment(part, data[:attachments], mail)
data[:attachments].concat(attachs)
@ -848,7 +848,7 @@ module Mail
end
end
# workaround to parse subjects with 2 different encodings correctly (e. g. quoted-printable see test/fixtures/mail9.box)
# workaround to parse subjects with 2 different encodings correctly (e. g. quoted-printable see test/data/mail/mail009.box)
module Encodings
def self.value_decode(str)
# Optimization: If there's no encoded-words in the string, just return it
@ -884,7 +884,7 @@ module Mail
end
end
# issue#348 - IMAP mail fetching stops because of broken spam email (e. g. broken Content-Transfer-Encoding value see test/fixtures/mail43.box)
# issue#348 - IMAP mail fetching stops because of broken spam email (e. g. broken Content-Transfer-Encoding value see test/data/mail/mail043.box)
# https://github.com/zammad/zammad/issues/348
class Body
def decoded

View file

@ -111,7 +111,7 @@ class String
string = "#{self}" # rubocop:disable Style/UnneededInterpolation
# in case of invalid encoding, strip invalid chars
# see also test/fixtures/mail21.box
# see also test/data/mail/mail021.box
# note: string.encode!('UTF-8', 'UTF-8', :invalid => :replace, :replace => '?') was not detecting invalid chars
if !string.valid_encoding?
string = string.chars.select(&:valid_encoding?).join

View file

@ -119,9 +119,9 @@ module Enrichment
def fetch
if !Rails.env.production?
filename = Rails.root.join('test', 'fixtures', 'clearbit', "#{@local_user.email}.json")
filename = Rails.root.join('test', 'data', 'clearbit', "#{@local_user.email}.json")
if File.exist?(filename)
data = IO.binread(filename)
data = File.binread(filename)
return JSON.parse(data) if data
end
end

View file

@ -45,7 +45,8 @@ class AgentTicketAttachmentTest < TestCase
# add attachment, attachment check should quiet
file_upload(
css: '.content.active .attachmentPlaceholder-inputHolder input',
files: ['test/fixtures/upload2.jpg', 'test/fixtures/upload1.txt'],
files: [Rails.root.join('test', 'data', 'upload', 'upload1.txt'),
Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
)
# submit form
@ -91,7 +92,7 @@ class AgentTicketAttachmentTest < TestCase
# add attachment, attachment check should quiet
file_upload(
css: '.content.active .attachmentPlaceholder-inputHolder input',
files: ['test/fixtures/upload1.txt'],
files: [Rails.root.join('test', 'data', 'upload', 'upload1.txt')],
)
# submit form
@ -132,7 +133,8 @@ class AgentTicketAttachmentTest < TestCase
# add attachment without body
file_upload(
css: '.content.active .attachmentPlaceholder-inputHolder input',
files: ['test/fixtures/upload2.jpg', 'test/fixtures/upload1.txt'],
files: [Rails.root.join('test', 'data', 'upload', 'upload1.txt'),
Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
)
# submit form

View file

@ -1226,7 +1226,7 @@ set type of task (closeTab, closeNextInOverview, stayOnTab)
file_upload(
browser: browser1,
css: '.content.active .attachmentPlaceholder-inputHolder input'
files: ['path/in/home/some_file.ext'], # 'test/fixtures/test1.pdf'
files: ['path/in/home/some_file.ext'], # 'test/data/pdf/test1.pdf'
)
=end

View file

@ -531,7 +531,8 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-admin@example.com', 'adminpw')
# invalid file
csv_file = ::Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'csv', 'organization_simple_col_not_existing.csv'), 'text/csv')
csv_file_path = Rails.root.join('test', 'data', 'csv', 'organization_simple_col_not_existing.csv')
csv_file = ::Rack::Test::UploadedFile.new(csv_file_path, 'text/csv')
post '/api/v1/organizations/import?try=true', params: { file: csv_file, col_sep: ';' }, headers: { 'Authorization' => credentials }
assert_response(200)
result = JSON.parse(@response.body)
@ -545,7 +546,8 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
assert_equal("Line 2: unknown attribute 'name2' for Organization.", result['errors'][1])
# valid file try
csv_file = ::Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'csv', 'organization_simple.csv'), 'text/csv')
csv_file_path = Rails.root.join('test', 'data', 'csv', 'organization_simple.csv')
csv_file = ::Rack::Test::UploadedFile.new(csv_file_path, 'text/csv')
post '/api/v1/organizations/import?try=true', params: { file: csv_file, col_sep: ';' }, headers: { 'Authorization' => credentials }
assert_response(200)
result = JSON.parse(@response.body)
@ -559,7 +561,8 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
assert_nil(Organization.find_by(name: 'organization-member-import2'))
# valid file
csv_file = ::Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'csv', 'organization_simple.csv'), 'text/csv')
csv_file_path = Rails.root.join('test', 'data', 'csv', 'organization_simple.csv')
csv_file = ::Rack::Test::UploadedFile.new(csv_file_path, 'text/csv')
post '/api/v1/organizations/import', params: { file: csv_file, col_sep: ';' }, headers: { 'Authorization' => credentials }
assert_response(200)
result = JSON.parse(@response.body)

View file

@ -101,7 +101,8 @@ class TextModuleControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-admin@example.com', 'adminpw')
# invalid file
csv_file = ::Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'csv', 'text_module_simple_col_not_existing.csv'), 'text/csv')
csv_file_path = Rails.root.join('test', 'data', 'csv', 'text_module_simple_col_not_existing.csv')
csv_file = ::Rack::Test::UploadedFile.new(csv_file_path, 'text/csv')
post '/api/v1/text_modules/import?try=true', params: { file: csv_file, col_sep: ';' }, headers: { 'Authorization' => credentials }
assert_response(200)
result = JSON.parse(@response.body)
@ -115,7 +116,8 @@ class TextModuleControllerTest < ActionDispatch::IntegrationTest
assert_equal("Line 2: unknown attribute 'keywords2' for TextModule.", result['errors'][1])
# valid file try
csv_file = ::Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'csv', 'text_module_simple.csv'), 'text/csv')
csv_file_path = Rails.root.join('test', 'data', 'csv', 'text_module_simple.csv')
csv_file = ::Rack::Test::UploadedFile.new(csv_file_path, 'text/csv')
post '/api/v1/text_modules/import?try=true', params: { file: csv_file, col_sep: ';' }, headers: { 'Authorization' => credentials }
assert_response(200)
result = JSON.parse(@response.body)
@ -129,7 +131,8 @@ class TextModuleControllerTest < ActionDispatch::IntegrationTest
assert_nil(TextModule.find_by(name: 'some name2'))
# valid file
csv_file = ::Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'csv', 'text_module_simple.csv'), 'text/csv')
csv_file_path = Rails.root.join('test', 'data', 'csv', 'text_module_simple.csv')
csv_file = ::Rack::Test::UploadedFile.new(csv_file_path, 'text/csv')
post '/api/v1/text_modules/import', params: { file: csv_file, col_sep: ';' }, headers: { 'Authorization' => credentials }
assert_response(200)
result = JSON.parse(@response.body)

View file

@ -144,7 +144,8 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest
test '01.02 test attachments for split' do
headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' }
email_raw_string = IO.binread('test/fixtures/mail24.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)
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
@ -161,7 +162,8 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest
test '01.03 test attachments for forward' do
headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' }
email_raw_string = IO.binread('test/fixtures/mail8.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)
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
@ -177,7 +179,8 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest
assert_equal(result['attachments'].class, Array)
assert(result['attachments'].blank?)
email_raw_string = IO.binread('test/fixtures/mail24.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)
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: { form_id: '1234-2' }.to_json, headers: headers.merge('Authorization' => credentials)

View file

@ -978,7 +978,8 @@ class UserControllerTest < ActionDispatch::IntegrationTest
credentials = ActionController::HttpAuthentication::Basic.encode_credentials('rest-admin@example.com', 'adminpw')
# invalid file
csv_file = ::Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'csv', 'user_simple_col_not_existing.csv'), 'text/csv')
csv_file_path = Rails.root.join('test', 'data', 'csv', 'user_simple_col_not_existing.csv')
csv_file = ::Rack::Test::UploadedFile.new(csv_file_path, 'text/csv')
post '/api/v1/users/import?try=true', params: { file: csv_file, col_sep: ';' }, headers: { 'Authorization' => credentials }
assert_response(200)
result = JSON.parse(@response.body)
@ -992,7 +993,8 @@ class UserControllerTest < ActionDispatch::IntegrationTest
assert_equal("Line 2: unknown attribute 'firstname2' for User.", result['errors'][1])
# valid file try
csv_file = ::Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'csv', 'user_simple.csv'), 'text/csv')
csv_file_path = Rails.root.join('test', 'data', 'csv', 'user_simple.csv')
csv_file = ::Rack::Test::UploadedFile.new(csv_file_path, 'text/csv')
post '/api/v1/users/import?try=true', params: { file: csv_file, col_sep: ';' }, headers: { 'Authorization' => credentials }
assert_response(200)
result = JSON.parse(@response.body)
@ -1006,7 +1008,8 @@ class UserControllerTest < ActionDispatch::IntegrationTest
assert_nil(User.find_by(login: 'user-simple-import2'))
# valid file
csv_file = ::Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'csv', 'user_simple.csv'), 'text/csv')
csv_file_path = Rails.root.join('test', 'data', 'csv', 'user_simple.csv')
csv_file = ::Rack::Test::UploadedFile.new(csv_file_path, 'text/csv')
post '/api/v1/users/import', params: { file: csv_file, col_sep: ';' }, headers: { 'Authorization' => credentials }
assert_response(200)
result = JSON.parse(@response.body)

View file

Can't render this file because it has a wrong number of fields in line 2.

View file

Can't render this file because it has a wrong number of fields in line 2.

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