protobuf-activerecord 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .DS_Store
4
4
  .bundle
5
5
  .config
6
+ .rvmrc
6
7
  .yardoc
7
8
  Gemfile.lock
8
9
  coverage
@@ -22,10 +22,6 @@ module Protoable
22
22
  # end
23
23
  #
24
24
  def field_scope(field, scope_name)
25
- unless self.respond_to?(scope_name)
26
- raise Protoable::SearchScopeError, "Undefined scope :#{scope_name}. :#{scope_name} must be defined before it can be used as a field scope."
27
- end
28
-
29
25
  searchable_fields[field] = scope_name
30
26
  end
31
27
 
@@ -47,6 +43,10 @@ module Protoable
47
43
  searchable_fields.each do |field, scope_name|
48
44
  next unless proto.respond_to_and_has_and_present?(field)
49
45
 
46
+ unless self.respond_to?(scope_name)
47
+ raise Protoable::SearchScopeError, "Undefined scope :#{scope_name}."
48
+ end
49
+
50
50
  values = [ proto.__send__(field) ].flatten
51
51
  values.map!(&:to_i) if proto.get_field_by_name(field).enum?
52
52
 
@@ -1,5 +1,5 @@
1
1
  module Protobuf
2
2
  module ActiveRecord
3
- VERSION = "1.2.4"
3
+ VERSION = "1.2.5"
4
4
  end
5
5
  end
@@ -21,17 +21,20 @@ describe Protoable::Scope do
21
21
  User.search_scope(request).should eq User.by_email("foo@test.co")
22
22
  end
23
23
  end
24
- end
25
24
 
26
- describe ".field_scope" do
27
- before { @fields = User.instance_variable_get("@_searchable_fields") }
28
- after { User.instance_variable_set("@_searchable_fields", @fields) }
25
+ context "when a searchable field uses a non-existant scope" do
26
+ let(:request) { UserSearchMessage.new(:email => ["foo@test.co"]) }
29
27
 
30
- context "when given a search scope that is not defined" do
31
28
  it "raises an exception" do
32
- expect { User.field_scope :name, :foo }.to raise_exception(/Undefined scope :foo/)
29
+ User.stub(:searchable_fields).and_return({ :email => :by_hullabaloo })
30
+ expect { User.search_scope(request) }.to raise_exception(/Undefined scope :by_hullabaloo/)
33
31
  end
34
32
  end
33
+ end
34
+
35
+ describe ".field_scope" do
36
+ before { @fields = User.instance_variable_get("@_searchable_fields") }
37
+ after { User.instance_variable_set("@_searchable_fields", @fields) }
35
38
 
36
39
  it "stores the search scope in the searchable fields hash using the field as the key" do
37
40
  User.field_scope :guid, :by_guid
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-07 00:00:00.000000000 Z
12
+ date: 2013-01-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -197,7 +197,6 @@ extra_rdoc_files: []
197
197
  files:
198
198
  - .gitignore
199
199
  - .rspec
200
- - .rvmrc
201
200
  - Gemfile
202
201
  - LICENSE.txt
203
202
  - README.md
@@ -240,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
239
  version: '0'
241
240
  segments:
242
241
  - 0
243
- hash: 811709440297212247
242
+ hash: 262184748097554895
244
243
  required_rubygems_version: !ruby/object:Gem::Requirement
245
244
  none: false
246
245
  requirements:
@@ -249,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
248
  version: '0'
250
249
  segments:
251
250
  - 0
252
- hash: 811709440297212247
251
+ hash: 262184748097554895
253
252
  requirements: []
254
253
  rubyforge_project:
255
254
  rubygems_version: 1.8.24
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 1.9.3@protobuf-activerecord --create