Commit cd103fdc63a0b66ba029c83b87e13f2ce823e0cf

Authored by Dylan Guedes
1 parent 37845587
Exists in error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0 and in 42 other branches error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0

Adds tests for the category filter

Signed-off-by: DylanGuedes <djmgguedes@gmail.com>
Signed-off-by: Macartur de Sousa <macartur.sc@gmail.com>
plugins/elasticsearch/test/functional/elasticsearch_plugin_controller_test.rb
... ... @@ -23,6 +23,7 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
23 23 end
24 24  
25 25 def create_instances_environment
  26 + create_categories
26 27 create_people
27 28 create_communities
28 29 end
... ... @@ -34,8 +35,19 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
34 35 end
35 36  
36 37 def create_communities
  38 + categories = [Category.find(1), Category.find(2), Category.find(3), Category.find(4), Category.find(5)]
37 39 6.times do | index |
38   - fast_create Community, name: "community #{index}", created_at: Date.new
  40 + community = fast_create Community, name: "community #{index}", created_at: Date.new
  41 + if categories[index]
  42 + community.categories.push categories[index]
  43 + community.save
  44 + end
  45 + end
  46 + end
  47 +
  48 + def create_categories
  49 + 5.times do | index |
  50 + fast_create Category, name: "category#{index}", id: index+1
39 51 end
40 52 end
41 53  
... ... @@ -140,4 +152,13 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
140 152 assert_select ".search-item", 5
141 153 end
142 154  
  155 + should 'filter by selected categories' do
  156 + get :index, { "categories" => "1,2,3" }
  157 + assert_response :success
  158 + assert_select ".search-item", 3
  159 + get :index, { "categories" => "5" }
  160 + assert_response :success
  161 + assert_select ".search-item", 1
  162 + end
  163 +
143 164 end
... ...