Commit 9353f9f0e7ae42fca4843802badf9261b799c443
Committed by
Macartur Sousa
1 parent
79fc2f28
Exists in
fix_sign_up_form
Elasticsearch: tests for models indexed fields
Signed-off-by: Arthur Jahn <stutrzbecher@gmail.com> Signed-off-by: DylanGuedes <djmgguedes@gmail.com>
Showing
5 changed files
with
96 additions
and
0 deletions
Show diff stats
plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb
plugins/elasticsearch/test/unit/controllers/elasticsearch_plugin_controller_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | +require "#{File.dirname(__FILE__)}/../../test_helper" | |
| 2 | + | |
| 3 | +class ElasticsearchPluginControllerTest < ActionController::TestCase | |
| 4 | + def setup | |
| 5 | + start_cluster | |
| 6 | + end | |
| 7 | + | |
| 8 | + def teardown | |
| 9 | + stop_cluster | |
| 10 | + end | |
| 11 | + | |
| 12 | + should 'work and uses control filter variables' do | |
| 13 | + get :index | |
| 14 | + assert_response :success | |
| 15 | + assert_not_nil assigns(:searchable_types) | |
| 16 | + assert_not_nil assigns(:selected_type) | |
| 17 | + assert_not_nil assigns(:search_filter_types) | |
| 18 | + assert_not_nil assigns(:selected_filter_field) | |
| 19 | + end | |
| 20 | + | |
| 21 | + should 'return all results if selected_type is nil' do | |
| 22 | + get :index, {'selected_type' => :person, :q => 'John'} | |
| 23 | + assert_response :success | |
| 24 | + assert_tag tag: "div", attributes: { class: "results" }, | |
| 25 | + children: { count: 2 } | |
| 26 | + end | |
| 27 | + | |
| 28 | +end | ... | ... |
plugins/elasticsearch/test/unit/models/community_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | +require "#{File.dirname(__FILE__)}/../test_helper" | |
| 2 | + | |
| 3 | +class CommunityTest < ActiveSupport::TestCase | |
| 4 | + def setup | |
| 5 | + start_cluster | |
| 6 | + @environment = Environment.default | |
| 7 | + @environment.enable_plugin(ElasticsearchPlugin) | |
| 8 | + @profile = create_user('testing').person | |
| 9 | + end | |
| 10 | + | |
| 11 | + def teardown | |
| 12 | + stop_cluster | |
| 13 | + end | |
| 14 | + | |
| 15 | + should 'index custom fields for Event model' do | |
| 16 | + community_cluster = Community.__elasticsearch__.client.cluster | |
| 17 | + | |
| 18 | + assert_not_nil Community.mappings.to_hash[:community][:properties][:name] | |
| 19 | + assert_not_nil Community.mappings.to_hash[:community][:properties][:identifier] | |
| 20 | + assert_not_nil Community.mappings.to_hash[:community][:properties][:nickname] | |
| 21 | + end | |
| 22 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +require "#{File.dirname(__FILE__)}/../test_helper" | |
| 2 | + | |
| 3 | +class EventTest < ActiveSupport::TestCase | |
| 4 | + def setup | |
| 5 | + start_cluster | |
| 6 | + @environment = Environment.default | |
| 7 | + @environment.enable_plugin(ElasticsearchPlugin) | |
| 8 | + @profile = create_user('testing').person | |
| 9 | + end | |
| 10 | + | |
| 11 | + def teardown | |
| 12 | + stop_cluster | |
| 13 | + end | |
| 14 | + | |
| 15 | + should 'index custom fields for Event model' do | |
| 16 | + event_cluster = Event.__elasticsearch__.client.cluster | |
| 17 | + | |
| 18 | + assert_not_nil Event.mappings.to_hash[:event][:properties][:advertise] | |
| 19 | + assert_not_nil Event.mappings.to_hash[:event][:properties][:published] | |
| 20 | + end | |
| 21 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | +require "#{File.dirname(__FILE__)}/../test_helper" | |
| 2 | + | |
| 3 | +class PersonTest < ActiveSupport::TestCase | |
| 4 | + def setup | |
| 5 | + start_cluster | |
| 6 | + @environment = Environment.default | |
| 7 | + @environment.enable_plugin(ElasticsearchPlugin) | |
| 8 | + @profile = create_user('testing').person | |
| 9 | + end | |
| 10 | + | |
| 11 | + def teardown | |
| 12 | + stop_cluster | |
| 13 | + end | |
| 14 | + | |
| 15 | + should 'index custom fields for Event model' do | |
| 16 | + person_cluster = Person.__elasticsearch__.client.cluster | |
| 17 | + | |
| 18 | + assert_not_nil Person.mappings.to_hash[:person][:properties][:name] | |
| 19 | + assert_not_nil Person.mappings.to_hash[:person][:properties][:identifier] | |
| 20 | + assert_not_nil Person.mappings.to_hash[:person][:properties][:nickname] | |
| 21 | + assert_not_nil Person.mappings.to_hash[:person][:properties][:visible] | |
| 22 | + end | |
| 23 | + | |
| 24 | +end | ... | ... |