elasticsearch-rails 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGNhMWI2MzQ0ZjU0YmVjY2Y0MTBlMDNlM2JmOWUyODUwMTQ4OGM5MQ==
4
+ NGQ1YzEyMTY2NDgyYjg1YjU3ZDFkYTZkMjIyZmVkNzdmMjBmMTgxZA==
5
5
  data.tar.gz: !binary |-
6
- ZjFmYjE4NDMyYzBhNzgxOGQzZTA2YTg5YzllNjcxODQ3YjU2YTVkYw==
6
+ ZDU0MTUzZDc1NzlhOGYyYzE3ODRlNTlkZGVlMjdkNjAyOTlhZjYzMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTM0MDA0MzNkMWZlZWNlYTczZWZiMzc5OTE4NDRiZmIzNDMzMDY3YWQ4NDAx
10
- M2U4MjEwOGJlMzUxNDFmOTQ3MzRmNmFiMzg4M2JmNTUwMWQyMTIxNDMzOWE5
11
- ZGU0Zjg4YTM3OTJiNjIwMmI3Mzc2MzVhYTIwZDEyZDg0NmZkNTM=
9
+ MWMwMjg4MGU4NWU4OWZlMTJlNjI4M2UwMTM0ZDY3NjQyNWJiNmEwMDZmOWQy
10
+ OWNmYzU2NTFhNzkyMmZhZDU1YzA3ZThlMmZmMzYzZWJlMjU1NWM5MTJkNTUx
11
+ MzU1OGExYmZjMWZjYjRhZmNjODRhOTllNjg3NzM1NWRmMjRjNjU=
12
12
  data.tar.gz: !binary |-
13
- OGQ4OGRkOTdiM2E4YzZhZmE5MTBlNTUwMTE5ZTVhNTYxMDJjMTI3NjE5MGFi
14
- MGE4NTFiYTQ4YmQ3OGQ1NGQ2Yjg5YWFlYzUwYjM2MTYyODVkNzcyNjJhYjA2
15
- N2ZmNTEzYWNhNjhkYjM0ZjllNDBlNWE4YWM0NDM2ZmY0NDdjMmI=
13
+ NzlkMjM5ZjlhMTI4YTM2OTRkOTVjN2IwZmE1MzRhNzk3OWNiZDE1NjI2NTRh
14
+ YzcyMjVkOTU5ZmI2OThlYWE4NTYzYTVmZjk2OTQxMzZiNjhiNzBiODkyM2Yy
15
+ YzMyYWU5ZjIxOWI2YjNkNTRkN2IxNTI0NDQyMGI2NmY4ZGQ5MTk=
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
- ## 0.1.3
1
+ ## 0.1.5
2
+
3
+ * Fixed an exception when no suggestions were returned in the `03-expert` example application template
2
4
 
3
5
  ## 0.1.2
4
6
 
@@ -34,14 +34,15 @@ Gem::Specification.new do |s|
34
34
 
35
35
  s.add_development_dependency "lograge"
36
36
 
37
- s.add_development_dependency "minitest", "~> 4.0"
37
+ s.add_development_dependency "minitest", "~> 4"
38
+ s.add_development_dependency "test-unit" if defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
38
39
  s.add_development_dependency "shoulda-context"
39
40
  s.add_development_dependency "mocha"
40
41
  s.add_development_dependency "turn"
41
42
  s.add_development_dependency "yard"
42
43
  s.add_development_dependency "ruby-prof"
43
44
  s.add_development_dependency "pry"
44
- s.add_development_dependency "ci_reporter"
45
+ s.add_development_dependency "ci_reporter", "~> 1.9"
45
46
 
46
47
  if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
47
48
  s.add_development_dependency "simplecov"
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module Rails
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
@@ -91,6 +91,7 @@ gsub_file "#{Rails::VERSION::STRING > '4' ? 'test/models' : 'test/unit' }/articl
91
91
  test "has a search method delegating to __elasticsearch__" do
92
92
  Article.__elasticsearch__.expects(:search).with do |definition|
93
93
  assert_equal 'foo', definition[:query][:multi_match][:query]
94
+ true
94
95
  end
95
96
 
96
97
  Article.search 'foo'
@@ -50,10 +50,13 @@
50
50
  <% if @articles.size < 1 && (suggestions = @articles.response.response['suggest']) && suggestions.present? %>
