Commit e1b76e5abe7ef6bf63d421864d5737f822f787b8

Authored by David Silva
1 parent 9d335fbd
Exists in elasticsearch_api

Test redirect for elasticsearch plugin.

  - Related with #322
plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb
... ... @@ -18,8 +18,6 @@ class ElasticsearchPluginController < ApplicationController
18 18 end
19 19  
20 20 def search
21   - puts "="*80
22   - puts params.inspect
23 21 define_searchable_types
24 22 define_search_fields_types
25 23  
... ...
plugins/elasticsearch/lib/elasticsearch_plugin.rb
1 1 class ElasticsearchPlugin < Noosfero::Plugin
2 2  
3   - # append_view_path File.join(File.dirname(__FILE__) + '/../views/elasticsearch_plugin')
4   -
5   -
6 3 def self.plugin_name
7 4 "ElasticsearchPlugin"
8 5 end
... ...
plugins/elasticsearch/test/unit/controllers/elasticsearch_plugin_controller_test.rb
... ... @@ -7,6 +7,12 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
7 7 @environment.enable_plugin(ElasticsearchPlugin)
8 8 create_user('John Silva').person
9 9 create_user('John Silvio').person
  10 + community = fast_create(Community)
  11 + community.name = "I like organic"
  12 + community.created_at = Time.now
  13 + community.save
  14 + Community.import
  15 + sleep 1
10 16  
11 17 #TODO: fix this, when update or create a new person
12 18 # the Elasticsearch::Model can update the
... ... @@ -37,4 +43,20 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
37 43 assert_select ".search-item" , 1
38 44 end
39 45  
  46 + should 'redirect to elasticsearch plugin when request are send to core' do
  47 + oldcontroller = @controller
  48 + @controller = SearchController.new
  49 + get 'index'
  50 + params = {}
  51 + params[:action] = 'index'
  52 + params[:controller] = 'search'
  53 + assert_redirected_to controller: 'elasticsearch_plugin', action: 'search', params: params
  54 + @controller = oldcontroller
  55 + end
  56 +
  57 + should 'pass params to elastic search controller' do
  58 + get 'index', { query: 'like' }
  59 + assert_not_nil assigns(:results)
  60 + assert_template partial: '_community_display'
  61 + end
40 62 end
... ...