From ce12728fe5128c8928d2fcf097a86a0fde7c6948 Mon Sep 17 00:00:00 2001 From: Macartur Sousa Date: Mon, 13 Jun 2016 15:18:30 -0300 Subject: [PATCH] Elasticsearch: Removed cluster from tests --- plugins/elasticsearch/test/test_helper.rb | 19 ------------------- plugins/elasticsearch/test/unit/controllers/elasticsearch_plugin_controller_test.rb | 28 ++++++++++++++++++++-------- plugins/elasticsearch/test/unit/elasticsearch_test.rb | 7 +------ plugins/elasticsearch/test/unit/models/community_test.rb | 7 +------ plugins/elasticsearch/test/unit/models/event_test.rb | 7 +------ plugins/elasticsearch/test/unit/models/person_test.rb | 7 +------ 6 files changed, 24 insertions(+), 51 deletions(-) diff --git a/plugins/elasticsearch/test/test_helper.rb b/plugins/elasticsearch/test/test_helper.rb index 9cfe880..1d8d247 100644 --- a/plugins/elasticsearch/test/test_helper.rb +++ b/plugins/elasticsearch/test/test_helper.rb @@ -1,20 +1 @@ require 'test_helper' - - -require 'elasticsearch/extensions/test/cluster' -require 'elasticsearch/extensions/test/cluster/tasks' - - -def start_cluster - if not Elasticsearch::Extensions::Test::Cluster.running?(on: 9250) - Elasticsearch::Extensions::Test::Cluster.start - end -end - -def stop_cluster - if Elasticsearch::Extensions::Test::Cluster.running?(on: 9250) - Elasticsearch::Extensions::Test::Cluster.stop - end -end - - diff --git a/plugins/elasticsearch/test/unit/controllers/elasticsearch_plugin_controller_test.rb b/plugins/elasticsearch/test/unit/controllers/elasticsearch_plugin_controller_test.rb index e7b6246..708572d 100644 --- a/plugins/elasticsearch/test/unit/controllers/elasticsearch_plugin_controller_test.rb +++ b/plugins/elasticsearch/test/unit/controllers/elasticsearch_plugin_controller_test.rb @@ -1,16 +1,23 @@ require "#{File.dirname(__FILE__)}/../../test_helper" class ElasticsearchPluginControllerTest < ActionController::TestCase + def setup - start_cluster - end + @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 - def teardown - stop_cluster end should 'work and uses control filter variables' do - get :index + get :index assert_response :success assert_not_nil assigns(:searchable_types) assert_not_nil assigns(:selected_type) @@ -19,10 +26,15 @@ class ElasticsearchPluginControllerTest < ActionController::TestCase end should 'return all results if selected_type is nil' do - get :index, {'selected_type' => :person, :q => 'John'} + 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_tag tag: "div", attributes: { class: "results" }, - children: { count: 2 } + assert_select ".search-item" , 1 end end diff --git a/plugins/elasticsearch/test/unit/elasticsearch_test.rb b/plugins/elasticsearch/test/unit/elasticsearch_test.rb index 3799580..8482093 100644 --- a/plugins/elasticsearch/test/unit/elasticsearch_test.rb +++ b/plugins/elasticsearch/test/unit/elasticsearch_test.rb @@ -2,18 +2,13 @@ require "#{File.dirname(__FILE__)}/../test_helper" class ElasticsearchTest < ActiveSupport::TestCase def setup - start_cluster @environment = Environment.default @environment.enable_plugin(ElasticsearchPlugin) @profile = create_user('testing').person end - def teardown - stop_cluster - end - - should ' be return yellow for health status' do + should 'be return yellow for health status' do cluster = Elasticsearch::Model.client.cluster assert_equal 'yellow', cluster.health["status"] end diff --git a/plugins/elasticsearch/test/unit/models/community_test.rb b/plugins/elasticsearch/test/unit/models/community_test.rb index b068a67..c959832 100644 --- a/plugins/elasticsearch/test/unit/models/community_test.rb +++ b/plugins/elasticsearch/test/unit/models/community_test.rb @@ -1,17 +1,12 @@ -require "#{File.dirname(__FILE__)}/../test_helper" +require "#{File.dirname(__FILE__)}/../../test_helper" class CommunityTest < ActiveSupport::TestCase def setup - start_cluster @environment = Environment.default @environment.enable_plugin(ElasticsearchPlugin) @profile = create_user('testing').person end - def teardown - stop_cluster - end - should 'index custom fields for Event model' do community_cluster = Community.__elasticsearch__.client.cluster diff --git a/plugins/elasticsearch/test/unit/models/event_test.rb b/plugins/elasticsearch/test/unit/models/event_test.rb index 3bc1498..7b095c3 100644 --- a/plugins/elasticsearch/test/unit/models/event_test.rb +++ b/plugins/elasticsearch/test/unit/models/event_test.rb @@ -1,17 +1,12 @@ -require "#{File.dirname(__FILE__)}/../test_helper" +require "#{File.dirname(__FILE__)}/../../test_helper" class EventTest < ActiveSupport::TestCase def setup - start_cluster @environment = Environment.default @environment.enable_plugin(ElasticsearchPlugin) @profile = create_user('testing').person end - def teardown - stop_cluster - end - should 'index custom fields for Event model' do event_cluster = Event.__elasticsearch__.client.cluster diff --git a/plugins/elasticsearch/test/unit/models/person_test.rb b/plugins/elasticsearch/test/unit/models/person_test.rb index 09e616d..e716032 100644 --- a/plugins/elasticsearch/test/unit/models/person_test.rb +++ b/plugins/elasticsearch/test/unit/models/person_test.rb @@ -1,17 +1,12 @@ -require "#{File.dirname(__FILE__)}/../test_helper" +require "#{File.dirname(__FILE__)}/../../test_helper" class PersonTest < ActiveSupport::TestCase def setup - start_cluster @environment = Environment.default @environment.enable_plugin(ElasticsearchPlugin) @profile = create_user('testing').person end - def teardown - stop_cluster - end - should 'index custom fields for Event model' do person_cluster = Person.__elasticsearch__.client.cluster -- libgit2 0.21.2