Improved attachment test.

This commit is contained in:
Martin Edenhofer 2015-04-07 01:56:53 +02:00
parent acbe704c3b
commit cfc3e846b6
4 changed files with 12 additions and 12 deletions

View file

@ -1,11 +1,11 @@
# Setup a Elasticsearch
* Install Elasticsearch
http://www.elasticsearch.org/overview/elkdownloads/
https://www.elastic.co/downloads/elasticsearch
* Install attachment plugin
cd /usr/share/elasticsearch
bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/2.0.0
bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/2.5.0
* Configure elasticsearch
/etc/sysconfig/elasticsearch

View file

@ -9,7 +9,7 @@ Message-Id: <BC182994-03FA-4DC5-8202-98CBFACA0887@example.com>
To: metest@znuny.com
Mime-Version: 1.0 (Apple Message framework v1257)
=E4=F6=FC=DF ad asd
=E4=F6=FC=DF ad asd test99
-Martin

File diff suppressed because one or more lines are too long

View file

@ -121,7 +121,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
Store.add(
:object => 'Ticket::Article',
:o_id => article1.id,
:data => File.read("#{Rails.root.to_s}/test/fixtures/es-normal.txt"),
:data => File.open("#{Rails.root.to_s}/test/fixtures/es-normal.txt", 'rb') { |file| file.read },
:filename => 'es-normal.txt',
:preferences => {},
:created_by_id => 1,
@ -132,29 +132,29 @@ class ElasticsearchTest < ActiveSupport::TestCase
Store.add(
:object => 'Ticket::Article',
:o_id => article1.id,
:data => File.read("#{Rails.root.to_s}/test/fixtures/es-pdf1.pdf"),
:data => File.open("#{Rails.root.to_s}/test/fixtures/es-pdf1.pdf", 'rb') { |file| file.read },
:filename => 'es-pdf1.pdf',
:preferences => {},
:created_by_id => 1,
)
# add attachments which should get index / .box
# "Old programmers never die"
# "Old programmers never die test99"
Store.add(
:object => 'Ticket::Article',
:o_id => article1.id,
:data => File.read("#{Rails.root.to_s}/test/fixtures/es-box1.box"),
:data => File.open("#{Rails.root.to_s}/test/fixtures/es-box1.box", 'rb') { |file| file.read },
:filename => 'mail1.box',
:preferences => {},
:created_by_id => 1,
)
# add to big attachment which should not get index
# "some too big text"
# "some too big text88"
Store.add(
:object => 'Ticket::Article',
:o_id => article1.id,
:data => File.read("#{Rails.root.to_s}/test/fixtures/es-too-big.txt"),
:data => File.open("#{Rails.root.to_s}/test/fixtures/es-too-big.txt", 'rb') { |file| file.read },
:filename => 'es-too-big.txt',
:preferences => {},
:created_by_id => 1,
@ -264,14 +264,14 @@ class ElasticsearchTest < ActiveSupport::TestCase
# search for not indexed attachment
result = Ticket.search(
:current_user => agent,
:query => '"some too big text"',
:query => 'test88',
:limit => 15,
)
assert(!result[0], 'record 1')
result = Ticket.search(
:current_user => agent,
:query => '"Old programmers never die"',
:query => 'test99',
:limit => 15,
)
assert(!result[0], 'record 1')