Commit c9ef2a433668c03008663284ba5805b08a3509c4

Authored by Dylan Guedes
1 parent 5c3c9f74
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
... ... @@ -24,11 +24,18 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
24 24 end
25 25  
26 26 def create_visible_models
  27 + categories = []
27 28 5.times do | index |
  29 + categories[index] = fast_create Category, name: "Category#{index}", id: index+1
28 30 create_user "person #{index}"
29 31 end
  32 +
30 33 6.times do | index |
31   - fast_create Community, name: "community #{index}", created_at: Date.new
  34 + community = fast_create Community, name: "community #{index}", created_at: Date.new
  35 + if categories[index]
  36 + community.categories.push categories[index]
  37 + community.save
  38 + end
32 39 end
33 40 end
34 41  
... ... @@ -45,7 +52,6 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
45 52 create_private_article(TextArticle,public_person: User.first.person, private_person: invisible_user.person)
46 53 create_private_article(UploadedFile,public_person: User.first.person, private_person: invisible_user.person)
47 54 create_private_article(Event,public_person: User.first.person, private_person: invisible_user.person)
48   -
49 55 end
50 56  
51 57 def create_private_article model,options = {}
... ... @@ -142,7 +148,6 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
142 148 assert_redirected_to controller: 'elasticsearch_plugin', action: 'search', params: params
143 149 end
144 150  
145   -
146 151 should 'filter community by default environment' do
147 152 get :index, { "selected_type" => :community}
148 153 assert_response :success
... ... @@ -173,4 +178,13 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
173 178 assert_select ".search-item", 0
174 179 end
175 180  
  181 + should 'filter by selected categories' do
  182 + get :index, { "categories" => "1,2,3" }
  183 + assert_response :success
  184 + assert_select ".search-item", 3
  185 + get :index, { "categories" => "5" }
  186 + assert_response :success
  187 + assert_select ".search-item", 1
  188 + end
  189 +
176 190 end
... ...