has_constant 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.6
1
+ 0.4.7
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.6"
8
+ s.version = "0.4.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mattbeedle"]
@@ -16,7 +16,7 @@ module HasConstant
16
16
  end
17
17
 
18
18
  module ClassMethods
19
- def has_constant( name, values, options = {} )
19
+ def has_constant( name, values = lambda { I18n.t(name) }, options = {} )
20
20
  super(name, values, options)
21
21
 
22
22
  singular = (options[:accessor] || name.to_s.singularize).to_s
@@ -36,6 +36,12 @@ class MongoidTest < Test::Unit::TestCase
36
36
  assert MongoUserWithout.fields.map(&:first).include?('sal')
37
37
  end
38
38
 
39
+ should 'default values to translated values list' do
40
+ I18n.stubs(:t).returns(['a', 'b'])
41
+ MongoUserWithout.has_constant :titles
42
+ assert_equal ['a', 'b'], MongoUserWithout.titles
43
+ end
44
+
39
45
  should 'add index when index option is supplied' do
40
46
  MongoUserWithout.has_constant :salutations, ['Mr', 'Mrs'], :index => true
41
47
  MongoUserWithout.create_indexes
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: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 6
10
- version: 0.4.6
9
+ - 7
10
+ version: 0.4.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - mattbeedle