Commit ce12728fe5128c8928d2fcf097a86a0fde7c6948
1 parent
72f0eaa0
Exists in
fix_sign_up_form
Elasticsearch: Removed cluster from tests
Signed-off-by: Dylan Guedes <djmgguedes@gmail.com> Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Showing
6 changed files
with
24 additions
and
51 deletions
Show diff stats
plugins/elasticsearch/test/test_helper.rb
1 | require 'test_helper' | 1 | require 'test_helper' |
2 | - | ||
3 | - | ||
4 | -require 'elasticsearch/extensions/test/cluster' | ||
5 | -require 'elasticsearch/extensions/test/cluster/tasks' | ||
6 | - | ||
7 | - | ||
8 | -def start_cluster | ||
9 | - if not Elasticsearch::Extensions::Test::Cluster.running?(on: 9250) | ||
10 | - Elasticsearch::Extensions::Test::Cluster.start | ||
11 | - end | ||
12 | -end | ||
13 | - | ||
14 | -def stop_cluster | ||
15 | - if Elasticsearch::Extensions::Test::Cluster.running?(on: 9250) | ||
16 | - Elasticsearch::Extensions::Test::Cluster.stop | ||
17 | - end | ||
18 | -end | ||
19 | - | ||
20 | - |
plugins/elasticsearch/test/unit/controllers/elasticsearch_plugin_controller_test.rb
1 | require "#{File.dirname(__FILE__)}/../../test_helper" | 1 | require "#{File.dirname(__FILE__)}/../../test_helper" |
2 | 2 | ||
3 | class ElasticsearchPluginControllerTest < ActionController::TestCase | 3 | class ElasticsearchPluginControllerTest < ActionController::TestCase |
4 | + | ||
4 | def setup | 5 | def setup |
5 | - start_cluster | ||
6 | - end | 6 | + @environment = Environment.default |
7 | + @environment.enable_plugin(ElasticsearchPlugin) | ||
8 | + create_user('John Silva').person | ||
9 | + create_user('John Silvio').person | ||
10 | + | ||
11 | + #TODO: fix this, when update or create a new person | ||
12 | + # the Elasticsearch::Model can update the | ||
13 | + # indexes models | ||
14 | + Person.import | ||
15 | + sleep 1 | ||
7 | 16 | ||
8 | - def teardown | ||
9 | - stop_cluster | ||
10 | end | 17 | end |
11 | 18 | ||
12 | should 'work and uses control filter variables' do | 19 | should 'work and uses control filter variables' do |
13 | - get :index | 20 | + get :index |
14 | assert_response :success | 21 | assert_response :success |
15 | assert_not_nil assigns(:searchable_types) | 22 | assert_not_nil assigns(:searchable_types) |
16 | assert_not_nil assigns(:selected_type) | 23 | assert_not_nil assigns(:selected_type) |
@@ -19,10 +26,15 @@ class ElasticsearchPluginControllerTest < ActionController::TestCase | @@ -19,10 +26,15 @@ class ElasticsearchPluginControllerTest < ActionController::TestCase | ||
19 | end | 26 | end |
20 | 27 | ||
21 | should 'return all results if selected_type is nil' do | 28 | should 'return all results if selected_type is nil' do |
22 | - get :index, {'selected_type' => :person, :q => 'John'} | 29 | + get :index, {'selected_type' => :person, :query => 'John'} |
30 | + assert_response :success | ||
31 | + assert_select ".search-item" , 2 | ||
32 | + end | ||
33 | + | ||
34 | + should 'render index' do | ||
35 | + get :index, {'selected_type' => :person, :query => 'Silva'} | ||
23 | assert_response :success | 36 | assert_response :success |
24 | - assert_tag tag: "div", attributes: { class: "results" }, | ||
25 | - children: { count: 2 } | 37 | + assert_select ".search-item" , 1 |
26 | end | 38 | end |
27 | 39 | ||
28 | end | 40 | end |
plugins/elasticsearch/test/unit/elasticsearch_test.rb
@@ -2,18 +2,13 @@ require "#{File.dirname(__FILE__)}/../test_helper" | @@ -2,18 +2,13 @@ require "#{File.dirname(__FILE__)}/../test_helper" | ||
2 | 2 | ||
3 | class ElasticsearchTest < ActiveSupport::TestCase | 3 | class ElasticsearchTest < ActiveSupport::TestCase |
4 | def setup | 4 | def setup |
5 | - start_cluster | ||
6 | @environment = Environment.default | 5 | @environment = Environment.default |
7 | @environment.enable_plugin(ElasticsearchPlugin) | 6 | @environment.enable_plugin(ElasticsearchPlugin) |
8 | @profile = create_user('testing').person | 7 | @profile = create_user('testing').person |
9 | end | 8 | end |
10 | 9 | ||
11 | - def teardown | ||
12 | - stop_cluster | ||
13 | - end | ||
14 | - | ||
15 | 10 | ||
16 | - should ' be return yellow for health status' do | 11 | + should 'be return yellow for health status' do |
17 | cluster = Elasticsearch::Model.client.cluster | 12 | cluster = Elasticsearch::Model.client.cluster |
18 | assert_equal 'yellow', cluster.health["status"] | 13 | assert_equal 'yellow', cluster.health["status"] |
19 | end | 14 | end |
plugins/elasticsearch/test/unit/models/community_test.rb
1 | -require "#{File.dirname(__FILE__)}/../test_helper" | 1 | +require "#{File.dirname(__FILE__)}/../../test_helper" |
2 | 2 | ||
3 | class CommunityTest < ActiveSupport::TestCase | 3 | class CommunityTest < ActiveSupport::TestCase |
4 | def setup | 4 | def setup |
5 | - start_cluster | ||
6 | @environment = Environment.default | 5 | @environment = Environment.default |
7 | @environment.enable_plugin(ElasticsearchPlugin) | 6 | @environment.enable_plugin(ElasticsearchPlugin) |
8 | @profile = create_user('testing').person | 7 | @profile = create_user('testing').person |
9 | end | 8 | end |
10 | 9 | ||
11 | - def teardown | ||
12 | - stop_cluster | ||
13 | - end | ||
14 | - | ||
15 | should 'index custom fields for Event model' do | 10 | should 'index custom fields for Event model' do |
16 | community_cluster = Community.__elasticsearch__.client.cluster | 11 | community_cluster = Community.__elasticsearch__.client.cluster |
17 | 12 |
plugins/elasticsearch/test/unit/models/event_test.rb
1 | -require "#{File.dirname(__FILE__)}/../test_helper" | 1 | +require "#{File.dirname(__FILE__)}/../../test_helper" |
2 | 2 | ||
3 | class EventTest < ActiveSupport::TestCase | 3 | class EventTest < ActiveSupport::TestCase |
4 | def setup | 4 | def setup |
5 | - start_cluster | ||
6 | @environment = Environment.default | 5 | @environment = Environment.default |
7 | @environment.enable_plugin(ElasticsearchPlugin) | 6 | @environment.enable_plugin(ElasticsearchPlugin) |
8 | @profile = create_user('testing').person | 7 | @profile = create_user('testing').person |
9 | end | 8 | end |
10 | 9 | ||
11 | - def teardown | ||
12 | - stop_cluster | ||
13 | - end | ||
14 | - | ||
15 | should 'index custom fields for Event model' do | 10 | should 'index custom fields for Event model' do |
16 | event_cluster = Event.__elasticsearch__.client.cluster | 11 | event_cluster = Event.__elasticsearch__.client.cluster |
17 | 12 |
plugins/elasticsearch/test/unit/models/person_test.rb
1 | -require "#{File.dirname(__FILE__)}/../test_helper" | 1 | +require "#{File.dirname(__FILE__)}/../../test_helper" |
2 | 2 | ||
3 | class PersonTest < ActiveSupport::TestCase | 3 | class PersonTest < ActiveSupport::TestCase |
4 | def setup | 4 | def setup |
5 | - start_cluster | ||
6 | @environment = Environment.default | 5 | @environment = Environment.default |
7 | @environment.enable_plugin(ElasticsearchPlugin) | 6 | @environment.enable_plugin(ElasticsearchPlugin) |
8 | @profile = create_user('testing').person | 7 | @profile = create_user('testing').person |
9 | end | 8 | end |
10 | 9 | ||
11 | - def teardown | ||
12 | - stop_cluster | ||
13 | - end | ||
14 | - | ||
15 | should 'index custom fields for Event model' do | 10 | should 'index custom fields for Event model' do |
16 | person_cluster = Person.__elasticsearch__.client.cluster | 11 | person_cluster = Person.__elasticsearch__.client.cluster |
17 | 12 |