51
51
  <div class="col-md-12">
52
52
  <p class="alert alert-warning">
53
- No documents have been found. Maybe you mean
54
- <%= suggestions.map { |k,v| v.first['options'] }.flatten.map {|v| v['text']}.uniq.map do |term|
55
- link_to term, search_path(params.merge q: term)
56
- end.to_sentence(last_word_connector: ' or ').html_safe %>?
53
+ No documents have been found.
54
+ <% if suggestions['suggest_title'].present? || suggestions['suggest_body'].present? %>
55
+ Maybe you mean
56
+ <%= suggestions.map { |k,v| v.first['options'] }.flatten.map {|v| v['text']}.uniq.map do |term|
57
+ link_to term, search_path(params.merge q: term)
58
+ end.to_sentence(last_word_connector: ' or ').html_safe %>?
59
+ <% end %>
57
60
  </p>
58
61
  </div>
59
62
  <% end %>
data/test/test_helper.rb CHANGED
@@ -10,10 +10,17 @@ at_exit { Elasticsearch::Test::IntegrationTestCase.__run_at_exit_hooks }
10
10
 
11
11
  puts '-'*80
12
12
 
13
- require 'test/unit'
13
+ if defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
14
+ require 'test-unit'
15
+ require 'mocha/test_unit'
16
+ else
17
+ require 'minitest/autorun'
18
+ require 'mocha/mini_test'
19
+ end
20
+
14
21
  require 'shoulda-context'
15
- require 'mocha/setup'
16
- require 'turn' unless ENV["TM_FILEPATH"] || ENV["NOTURN"] || RUBY_1_8
22
+
23
+ require 'turn' unless ENV["TM_FILEPATH"] || ENV["NOTURN"] || defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
17
24
 
18
25
  require 'ansi'
19
26
  require 'oj'
@@ -19,10 +19,9 @@ class Elasticsearch::Rails::InstrumentationTest < Test::Unit::TestCase
19
19
  RESPONSE = { 'took' => '5ms', 'hits' => { 'total' => 123, 'max_score' => 456, 'hits' => [] } }
20
20
 
21
21
  setup do
22
- @search = Elasticsearch::Model::Searching::SearchRequest.new ::DummyInstrumentationModel, '*'
23
- @response = Elasticsearch::Model::Response::Response.new ::DummyInstrumentationModel, @search
22
+ @search = Elasticsearch::Model::Searching::SearchRequest.new ::DummyInstrumentationModel, '*'
24
23
 
25
- @client = stub('client', search: @response)
24
+ @client = stub('client', search: RESPONSE)
26
25
  DummyInstrumentationModel.stubs(:client).returns(@client)
27
26
 
28
27
  Elasticsearch::Rails::Instrumentation::Railtie.run_initializers
@@ -41,6 +40,7 @@ class Elasticsearch::Rails::InstrumentationTest < Test::Unit::TestCase
41
40
  assert_equal "search.elasticsearch", name
42
41
  assert_equal 'DummyInstrumentationModel', payload[:klass]
43
42
  assert_equal @query, payload[:search][:body]
43
+ true
44
44
  end
45
45
 
46
46
  s = ::DummyInstrumentationModel.search @query
@@ -56,6 +56,6 @@ class Elasticsearch::Rails::InstrumentationTest < Test::Unit::TestCase
56
56
  assert_not_nil logged
57
57
  assert_match /DummyInstrumentationModel Search \(\d+\.\d+ms\)/, logged
58
58
  assert_match /body\: \{query\: \{match\: \{moo\: "bam"\}\}\}\}/, logged
59
- end
59
+ end unless defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
60
60
  end
61
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-18 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: '4.0'
117
+ version: '4'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ~>
123
123
  - !ruby/object:Gem::Version
124
- version: '4.0'
124
+ version: '4'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: shoulda-context
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -210,16 +210,16 @@ dependencies:
210
210
  name: ci_reporter
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - ! '>='
213
+ - - ~>
214
214
  - !ruby/object:Gem::Version
215
- version: '0'
215
+ version: '1.9'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - ! '>='
220
+ - - ~>
221
221
  - !ruby/object:Gem::Version
222
- version: '0'
222
+ version: '1.9'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: simplecov
225
225
  requirement: !ruby/object:Gem::Requirement