dm-validations 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -0
- data/Manifest.txt +21 -2
- data/lib/dm-validations.rb +14 -14
- data/lib/dm-validations/absent_field_validator.rb +3 -4
- data/lib/dm-validations/acceptance_validator.rb +6 -10
- data/lib/dm-validations/confirmation_validator.rb +5 -5
- data/lib/dm-validations/contextual_validators.rb +1 -1
- data/lib/dm-validations/custom_validator.rb +1 -1
- data/lib/dm-validations/format_validator.rb +6 -5
- data/lib/dm-validations/generic_validator.rb +7 -10
- data/lib/dm-validations/length_validator.rb +7 -7
- data/lib/dm-validations/method_validator.rb +2 -2
- data/lib/dm-validations/numeric_validator.rb +4 -4
- data/lib/dm-validations/primitive_validator.rb +4 -4
- data/lib/dm-validations/required_field_validator.rb +5 -5
- data/lib/dm-validations/uniqueness_validator.rb +2 -2
- data/lib/dm-validations/validation_errors.rb +34 -2
- data/lib/dm-validations/version.rb +1 -1
- data/lib/dm-validations/within_validator.rb +15 -13
- data/spec/integration/absent_field_validator_spec.rb +4 -2
- data/spec/integration/acceptance_validator_spec.rb +3 -3
- data/spec/integration/auto_validate_spec.rb +16 -9
- data/spec/integration/block_validator_spec.rb +2 -8
- data/spec/integration/confirmation_validator_spec.rb +11 -8
- data/spec/integration/contextual_validators_spec.rb +2 -1
- data/spec/integration/format_validator_spec.rb +1 -1
- data/spec/integration/length_validator/error_message_spec.rb +23 -0
- data/spec/integration/length_validator/maximum_spec.rb +31 -0
- data/spec/integration/length_validator/minimum_spec.rb +31 -0
- data/spec/integration/length_validator/range_spec.rb +95 -0
- data/spec/integration/length_validator/spec_helper.rb +12 -0
- data/spec/integration/length_validator/valid_objects_spec.rb +13 -0
- data/spec/integration/method_validator_spec.rb +3 -3
- data/spec/integration/numeric_validator/float_type_spec.rb +102 -0
- data/spec/integration/numeric_validator/integer_only_true_spec.rb +92 -0
- data/spec/integration/numeric_validator/integer_type_spec.rb +100 -0
- data/spec/integration/numeric_validator/spec_helper.rb +77 -0
- data/spec/integration/numeric_validator_spec.rb +19 -6
- data/spec/integration/primitive_validator_spec.rb +2 -1
- data/spec/integration/required_field_validator/association_spec.rb +98 -0
- data/spec/integration/required_field_validator/boolean_type_value_spec.rb +149 -0
- data/spec/integration/required_field_validator/date_type_value_spec.rb +126 -0
- data/spec/integration/required_field_validator/datetime_type_value_spec.rb +126 -0
- data/spec/integration/required_field_validator/float_type_value_spec.rb +130 -0
- data/spec/integration/required_field_validator/integer_type_value_spec.rb +98 -0
- data/spec/integration/required_field_validator/plain_old_ruby_object_spec.rb +36 -0
- data/spec/integration/required_field_validator/shared_examples.rb +24 -0
- data/spec/integration/required_field_validator/spec_helper.rb +68 -0
- data/spec/integration/required_field_validator/string_type_value_spec.rb +164 -0
- data/spec/integration/required_field_validator/text_type_value_spec.rb +46 -0
- data/spec/integration/uniqueness_validator_spec.rb +10 -8
- data/spec/integration/validation_spec.rb +25 -25
- data/spec/integration/within_validator_spec.rb +36 -11
- data/tasks/spec.rb +1 -1
- metadata +24 -5
- data/spec/integration/length_validator_spec.rb +0 -115
- data/spec/integration/required_field_validator_spec.rb +0 -93
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
__dir__ = Pathname(__FILE__).dirname.expand_path
|
3
|
+
|
4
|
+
require __dir__.parent.parent + 'spec_helper'
|
5
|
+
require __dir__ + 'spec_helper'
|
6
|
+
|
7
|
+
if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
8
|
+
# keep in mind any ScmOperation has a default value for brand property
|
9
|
+
# so it is used
|
10
|
+
describe GitOperation do
|
11
|
+
before :each do
|
12
|
+
@operation = GitOperation.new(:network_connection => true,
|
13
|
+
:clean_working_copy => true,
|
14
|
+
:message => "I did it! I did it!! Hell yeah!!!")
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "without explicitly specified committer name" do
|
18
|
+
before :each do
|
19
|
+
# no specific actions for this case! yay!
|
20
|
+
end
|
21
|
+
|
22
|
+
it "is valid for committing (because default value jumps in)" do
|
23
|
+
@operation.should be_valid_for_committing
|
24
|
+
@operation.should be_valid(:committing)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "is not valid in default context" do
|
28
|
+
# context here is :default
|
29
|
+
@operation.should_not be_valid
|
30
|
+
end
|
31
|
+
|
32
|
+
it "has default value set" do
|
33
|
+
# this is more of a sanity check since
|
34
|
+
# this sort of functionality clearly needs to be
|
35
|
+
# tested in
|
36
|
+
@operation.committer_name.should == "Just another Ruby hacker"
|
37
|
+
end
|
38
|
+
end # describe "without explicitly specified committer name"
|
39
|
+
|
40
|
+
describe "WITH explicitly specified committer name" do
|
41
|
+
before :each do
|
42
|
+
@operation.committer_name = "Core Team Guy"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "is valid for committing" do
|
46
|
+
@operation.should be_valid_for_committing
|
47
|
+
@operation.should be_valid(:committing)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "is not valid in default context" do
|
51
|
+
@operation.should_not be_valid
|
52
|
+
@operation.should_not be_valid(:default)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "has value set" do
|
56
|
+
# this is more of a sanity check since
|
57
|
+
# this sort of functionality clearly needs to be
|
58
|
+
# tested in
|
59
|
+
@operation.committer_name.should == "Core Team Guy"
|
60
|
+
end
|
61
|
+
end # describe "with explicitly specified committer name"
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
describe "without explicitly specified author name" do
|
66
|
+
before :each do
|
67
|
+
# no specific actions for this case! yay!
|
68
|
+
end
|
69
|
+
|
70
|
+
it "is valid for committing (because default value jumps in)" do
|
71
|
+
@operation.should be_valid_for_committing
|
72
|
+
@operation.should be_valid(:committing)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "is not valid in default context" do
|
76
|
+
# context here is :default
|
77
|
+
@operation.should_not be_valid
|
78
|
+
@operation.should_not be_valid(:default)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "has default value set" do
|
82
|
+
@operation.author_name.should == "Just another Ruby hacker"
|
83
|
+
end
|
84
|
+
end # describe "without explicitly specified author name"
|
85
|
+
|
86
|
+
describe "WITH explicitly specified author name" do
|
87
|
+
before :each do
|
88
|
+
@operation.author_name = "Random contributor"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "is valid for committing" do
|
92
|
+
@operation.should be_valid_for_committing
|
93
|
+
end
|
94
|
+
|
95
|
+
it "is not valid in default context" do
|
96
|
+
# context here is :default
|
97
|
+
@operation.should_not be_valid
|
98
|
+
end
|
99
|
+
|
100
|
+
it "has value set" do
|
101
|
+
@operation.author_name.should == "Random contributor"
|
102
|
+
end
|
103
|
+
end # describe "with explicitly specified author name"
|
104
|
+
|
105
|
+
describe "with empty committer name" do
|
106
|
+
before(:each) do
|
107
|
+
@operation.committer_name = ""
|
108
|
+
end
|
109
|
+
|
110
|
+
it "is NOT valid for committing" do
|
111
|
+
# empty string is not considered present for
|
112
|
+
# a String value
|
113
|
+
@operation.should_not be_valid_for_committing
|
114
|
+
|
115
|
+
# sanity check since this empty vs blank vs nil
|
116
|
+
# thing is a shaky ground
|
117
|
+
@operation.committer_name = "l33t k0dr"
|
118
|
+
@operation.should be_valid_for_committing
|
119
|
+
end
|
120
|
+
|
121
|
+
it "IS valid for pushing" do
|
122
|
+
@operation.should be_valid_for_pushing
|
123
|
+
end
|
124
|
+
|
125
|
+
it "IS valid for pulling" do
|
126
|
+
@operation.should be_valid_for_pulling
|
127
|
+
end
|
128
|
+
|
129
|
+
it "is not valid in default context" do
|
130
|
+
@operation.should_not be_valid
|
131
|
+
end
|
132
|
+
end # describe "with empty committer field"
|
133
|
+
|
134
|
+
|
135
|
+
describe "with empty author name" do
|
136
|
+
before(:each) do
|
137
|
+
@operation.author_name = ""
|
138
|
+
end
|
139
|
+
|
140
|
+
it "is NOT valid for committing" do
|
141
|
+
# empty string is not considered present for
|
142
|
+
# a String value
|
143
|
+
@operation.should_not be_valid_for_committing
|
144
|
+
|
145
|
+
# sanity check since this empty vs blank vs nil
|
146
|
+
# thing is a shaky ground
|
147
|
+
@operation.author_name = "l33t k0dr"
|
148
|
+
@operation.should be_valid_for_committing
|
149
|
+
end
|
150
|
+
|
151
|
+
it "IS valid for pushing" do
|
152
|
+
@operation.should be_valid_for_pushing
|
153
|
+
end
|
154
|
+
|
155
|
+
it "IS valid for pulling" do
|
156
|
+
@operation.should be_valid_for_pulling
|
157
|
+
end
|
158
|
+
|
159
|
+
it "is not valid in default context" do
|
160
|
+
@operation.should_not be_valid
|
161
|
+
end
|
162
|
+
end # describe "with empty author field"
|
163
|
+
end # describe GitOperation
|
164
|
+
end # if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
__dir__ = Pathname(__FILE__).dirname.expand_path
|
3
|
+
|
4
|
+
require __dir__.parent.parent + 'spec_helper'
|
5
|
+
require __dir__ + 'spec_helper'
|
6
|
+
|
7
|
+
if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
8
|
+
# keep in mind any ScmOperation has a default value for brand property
|
9
|
+
# so it is used
|
10
|
+
describe GitOperation do
|
11
|
+
before :each do
|
12
|
+
@operation = GitOperation.new(:network_connection => true,
|
13
|
+
:clean_working_copy => true,
|
14
|
+
:message => "I did it! I did it!! Hell yeah!!!")
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "with empty message" do
|
18
|
+
before(:each) do
|
19
|
+
@operation.message = ""
|
20
|
+
end
|
21
|
+
|
22
|
+
it "is NOT valid for committing" do
|
23
|
+
# empty string is not considered present for
|
24
|
+
# a text value
|
25
|
+
@operation.should_not be_valid_for_committing
|
26
|
+
|
27
|
+
# sanity check since this empty vs blank vs nil
|
28
|
+
# thing is a shaky ground
|
29
|
+
@operation.message = "RUBY ON RAILS CAN SCALE NOW!!! w00t!!!"
|
30
|
+
@operation.should be_valid_for_committing
|
31
|
+
end
|
32
|
+
|
33
|
+
it "IS valid for pushing" do
|
34
|
+
@operation.should be_valid_for_pushing
|
35
|
+
end
|
36
|
+
|
37
|
+
it "IS valid for pulling" do
|
38
|
+
@operation.should be_valid_for_pulling
|
39
|
+
end
|
40
|
+
|
41
|
+
it "is not valid in default context" do
|
42
|
+
@operation.should_not be_valid
|
43
|
+
end
|
44
|
+
end # describe "with empty message"
|
45
|
+
end # describe GitOperation
|
46
|
+
end # if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
@@ -5,7 +5,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
5
5
|
describe DataMapper::Validate::UniquenessValidator do
|
6
6
|
|
7
7
|
before do
|
8
|
-
class Organisation
|
8
|
+
class ::Organisation
|
9
9
|
include DataMapper::Resource
|
10
10
|
property :id, Serial
|
11
11
|
property :name, String
|
@@ -14,7 +14,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
14
14
|
validates_is_unique :domain, :allow_nil => true
|
15
15
|
end
|
16
16
|
|
17
|
-
class User
|
17
|
+
class ::User
|
18
18
|
include DataMapper::Resource
|
19
19
|
property :id, Serial
|
20
20
|
property :organisation_id, Integer
|
@@ -33,7 +33,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
33
33
|
Organisation.new(:id=>1, :name=>'Org One', :domain=>'taken').save
|
34
34
|
Organisation.new(:id=>2, :name=>'Org Two', :domain=>'two').save
|
35
35
|
|
36
|
-
User.new(:id=>1
|
36
|
+
User.new(:id=>1, :organisation_id=>1, :user_name=>'guy').save
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -42,11 +42,11 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
42
42
|
o = Organisation.get!(1)
|
43
43
|
o.should be_valid
|
44
44
|
|
45
|
-
o = Organisation.new(:id=>20
|
45
|
+
o = Organisation.new(:id=>20, :name=>"Org Twenty", :domain=>nil)
|
46
46
|
o.should be_valid
|
47
47
|
o.save
|
48
48
|
|
49
|
-
o = Organisation.new(:id=>30
|
49
|
+
o = Organisation.new(:id=>30, :name=>"Org Thirty", :domain=>nil)
|
50
50
|
o.should be_valid
|
51
51
|
end
|
52
52
|
end
|
@@ -56,17 +56,17 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
56
56
|
o = Organisation.get!(1)
|
57
57
|
o.should be_valid
|
58
58
|
|
59
|
-
o = Organisation.new(:id=>2
|
59
|
+
o = Organisation.new(:id=>2, :name=>"Org Two", :domain=>"taken")
|
60
60
|
o.should_not be_valid
|
61
61
|
o.errors.on(:domain).should include('Domain is already taken')
|
62
62
|
|
63
|
-
o = Organisation.new(:id=>2
|
63
|
+
o = Organisation.new(:id=>2, :name=>"Org Two", :domain=>"not_taken")
|
64
64
|
o.should be_valid
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'should validate uniqueness on a string key' do
|
69
|
-
class Department
|
69
|
+
class ::Department
|
70
70
|
include DataMapper::Resource
|
71
71
|
property :name, String, :key => true
|
72
72
|
|
@@ -83,7 +83,9 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
83
83
|
repository do
|
84
84
|
u = User.new(:id => 2, :organisation_id=>1, :user_name => 'guy')
|
85
85
|
u.should_not be_valid_for_testing_property
|
86
|
+
u.errors.on(:user_name).should include('User name is already taken')
|
86
87
|
u.should_not be_valid_for_testing_association
|
88
|
+
u.errors.on(:user_name).should include('User name is already taken')
|
87
89
|
|
88
90
|
|
89
91
|
u = User.new(:id => 2, :organisation_id => 2, :user_name => 'guy')
|
@@ -3,7 +3,7 @@ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
|
3
3
|
|
4
4
|
describe DataMapper::Validate do
|
5
5
|
before :all do
|
6
|
-
class Yacht
|
6
|
+
class ::Yacht
|
7
7
|
include DataMapper::Resource
|
8
8
|
property :id, Integer, :serial => true
|
9
9
|
property :name, String, :auto_validation => false
|
@@ -15,7 +15,7 @@ describe DataMapper::Validate do
|
|
15
15
|
describe '#validations' do
|
16
16
|
it 'should support more different validations of a different type' do
|
17
17
|
number_of_validators_before = Yacht.validators.contexts[:default].length
|
18
|
-
class Yacht
|
18
|
+
class ::Yacht
|
19
19
|
validates_is_unique :name
|
20
20
|
end
|
21
21
|
number_of_validators_after = Yacht.validators.contexts[:default].length
|
@@ -59,7 +59,7 @@ describe DataMapper::Validate do
|
|
59
59
|
|
60
60
|
describe 'with context specified' do
|
61
61
|
before :all do
|
62
|
-
class Yacht
|
62
|
+
class ::Yacht
|
63
63
|
validates_length :name, :min => 2, :context => [ :strict_name ]
|
64
64
|
end
|
65
65
|
end
|
@@ -143,7 +143,7 @@ describe DataMapper::Validate do
|
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should allow multiple user defined contexts for a validator" do
|
146
|
-
class Yacht
|
146
|
+
class ::Yacht
|
147
147
|
property :port, String, :auto_validation => false
|
148
148
|
validates_present :port, :context => [:at_sea, :in_harbor]
|
149
149
|
end
|
@@ -154,7 +154,7 @@ describe DataMapper::Validate do
|
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should alias :on and :when for :context" do
|
157
|
-
class Yacht
|
157
|
+
class ::Yacht
|
158
158
|
property :owner, String, :auto_validation => false
|
159
159
|
property :bosun, String, :auto_validation => false
|
160
160
|
|
@@ -166,7 +166,7 @@ describe DataMapper::Validate do
|
|
166
166
|
end
|
167
167
|
|
168
168
|
it "should alias :group for :context (backward compat with Validatable??)" do
|
169
|
-
class Yacht
|
169
|
+
class ::Yacht
|
170
170
|
property :captain, String, :auto_validation => false
|
171
171
|
validates_present :captain, :group => [:captained_vessel]
|
172
172
|
end
|
@@ -174,7 +174,7 @@ describe DataMapper::Validate do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it "should add a method valid_for_<context_name>? for each context" do
|
177
|
-
class Yacht
|
177
|
+
class ::Yacht
|
178
178
|
property :engine_size, String, :auto_validation => false
|
179
179
|
validates_present :engine_size, :when => :power_boat
|
180
180
|
end
|
@@ -189,7 +189,7 @@ describe DataMapper::Validate do
|
|
189
189
|
end
|
190
190
|
|
191
191
|
it "should add a method all_valid_for_<context_name>? for each context" do
|
192
|
-
class Yacht
|
192
|
+
class ::Yacht
|
193
193
|
property :mast_height, String, :auto_validation => false
|
194
194
|
validates_present :mast_height, :when => :sailing_vessel
|
195
195
|
end
|
@@ -200,7 +200,7 @@ describe DataMapper::Validate do
|
|
200
200
|
it "should be able to translate the error message" # needs String::translations
|
201
201
|
|
202
202
|
it "should be able to get the error message for a given field" do
|
203
|
-
class Yacht
|
203
|
+
class ::Yacht
|
204
204
|
property :wood_type, String, :auto_validation => false
|
205
205
|
validates_present :wood_type, :on => :wooden_boats
|
206
206
|
end
|
@@ -212,7 +212,7 @@ describe DataMapper::Validate do
|
|
212
212
|
end
|
213
213
|
|
214
214
|
it "should be able to specify a custom error message" do
|
215
|
-
class Yacht
|
215
|
+
class ::Yacht
|
216
216
|
property :year_built, String, :auto_validation => false
|
217
217
|
validates_present :year_built, :when => :built, :message => 'Year built is a must enter field'
|
218
218
|
end
|
@@ -223,7 +223,7 @@ describe DataMapper::Validate do
|
|
223
223
|
end
|
224
224
|
|
225
225
|
it "should execute a Proc when provided in an :if clause and run validation if the Proc returns true" do
|
226
|
-
class Dingy
|
226
|
+
class ::Dingy
|
227
227
|
include DataMapper::Resource
|
228
228
|
property :id, Integer, :serial => true
|
229
229
|
property :owner, String, :auto_validation => false
|
@@ -236,7 +236,7 @@ describe DataMapper::Validate do
|
|
236
236
|
|
237
237
|
Dingy.new.valid?.should == true
|
238
238
|
|
239
|
-
class Dingy
|
239
|
+
class ::Dingy
|
240
240
|
def owned?
|
241
241
|
true
|
242
242
|
end
|
@@ -246,7 +246,7 @@ describe DataMapper::Validate do
|
|
246
246
|
end
|
247
247
|
|
248
248
|
it "should execute a symbol or method name provided in an :if clause and run validation if the method returns true" do
|
249
|
-
class Dingy
|
249
|
+
class ::Dingy
|
250
250
|
validators.clear!
|
251
251
|
validates_present :owner, :if => :owned?
|
252
252
|
|
@@ -257,7 +257,7 @@ describe DataMapper::Validate do
|
|
257
257
|
|
258
258
|
Dingy.new.valid?.should == true
|
259
259
|
|
260
|
-
class Dingy
|
260
|
+
class ::Dingy
|
261
261
|
def owned?
|
262
262
|
true
|
263
263
|
end
|
@@ -267,7 +267,7 @@ describe DataMapper::Validate do
|
|
267
267
|
end
|
268
268
|
|
269
269
|
it "should execute a Proc when provided in an :unless clause and not run validation if the Proc returns true" do
|
270
|
-
class RowBoat
|
270
|
+
class ::RowBoat
|
271
271
|
include DataMapper::Resource
|
272
272
|
property :id, Integer, :serial => true
|
273
273
|
validates_present :salesman, :unless => Proc.new{|resource| resource.sold?}
|
@@ -279,7 +279,7 @@ describe DataMapper::Validate do
|
|
279
279
|
|
280
280
|
RowBoat.new.valid?.should_not == true
|
281
281
|
|
282
|
-
class RowBoat
|
282
|
+
class ::RowBoat
|
283
283
|
def sold?
|
284
284
|
true
|
285
285
|
end
|
@@ -289,7 +289,7 @@ describe DataMapper::Validate do
|
|
289
289
|
end
|
290
290
|
|
291
291
|
it "should execute a symbol or method name provided in an :unless clause and not run validation if the method returns true" do
|
292
|
-
class Dingy
|
292
|
+
class ::Dingy
|
293
293
|
validators.clear!
|
294
294
|
validates_present :salesman, :unless => :sold?
|
295
295
|
|
@@ -300,7 +300,7 @@ describe DataMapper::Validate do
|
|
300
300
|
|
301
301
|
Dingy.new.valid?.should_not == true #not sold and no salesman
|
302
302
|
|
303
|
-
class Dingy
|
303
|
+
class ::Dingy
|
304
304
|
def sold?
|
305
305
|
true
|
306
306
|
end
|
@@ -310,7 +310,7 @@ describe DataMapper::Validate do
|
|
310
310
|
end
|
311
311
|
|
312
312
|
it "should perform automatic recursive validation #all_valid? checking all instance variables (and ivar.each items if valid)" do
|
313
|
-
class Invoice
|
313
|
+
class ::Invoice
|
314
314
|
include DataMapper::Resource
|
315
315
|
property :id, Integer, :serial => true
|
316
316
|
property :customer, String, :auto_validation => false
|
@@ -329,7 +329,7 @@ describe DataMapper::Validate do
|
|
329
329
|
end
|
330
330
|
end
|
331
331
|
|
332
|
-
class LineItem
|
332
|
+
class ::LineItem
|
333
333
|
include DataMapper::Resource
|
334
334
|
property :id, Integer, :serial => true
|
335
335
|
property :price, String, :auto_validation => false
|
@@ -340,7 +340,7 @@ describe DataMapper::Validate do
|
|
340
340
|
end
|
341
341
|
end
|
342
342
|
|
343
|
-
class Comment
|
343
|
+
class ::Comment
|
344
344
|
include DataMapper::Resource
|
345
345
|
property :id, Integer, :serial => true
|
346
346
|
property :note, String, :auto_validation => false
|
@@ -370,7 +370,7 @@ describe DataMapper::Validate do
|
|
370
370
|
end
|
371
371
|
|
372
372
|
it "should retrieve private instance variables for validation" do
|
373
|
-
class Raft
|
373
|
+
class ::Raft
|
374
374
|
include DataMapper::Resource
|
375
375
|
property :length, Integer, :accessor => :private
|
376
376
|
|
@@ -383,7 +383,7 @@ describe DataMapper::Validate do
|
|
383
383
|
end
|
384
384
|
|
385
385
|
it "should duplicate validations to STI models" do
|
386
|
-
class Company
|
386
|
+
class ::Company
|
387
387
|
include DataMapper::Resource
|
388
388
|
|
389
389
|
validates_present :title, :message => "Company name is a required field"
|
@@ -393,10 +393,10 @@ describe DataMapper::Validate do
|
|
393
393
|
property :type, Discriminator
|
394
394
|
end
|
395
395
|
|
396
|
-
class ServiceCompany < Company
|
396
|
+
class ::ServiceCompany < Company
|
397
397
|
end
|
398
398
|
|
399
|
-
class ProductCompany < Company
|
399
|
+
class ::ProductCompany < Company
|
400
400
|
end
|
401
401
|
company = ServiceCompany.new
|
402
402
|
company.should_not be_valid
|