cirandas.net

ref: master

plugins/elasticsearch/test/test_helper.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'test_helper'
require_relative '../../../test/api/test_helper.rb'

module ElasticsearchTestHelper

  def setup
    setup_environment
    create_instances
    import_instancies
  end

  def create_instances
  end

  def teardown
  end

  def import_instancies
    indexed_models.each {|model|
      model.__elasticsearch__.create_index! force: true
      model.import
    }
    sleep 3
  end

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

  def indexed_models
    []
  end

  def indexed_fields model
    model.mappings.to_hash[model.name.underscore.to_sym][:properties]
  end

end