Commit 572f99a7fd7ef03da1ba4b65691895f66c235381

Authored by David Silva
Committed by Macartur Sousa
1 parent b4818910
Exists in fix_sign_up_form

Elasticsearch: Test redirect to elasticsearch

plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb
@@ -18,8 +18,6 @@ class ElasticsearchPluginController < ApplicationController @@ -18,8 +18,6 @@ class ElasticsearchPluginController < ApplicationController
18 end 18 end
19 19
20 def search 20 def search
21 - puts "="*80  
22 - puts params.inspect  
23 define_searchable_types 21 define_searchable_types
24 define_search_fields_types 22 define_search_fields_types
25 23
plugins/elasticsearch/lib/elasticsearch_plugin.rb
1 class ElasticsearchPlugin < Noosfero::Plugin 1 class ElasticsearchPlugin < Noosfero::Plugin
2 2
3 - # append_view_path File.join(File.dirname(__FILE__) + '/../views/elasticsearch_plugin')  
4 -  
5 -  
6 def self.plugin_name 3 def self.plugin_name
7 "ElasticsearchPlugin" 4 "ElasticsearchPlugin"
8 end 5 end
plugins/elasticsearch/test/unit/controllers/elasticsearch_plugin_controller_test.rb
@@ -7,6 +7,12 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase @@ -7,6 +7,12 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
7 @environment.enable_plugin(ElasticsearchPlugin) 7 @environment.enable_plugin(ElasticsearchPlugin)
8 create_user('John Silva').person 8 create_user('John Silva').person
9 create_user('John Silvio').person 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 #TODO: fix this, when update or create a new person 17 #TODO: fix this, when update or create a new person
12 # the Elasticsearch::Model can update the 18 # the Elasticsearch::Model can update the
@@ -37,4 +43,20 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase @@ -37,4 +43,20 @@ class ElasticsearchPluginControllerTest &lt; ActionController::TestCase
37 assert_select ".search-item" , 1 43 assert_select ".search-item" , 1
38 end 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 end 62 end