has_constant 0.2.5 → 0.2.6

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.2.5
1
+ 0.2.6
data/has_constant.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{has_constant}
8
- s.version = "0.2.5"
8
+ s.version = "0.2.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"]
12
- s.date = %q{2010-08-14}
12
+ s.date = %q{2010-08-15}
13
13
  s.description = %q{Allows certain fields to be limited to a set of values}
14
14
  s.email = %q{mattbeedle@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -32,7 +32,7 @@ module HasConstant
32
32
  if val.instance_of?(String)
33
33
  if index = self.class.send(name.to_s).index(val)
34
34
  write_attribute singular.to_sym, index
35
- else
35
+ elsif !val.blank?
36
36
  values = values.call if values.respond_to?(:call)
37
37
  @has_constant_errors ||= {}
38
38
  @has_constant_errors.merge!(singular.to_sym => "must be one of #{values.join(', ')}")
@@ -42,6 +42,11 @@ class MongoidTest < Test::Unit::TestCase
42
42
  assert !m.valid?
43
43
  assert_equal ['must be one of Mr, Mrs'], m.errors[:salutation]
44
44
  end
45
+
46
+ should 'be valid when a blank value is supplied' do
47
+ m = MongoUserWithProc.new(:salutation => '')
48
+ assert m.valid?
49
+ end
45
50
  end
46
51
 
47
52
  context 'Named Scopes' 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: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - mattbeedle
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-14 00:00:00 +02:00
18
+ date: 2010-08-15 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency