has_constant 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
data/has_constant.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{has_constant}
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mattbeedle"]
@@ -24,7 +24,7 @@ module HasConstant
24
24
  class_eval do
25
25
  field singular.to_sym, { :type => Integer }.merge(options)
26
26
 
27
- index singular.to_sym if options[:index]
27
+ index singular.to_sym, :background => true if options[:index]
28
28
 
29
29
  named_scope :by_constant, lambda { |constant,value| { :where =>
30
30
  { constant.to_sym => eval("#{self.to_s}.#{constant.pluralize}.index(value)") } } }
@@ -38,7 +38,13 @@ class MongoidTest < Test::Unit::TestCase
38
38
 
39
39
  should 'add index when index option is supplied' do
40
40
  MongoUserWithout.has_constant :salutations, ['Mr', 'Mrs'], :index => true
41
- assert MongoUserWithout.index_information.keys.any? { |k| k.match(/salutation/) }
41
+ MongoUserWithout.create_indexes
42
+ assert MongoUserWithout.index_information.keys.any? { |key| key.match(/salutation/) }
43
+ end
44
+
45
+ should 'not index when index option is not supplied' do
46
+ MongoUser.create_indexes
47
+ assert !MongoUser.index_information.keys.any? { |key| key.match(/salutation/) }
42
48
  end
43
49
 
44
50
  should 'save values as integers' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_constant
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 5
10
- version: 0.4.5
9
+ - 6
10
+ version: 0.4.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - mattbeedle