mongoa 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mongoa/mongo_mapper/validations/validate_base.rb +14 -4
- data/lib/mongoa/mongo_mapper/validations/validate_format_of.rb +5 -0
- data/lib/mongoa/mongo_mapper/validations/validate_inclusion_of.rb +10 -1
- data/lib/mongoa/mongo_mapper/validations/validate_length_of.rb +24 -4
- data/lib/mongoa/mongo_mapper/validations/validate_numericality_of.rb +4 -0
- data/lib/mongoa/mongo_mapper/validations/validate_presence_of.rb +4 -0
- data/lib/mongoa/mongo_mapper/validations/validate_uniqueness_of.rb +4 -0
- data/mongoa.gemspec +2 -2
- data/spec/spec_helper.rb +55 -1
- data/spec/validations/validate_inclusion_of_spec.rb +30 -21
- data/spec/validations/validate_length_of_spec.rb +53 -44
- data/spec/validations/validate_numercality_of_spec.rb +18 -14
- data/spec/validations/validate_presence_of_spec.rb +23 -14
- data/spec/validations/validate_uniqueness_of_spec.rb +29 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
@@ -16,6 +16,10 @@ module Mongoa
|
|
16
16
|
def validation_type
|
17
17
|
raise "Redefine in the subclass"
|
18
18
|
end
|
19
|
+
|
20
|
+
def validator_class_name
|
21
|
+
raise "Redefine in the subclass"
|
22
|
+
end
|
19
23
|
|
20
24
|
private
|
21
25
|
|
@@ -24,10 +28,16 @@ module Mongoa
|
|
24
28
|
end
|
25
29
|
|
26
30
|
def find_validation
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
+
if model_class.respond_to?(:validators)
|
32
|
+
model_class.validators.detect do |validator|
|
33
|
+
validator.class.to_s == validator_class_name && validator.attributes.include?(attribute)
|
34
|
+
end
|
35
|
+
else
|
36
|
+
attr_validations = model_class.validations.select { |validation| validation.attribute == attribute }
|
37
|
+
return nil unless attr_validations
|
38
|
+
attr_validations.detect { |validation| validation.key.include?(validation_type) }
|
39
|
+
end
|
40
|
+
end
|
31
41
|
end
|
32
42
|
end
|
33
43
|
end
|
@@ -9,7 +9,7 @@ module Mongoa
|
|
9
9
|
|
10
10
|
def matches?(subject)
|
11
11
|
super(subject)
|
12
|
-
@validation ?
|
12
|
+
@validation ? within == @within : false
|
13
13
|
end
|
14
14
|
|
15
15
|
def description
|
@@ -29,6 +29,15 @@ module Mongoa
|
|
29
29
|
def validation_type
|
30
30
|
"ValidatesInclusionOf"
|
31
31
|
end
|
32
|
+
|
33
|
+
def validator_class_name
|
34
|
+
"ActiveModel::Validations::InclusionValidator"
|
35
|
+
end
|
36
|
+
|
37
|
+
#MM - master branch has removed the within
|
38
|
+
def within
|
39
|
+
@validation.respond_to?(:within) ? @validation.within : @validation.options[:in]
|
40
|
+
end
|
32
41
|
end
|
33
42
|
end
|
34
43
|
end
|
@@ -23,17 +23,17 @@ module Mongoa
|
|
23
23
|
super(subject)
|
24
24
|
if @validation
|
25
25
|
if @length_options.keys.include?(:minimum)
|
26
|
-
result =
|
26
|
+
result = minimum == @length_options[:minimum]
|
27
27
|
return false if !result
|
28
28
|
end
|
29
29
|
|
30
30
|
if @length_options.keys.include?(:maximum)
|
31
|
-
result =
|
31
|
+
result = maximum == @length_options[:maximum]
|
32
32
|
return false if !result
|
33
33
|
end
|
34
34
|
|
35
|
-
if @length_options.keys.include?(:within)
|
36
|
-
result =
|
35
|
+
if @length_options.keys.include?(:within)
|
36
|
+
result = within == @length_options[:within]
|
37
37
|
return false if !result
|
38
38
|
end
|
39
39
|
true
|
@@ -59,6 +59,26 @@ module Mongoa
|
|
59
59
|
def validation_type
|
60
60
|
"ValidatesLengthOf"
|
61
61
|
end
|
62
|
+
|
63
|
+
def validator_class_name
|
64
|
+
"ActiveModel::Validations::LengthValidator"
|
65
|
+
end
|
66
|
+
|
67
|
+
def minimum
|
68
|
+
@validation.respond_to?(:minimum) ? @validation.minimum : @validation.options[:minimum]
|
69
|
+
end
|
70
|
+
|
71
|
+
def maximum
|
72
|
+
@validation.respond_to?(:maximum) ? @validation.maximum : @validation.options[:maximum]
|
73
|
+
end
|
74
|
+
|
75
|
+
def within
|
76
|
+
if @validation.respond_to?(:within)
|
77
|
+
@validation.within
|
78
|
+
else
|
79
|
+
(@validation.options[:minimum]..@validation.options[:maximum])
|
80
|
+
end
|
81
|
+
end
|
62
82
|
end
|
63
83
|
end
|
64
84
|
end
|
data/mongoa.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongoa}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Scott J. Tamosunas"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-21}
|
13
13
|
s.description = %q{Adds the association and validation macros for Rspec in the same way Shoulda does for ActiveRecord.}
|
14
14
|
s.email = %q{tamosunas@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# $LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
# $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
require 'rubygems'
|
4
|
+
require 'active_model'
|
4
5
|
require 'mongo_mapper'
|
5
6
|
require 'mongo_mapper/plugins'
|
6
7
|
require 'mongo_mapper/plugins/associations'
|
@@ -20,6 +21,7 @@ end
|
|
20
21
|
require 'mongoa'
|
21
22
|
require File.expand_path(File.dirname(__FILE__) + '/../lib/mongoa/mongo_mapper/matchers')
|
22
23
|
|
24
|
+
#The models that include ActiveModel are emulating what the later version of MongoMapper is doing
|
23
25
|
class User
|
24
26
|
include MongoMapper::Document
|
25
27
|
|
@@ -33,6 +35,20 @@ class User
|
|
33
35
|
validates_numericality_of :years_alive
|
34
36
|
end
|
35
37
|
|
38
|
+
class UserActiveModel
|
39
|
+
include MongoMapper::Document
|
40
|
+
include ActiveModel::Validations
|
41
|
+
|
42
|
+
key :name, String
|
43
|
+
key :email, String
|
44
|
+
key :years_alive, Integer
|
45
|
+
key :years_alive_numeric, Integer, :numeric => true
|
46
|
+
key :email_format, String, :format => /(\A(\s*)\Z)|(\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z)/i
|
47
|
+
|
48
|
+
validates_format_of :email, :with => /(\A(\s*)\Z)|(\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z)/i
|
49
|
+
validates_numericality_of :years_alive
|
50
|
+
end
|
51
|
+
|
36
52
|
class Post
|
37
53
|
include MongoMapper::Document
|
38
54
|
|
@@ -44,6 +60,18 @@ class Post
|
|
44
60
|
validates_uniqueness_of :unique_name
|
45
61
|
end
|
46
62
|
|
63
|
+
class PostActiveModel
|
64
|
+
include MongoMapper::Document
|
65
|
+
include ActiveModel::Validations
|
66
|
+
|
67
|
+
key :name, String
|
68
|
+
key :unique_name, String
|
69
|
+
|
70
|
+
validates_presence_of :name
|
71
|
+
validates_length_of :name, :minimum => 4, :maximum => 32
|
72
|
+
validates_uniqueness_of :unique_name
|
73
|
+
end
|
74
|
+
|
47
75
|
class PostRequired
|
48
76
|
include MongoMapper::Document
|
49
77
|
|
@@ -52,6 +80,15 @@ class PostRequired
|
|
52
80
|
key :range_name, String, :required => true, :length => 0..56
|
53
81
|
end
|
54
82
|
|
83
|
+
class PostRequiredActiveModel
|
84
|
+
include MongoMapper::Document
|
85
|
+
include ActiveModel::Validations
|
86
|
+
|
87
|
+
key :name, String, :required => true, :length => 32
|
88
|
+
key :unique_name, String, :unique => true
|
89
|
+
key :range_name, String, :required => true, :length => 0..56
|
90
|
+
end
|
91
|
+
|
55
92
|
class Within
|
56
93
|
include MongoMapper::Document
|
57
94
|
|
@@ -60,8 +97,25 @@ class Within
|
|
60
97
|
validates_inclusion_of :state, :within => ["new", "uploaded"]
|
61
98
|
end
|
62
99
|
|
100
|
+
class WithinActiveModel
|
101
|
+
include MongoMapper::Document
|
102
|
+
include ActiveModel::Validations
|
103
|
+
|
104
|
+
key :state, String
|
105
|
+
|
106
|
+
validates_inclusion_of :state, :in => ["new", "uploaded"]
|
107
|
+
end
|
108
|
+
|
63
109
|
class WithinIn
|
64
110
|
include MongoMapper::Document
|
65
111
|
|
66
112
|
key :state, String, :in => ["new", "uploaded"]
|
67
|
-
end
|
113
|
+
end
|
114
|
+
|
115
|
+
#This doesn't work with MM 0.8.6 as is transforms in to within
|
116
|
+
# class WithinInActiveModel
|
117
|
+
# include MongoMapper::Document
|
118
|
+
# include ActiveModel::Validations
|
119
|
+
#
|
120
|
+
# key :state, String, :in => ["new", "uploaded"]
|
121
|
+
# end
|
@@ -2,34 +2,43 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe Mongoa::MongoMapper do
|
4
4
|
describe "#validates_inclusion_of or key :in => []" do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
|
6
|
+
[Within, WithinActiveModel].each do |model_class|
|
7
|
+
context "#{model_class}" do
|
8
|
+
describe "validates_inclusion_of" do
|
9
|
+
it "should return true if the key has a validate_inclusion_of with the specified within" do
|
10
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:state, ["new", "uploaded"])
|
11
|
+
validation.should be_matches(Within.new)
|
12
|
+
end
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
it "should return false if the key has a validate_inclusion_of but the within doesn't match" do
|
15
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:state, ["goo", "gaa"])
|
16
|
+
validation.should_not be_matches(Within.new)
|
17
|
+
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
it "should return false if the key does not have a validate_inclusion_of set" do
|
20
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:foo, ["new", "uploaded"])
|
21
|
+
validation.should_not be_matches(Within.new)
|
22
|
+
end
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
27
|
+
[WithinIn].each do |model_class|
|
28
|
+
context "#{model_class}" do
|
29
|
+
describe "in" do
|
30
|
+
it "should work the same as validates_inclusion_of" do
|
31
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:state, ["new", "uploaded"])
|
32
|
+
validation.should be_matches(WithinIn.new)
|
26
33
|
|
27
|
-
|
28
|
-
|
34
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:state, ["goo", "gaa"])
|
35
|
+
validation.should_not be_matches(WithinIn.new)
|
29
36
|
|
30
|
-
|
31
|
-
|
37
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:foo, ["new", "uploaded"])
|
38
|
+
validation.should_not be_matches(WithinIn.new)
|
39
|
+
end
|
40
|
+
end
|
32
41
|
end
|
33
|
-
end
|
42
|
+
end
|
34
43
|
end
|
35
44
|
end
|
@@ -2,56 +2,65 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe Mongoa::MongoMapper do
|
4
4
|
describe "#validates_length_of or key :length => <length_options>" do
|
5
|
-
describe "validates_length_of" do
|
6
|
-
describe "maximum" do
|
7
|
-
it "should return true if the key has a validates_length of with the specified :maximum" do
|
8
|
-
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:name, :maximum => 32)
|
9
|
-
validation.should be_matches(Post.new)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should return false if the key has a validates_length but the maximum's don't match" do
|
13
|
-
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:name, :maximum => 25)
|
14
|
-
validation.should_not be_matches(Post.new)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should return false if the key does not have a validates_length of" do
|
18
|
-
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:foo, :maximum => 32)
|
19
|
-
validation.should_not be_matches(Post.new)
|
20
|
-
end
|
21
|
-
end
|
22
5
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
6
|
+
[Post, PostActiveModel].each do |model_class|
|
7
|
+
context "#{model_class}" do
|
8
|
+
describe "validates_length_of" do
|
9
|
+
describe "maximum" do
|
10
|
+
it "should return true if the key has a validates_length of with the specified :maximum" do
|
11
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:name, :maximum => 32)
|
12
|
+
validation.should be_matches(model_class.new)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return false if the key has a validates_length but the maximum's don't match" do
|
16
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:name, :maximum => 25)
|
17
|
+
validation.should_not be_matches(model_class.new)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return false if the key does not have a validates_length of" do
|
21
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:foo, :maximum => 32)
|
22
|
+
validation.should_not be_matches(model_class.new)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "minimum" do
|
27
|
+
it "should return true if the key has a validates_length of with the specified :minimum" do
|
28
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:name, :minimum => 4)
|
29
|
+
validation.should be_matches(model_class.new)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return false if the key has a validates_length of but the minimum's don't match" do
|
33
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:name, :minimum => 2)
|
34
|
+
validation.should_not be_matches(model_class.new)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return false if the key does not have a validates_length" do
|
38
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:foo, :minimum => 32)
|
39
|
+
validation.should_not be_matches(model_class.new)
|
40
|
+
end
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
40
|
-
|
41
|
-
describe "length" do
|
42
|
-
it "should work the same as validates_length_of" do
|
43
|
-
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:name, :length => 32)
|
44
|
-
validation.should be_matches(PostRequired.new)
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
[PostRequiredActiveModel].each do |model_class|
|
47
|
+
context "#{model_class}" do
|
48
|
+
describe "length" do
|
49
|
+
it "should work the same as validates_length_of" do
|
50
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:name, :length => 32)
|
51
|
+
validation.should be_matches(model_class.new)
|
52
|
+
|
53
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:name, :length => 25)
|
54
|
+
validation.should_not be_matches(model_class.new)
|
55
|
+
|
56
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:foo, :length => 32)
|
57
|
+
validation.should_not be_matches(model_class.new)
|
48
58
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
validation.should be_matches(PostRequired.new)
|
59
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateLengthOfMatcher.new(:range_name, :length => 0..56)
|
60
|
+
validation.should be_matches(model_class.new)
|
61
|
+
end
|
62
|
+
end
|
54
63
|
end
|
55
|
-
end
|
64
|
+
end
|
56
65
|
end
|
57
66
|
end
|
@@ -2,22 +2,26 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe Mongoa::MongoMapper do
|
4
4
|
describe "validates_numericality_of or key numeric" do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
[User, UserActiveModel].each do |model_class|
|
6
|
+
context model_class do
|
7
|
+
describe "#validates_numericality_of" do
|
8
|
+
it "should return true if the key has a validates_numericality_of validtion" do
|
9
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateNumericalityOfMatcher.new(:years_alive)
|
10
|
+
validation.should be_matches(model_class.new)
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
it "should return false if it doesn't have a validates_numericality_of" do
|
14
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateNumericalityOfMatcher.new(:foo)
|
15
|
+
validation.should_not be_matches(model_class.new)
|
16
|
+
end
|
17
|
+
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
describe "numeric" do
|
20
|
+
it "should work the same if the key is numeric rather than validates_numericality_of" do
|
21
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateNumericalityOfMatcher.new(:years_alive_numeric)
|
22
|
+
validation.should be_matches(model_class.new)
|
23
|
+
end
|
24
|
+
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
@@ -2,25 +2,34 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe Mongoa::MongoMapper do
|
4
4
|
describe "validates_presence_of or key required => :true" do
|
5
|
-
describe "#validates_presence_of" do
|
6
|
-
it "should return true if the key has a validates_presence_of validtion" do
|
7
|
-
validation = Mongoa::MongoMapper::Matchers::ValidatePresenceOfMatcher.new(:name)
|
8
|
-
validation.should be_matches(Post.new)
|
9
|
-
end
|
10
5
|
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
[Post, PostActiveModel].each do |model_class|
|
7
|
+
context "#{model_class}" do
|
8
|
+
describe "#validates_presence_of" do
|
9
|
+
it "should return true if the key has a validates_presence_of validtion" do
|
10
|
+
validation = Mongoa::MongoMapper::Matchers::ValidatePresenceOfMatcher.new(:name)
|
11
|
+
validation.should be_matches(model_class.new)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return false if the key does not have a validates_presence_of validtion" do
|
15
|
+
validation = Mongoa::MongoMapper::Matchers::ValidatePresenceOfMatcher.new(:foo)
|
16
|
+
validation.should_not be_matches(model_class.new)
|
17
|
+
end
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
22
|
+
[PostRequired, PostRequiredActiveModel].each do |model_class|
|
23
|
+
context "#{model_class}" do
|
24
|
+
describe "required" do
|
25
|
+
it "should work the same if the key is required rather than validates_presence_of" do
|
26
|
+
validation = Mongoa::MongoMapper::Matchers::ValidatePresenceOfMatcher.new(:name)
|
27
|
+
validation.should be_matches(model_class.new)
|
21
28
|
|
22
|
-
|
23
|
-
|
29
|
+
validation = Mongoa::MongoMapper::Matchers::ValidatePresenceOfMatcher.new(:foo)
|
30
|
+
validation.should_not be_matches(model_class.new)
|
31
|
+
end
|
32
|
+
end
|
24
33
|
end
|
25
34
|
end
|
26
35
|
end
|
@@ -24,4 +24,33 @@ describe Mongoa::MongoMapper do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
#This is defined by MonoMapper, not ActiveModel
|
29
|
+
if defined?(ActiveModel::Validations::UniquenessValidator)
|
30
|
+
context "ActiveModel" do
|
31
|
+
describe "validates_uniqueness_of or key required => :true" do
|
32
|
+
describe "#validates_uniqueness_of" do
|
33
|
+
it "should return true if the key has a validates_presence_of validtion" do
|
34
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateUniquenessOfMatcher.new(:unique_name)
|
35
|
+
validation.should be_matches(PostActiveModel.new)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return false if the key does not have a validates_presence_of validtion" do
|
39
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateUniquenessOfMatcher.new(:foo)
|
40
|
+
validation.should_not be_matches(PostActiveModel.new)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "unique" do
|
45
|
+
it "should work the same if the key is unique rather than validates_presence_of" do
|
46
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateUniquenessOfMatcher.new(:unique_name)
|
47
|
+
validation.should be_matches(PostRequiredActiveModel.new)
|
48
|
+
|
49
|
+
validation = Mongoa::MongoMapper::Matchers::ValidateUniquenessOfMatcher.new(:foo)
|
50
|
+
validation.should_not be_matches(PostRequiredActiveModel.new)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
27
56
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mongoa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Scott J. Tamosunas
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-21 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|