Commit 84db6592a96559c231fee1a3bf81ff4c2dbb7e09
Committed by
Macartur Sousa
1 parent
ab552d41
Exists in
elasticsearch_categories
Adds categories tests for the api
Signed-off-by: DylanGuedes <djmgguedes@gmail.com>
Showing
1 changed file
with
13 additions
and
1 deletions
Show diff stats
plugins/elasticsearch/test/api/elasticsearch_plugin_api_test.rb
@@ -57,8 +57,13 @@ class ElasticsearchPluginApiTest < ActiveSupport::TestCase | @@ -57,8 +57,13 @@ class ElasticsearchPluginApiTest < ActiveSupport::TestCase | ||
57 | end | 57 | end |
58 | 58 | ||
59 | def create_instances | 59 | def create_instances |
60 | + 5.times.each {|index| fast_create Category, name: "category#{index}", id: index+1 } | ||
60 | 7.times.each {|index| create_user "person #{index}"} | 61 | 7.times.each {|index| create_user "person #{index}"} |
61 | - 4.times.each {|index| fast_create Community, name: "community #{index}" } | 62 | + 4.times.each do |index| |
63 | + community = fast_create Community, name: "community #{index}" | ||
64 | + community.categories.push Category.find(index+1) | ||
65 | + community.save | ||
66 | + end | ||
62 | end | 67 | end |
63 | 68 | ||
64 | should 'show all types avaliable in /search/types endpoint' do | 69 | should 'show all types avaliable in /search/types endpoint' do |
@@ -110,4 +115,11 @@ class ElasticsearchPluginApiTest < ActiveSupport::TestCase | @@ -110,4 +115,11 @@ class ElasticsearchPluginApiTest < ActiveSupport::TestCase | ||
110 | assert_equal 7, json["results"].count | 115 | assert_equal 7, json["results"].count |
111 | end | 116 | end |
112 | 117 | ||
118 | + should 'respond with only the correct categories' do | ||
119 | + get "/api/v1/search?categories=1,2,3" | ||
120 | + json = JSON.parse(last_response.body) | ||
121 | + assert_equal 200, last_response.status | ||
122 | + assert_equal 3, json["results"].count | ||
123 | + end | ||
124 | + | ||
113 | end | 125 | end |