elastic_record 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'elastic_record'
5
- s.version = '0.10.1'
5
+ s.version = '0.10.2'
6
6
  s.summary = 'Use Elastic Search with your objects'
7
7
  s.description = 'Find your records with elastic search'
8
8
 
@@ -2,7 +2,7 @@ module ElasticRecord
2
2
  class Relation
3
3
  module FinderMethods
4
4
  def find(id)
5
- filter(arelastic.filter.ids(id)).to_a.first
5
+ filter(arelastic.filter.ids(id)).to_a.first || (raise ActiveRecord::RecordNotFound)
6
6
  end
7
7
 
8
8
  def first
@@ -19,9 +19,9 @@ module ElasticRecord
19
19
 
20
20
  private
21
21
 
22
- def find_one(relation)
23
- relation.limit(1).to_a.first
24
- end
22
+ def find_one(relation)
23
+ relation.limit(1).to_a.first
24
+ end
25
25
  end
26
26
  end
27
27
  end
@@ -1,5 +1,10 @@
1
1
  require 'helper'
2
2
 
3
+ module ActiveRecord
4
+ class RecordNotFound < StandardError
5
+ end
6
+ end
7
+
3
8
  class ElasticRecord::Relation::FinderMethodsTest < MiniTest::Spec
4
9
  def setup
5
10
  super
@@ -9,7 +14,10 @@ class ElasticRecord::Relation::FinderMethodsTest < MiniTest::Spec
9
14
  def test_find
10
15
  refute_nil Widget.elastic_relation.find('05')
11
16
  refute_nil Widget.elastic_relation.filter('color' => 'red').find('05')
12
- assert_nil Widget.elastic_relation.filter('color' => 'blue').find('05')
17
+
18
+ assert_raises ActiveRecord::RecordNotFound do
19
+ Widget.elastic_relation.filter('color' => 'blue').find('05')
20
+ end
13
21
  end
14
22
 
15
23
  def test_first
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,40 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-26 00:00:00.000000000 Z
12
+ date: 2012-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arelastic
16
+ prerelease: false
16
17
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
+ none: false
22
23
  type: :runtime
23
- prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
25
  requirements:
27
26
  - - ! '>='
28
27
  - !ruby/object:Gem::Version
29
28
  version: '0'
29
+ none: false
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: activemodel
32
+ prerelease: false
32
33
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
+ none: false
38
39
  type: :runtime
39
- prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
41
  requirements:
43
42
  - - ! '>='
44
43
  - !ruby/object:Gem::Version
45
44
  version: '0'
45
+ none: false
46
46
  description: Find your records with elastic search
47
47
  email: developer@matthewhiggins.com
48
48
  executables: []
@@ -126,17 +126,17 @@ rdoc_options: []
126
126
  require_paths:
127
127
  - lib
128
128
  required_ruby_version: !ruby/object:Gem::Requirement
129
- none: false
130
129
  requirements:
131
130
  - - ! '>='
132
131
  - !ruby/object:Gem::Version
133
132
  version: 1.9.3
134
- required_rubygems_version: !ruby/object:Gem::Requirement
135
133
  none: false
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
135
  requirements:
137
136
  - - ! '>='
138
137
  - !ruby/object:Gem::Version
139
138
  version: 1.8.11
139
+ none: false
140
140
  requirements: []
141
141
  rubyforge_project:
142
142
  rubygems_version: 1.8.24