simple_enum 1.6.3 → 1.6.4

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_enum (1.6.3)
4
+ simple_enum (1.6.4)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
data/Rakefile CHANGED
@@ -31,6 +31,7 @@ task :test => [:'test:activerecord', :'test:mongoid']
31
31
 
32
32
  # Mongodb
33
33
  directory "tmp/mongodb.data"
34
+ desc 'Run mongodb in tmp/'
34
35
  task :mongodb => [:'tmp/mongodb.data'] do |t|
35
36
  system "mongod", "--dbpath", "tmp/mongodb.data"
36
37
  end
@@ -36,7 +36,7 @@ module SimpleEnum
36
36
  # Wrap method chain to create mongoid field and additional
37
37
  # column options
38
38
  def as_enum_with_mongoid(enum_cd, values, options = {})
39
- options = SimpleEnum.default_options.merge({ :column => "#{enum_cd}_cd" }).merge(options)
39
+ options = SimpleEnum.default_options.merge({ :column => "#{enum_cd}_cd" }).deep_merge(options)
40
40
 
41
41
  # forward custom field options
42
42
  field_options = options.delete(:field)
@@ -1,5 +1,5 @@
1
1
  module SimpleEnum
2
2
 
3
3
  # +SimpleEnum+ version string.
4
- VERSION = "1.6.3"
4
+ VERSION = "1.6.4"
5
5
  end
data/test/mongoid_test.rb CHANGED
@@ -51,4 +51,16 @@ class MongoidTest < MiniTest::Unit::TestCase
51
51
  refute_nil klass.new.fields['gender_cd']
52
52
  assert_equal String, klass.new.fields['gender_cd'].options[:type]
53
53
  end
54
+
55
+ def test_default_field_options_are_merged_recursivly
56
+ skip('Only available in mongoid') unless mongoid?
57
+ SimpleEnum.default_options[:field] = { :type => String }
58
+ klass = anonymous_dummy do
59
+ as_enum :gender, [:male, :female], :field => { :default => "0" }
60
+ end
61
+
62
+ refute_nil klass.new.fields['gender_cd']
63
+ assert_equal String, klass.new.fields['gender_cd'].options[:type]
64
+ assert_equal "0", klass.new.fields['gender_cd'].options[:default]
65
+ end
54
66
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_enum
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
- - 3
10
- version: 1.6.3
9
+ - 4
10
+ version: 1.6.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lukas Westermann
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-09-08 00:00:00 Z
18
+ date: 2012-10-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement