Blame view

plugins/elasticsearch/test/test_helper.rb 665 Bytes
de641fe3   Macartur Sousa   Elasticsearch: Ad...
1
require 'test_helper'
220a5f3e   Macartur Sousa   Elasticsearch: Re...
2
require_relative '../../../test/api/test_helper.rb'
4ae80bab   Macartur Sousa   Elasticsearch: Ad...
3

220a5f3e   Macartur Sousa   Elasticsearch: Re...
4
module ElasticsearchTestHelper
4ae80bab   Macartur Sousa   Elasticsearch: Ad...
5
6
7

  def setup
    setup_environment
220a5f3e   Macartur Sousa   Elasticsearch: Re...
8
    create_instances
4ae80bab   Macartur Sousa   Elasticsearch: Ad...
9
10
11
    import_instancies
  end

220a5f3e   Macartur Sousa   Elasticsearch: Re...
12
13
14
  def create_instances
  end

4ae80bab   Macartur Sousa   Elasticsearch: Ad...
15
  def teardown
4ae80bab   Macartur Sousa   Elasticsearch: Ad...
16
17
18
19
  end

  def import_instancies
    indexed_models.each {|model|
b101aa2a   Macartur Sousa   Elasticsearch: Fi...
20
      model.__elasticsearch__.create_index! force: true
4ae80bab   Macartur Sousa   Elasticsearch: Ad...
21
      model.import
4ae80bab   Macartur Sousa   Elasticsearch: Ad...
22
    }
625d8f63   Macartur Sousa   Elasticsearch: Fi...
23
    sleep 2
4ae80bab   Macartur Sousa   Elasticsearch: Ad...
24
25
26
27
28
29
30
31
32
33
34
35
  end

  def setup_environment
    @environment = Environment.default
    @environment.enable_plugin(ElasticsearchPlugin)
  end

  def indexed_models
    []
  end

  def indexed_fields model
220a5f3e   Macartur Sousa   Elasticsearch: Re...
36
    model.mappings.to_hash[model.name.underscore.to_sym][:properties]
4ae80bab   Macartur Sousa   Elasticsearch: Ad...
37
38
39
  end

end