elasticsearch_plugin_controller_test.rb
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require "#{File.dirname(__FILE__)}/../../test_helper"
class ElasticsearchPluginControllerTest < ActionController::TestCase
def setup
@environment = Environment.default
@environment.enable_plugin(ElasticsearchPlugin)
create_user('John Silva').person
create_user('John Silvio').person
#TODO: fix this, when update or create a new person
# the Elasticsearch::Model can update the
# indexes models
Person.import
sleep 1
end
should 'work and uses control filter variables' do
get :index
assert_response :success
assert_not_nil assigns(:searchable_types)
assert_not_nil assigns(:selected_type)
assert_not_nil assigns(:search_filter_types)
assert_not_nil assigns(:selected_filter_field)
end
should 'return all results if selected_type is nil' do
get :index, {'selected_type' => :person, :query => 'John'}
assert_response :success
assert_select ".search-item" , 2
end
should 'render index' do
get :index, {'selected_type' => :person, :query => 'Silva'}
assert_response :success
assert_select ".search-item" , 1
end
end