Extended test.
This commit is contained in:
parent
3681c8d7f0
commit
c1d2eca4a5
1 changed files with 25 additions and 10 deletions
|
@ -1,16 +1,18 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
require 'integration_test_helper'
|
require 'integration_test_helper'
|
||||||
|
|
||||||
class ElasticSearchTest < ActiveSupport::TestCase
|
class ElasticsearchTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
Setting.set('es_url', 'http://172.0.0.1:9200')
|
#Setting.set('es_url', 'http://172.0.0.1:9200')
|
||||||
|
Setting.set('es_url', 'http://10.240.2.11:9200')
|
||||||
Setting.set('es_index', 'estest.local_zammad')
|
Setting.set('es_index', 'estest.local_zammad')
|
||||||
#Setting.set('es_user', 'elasticsearch')
|
#Setting.set('es_user', 'elasticsearch')
|
||||||
#Setting.set('es_password', 'zammad')
|
#Setting.set('es_password', 'zammad')
|
||||||
|
|
||||||
# drop/create indexes
|
# drop/create indexes
|
||||||
Rake::Task["searchindex:drop"].execute
|
#Rake::Task["searchindex:drop"].execute
|
||||||
Rake::Task["searchindex:create"].execute
|
#Rake::Task["searchindex:create"].execute
|
||||||
|
system('rake searchindex:rebuild')
|
||||||
|
|
||||||
groups = Group.where( :name => 'Users' )
|
groups = Group.where( :name => 'Users' )
|
||||||
roles = Role.where( :name => 'Agent' )
|
roles = Role.where( :name => 'Agent' )
|
||||||
|
@ -74,7 +76,7 @@ class ElasticSearchTest < ActiveSupport::TestCase
|
||||||
:ticket_id => ticket2.id,
|
:ticket_id => ticket2.id,
|
||||||
:from => 'some_sender@example.org',
|
:from => 'some_sender@example.org',
|
||||||
:to => 'some_recipient@example.org',
|
:to => 'some_recipient@example.org',
|
||||||
:subject => 'some subject2',
|
:subject => 'some subject2 / autobahn what else?',
|
||||||
:message_id => 'some@id',
|
:message_id => 'some@id',
|
||||||
:body => 'some other message',
|
:body => 'some other message',
|
||||||
:internal => false,
|
:internal => false,
|
||||||
|
@ -87,7 +89,7 @@ class ElasticSearchTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
ticket3 = Ticket.create(
|
ticket3 = Ticket.create(
|
||||||
:title => "something else",
|
:title => "something else",
|
||||||
:group => Group.lookup( :name => 'Users'),
|
:group => Group.lookup( :name => 'WithoutAccess'),
|
||||||
:customer_id => 2,
|
:customer_id => 2,
|
||||||
:state => Ticket::State.lookup( :name => 'open' ),
|
:state => Ticket::State.lookup( :name => 'open' ),
|
||||||
:priority => Ticket::Priority.lookup( :name => '2 normal' ),
|
:priority => Ticket::Priority.lookup( :name => '2 normal' ),
|
||||||
|
@ -100,7 +102,7 @@ class ElasticSearchTest < ActiveSupport::TestCase
|
||||||
:to => 'some_recipient@example.org',
|
:to => 'some_recipient@example.org',
|
||||||
:subject => 'some subject3',
|
:subject => 'some subject3',
|
||||||
:message_id => 'some@id',
|
:message_id => 'some@id',
|
||||||
:body => 'some other message 3',
|
:body => 'some other message 3 / kindergarden what else?',
|
||||||
:internal => false,
|
:internal => false,
|
||||||
:sender => Ticket::Article::Sender.where(:name => 'Customer').first,
|
:sender => Ticket::Article::Sender.where(:name => 'Customer').first,
|
||||||
:type => Ticket::Article::Type.where(:name => 'email').first,
|
:type => Ticket::Article::Type.where(:name => 'email').first,
|
||||||
|
@ -112,11 +114,24 @@ class ElasticSearchTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
result = Ticket.search(
|
result = Ticket.search(
|
||||||
:current_user => agent,
|
:current_user => agent,
|
||||||
:query => 'subject2',
|
:query => 'autobahn',
|
||||||
:limit => 15,
|
:limit => 15,
|
||||||
)
|
)
|
||||||
puts "RRR #{result.inspect}"
|
|
||||||
assert_equal( 24, Group.count, 'groups' )
|
assert(!result.empty?, 'result exists')
|
||||||
|
assert(result[0], 'record 1')
|
||||||
|
assert(!result[1], 'record 2')
|
||||||
|
assert_equal(result[0].id, ticket2.id)
|
||||||
|
|
||||||
|
|
||||||
|
result = Ticket.search(
|
||||||
|
:current_user => agent,
|
||||||
|
:query => 'kindergarden',
|
||||||
|
:limit => 15,
|
||||||
|
)
|
||||||
|
assert(result.empty?, 'result should be empty')
|
||||||
|
assert(!result[0], 'record 1')
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue