vidibus-inheritance 0.3.6 → 0.3.9
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/README.rdoc +3 -2
- data/TODO +4 -5
- data/VERSION +1 -1
- data/lib/vidibus/inheritance.rb +1 -7
- data/lib/vidibus/inheritance/mongoid.rb +239 -190
- data/lib/vidibus/inheritance/validators/ancestor_validator.rb +1 -1
- data/spec/models.rb +70 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/vidibus/inheritance/inheritance_spec.rb +396 -0
- data/spec/vidibus/inheritance/mongoid_spec.rb +104 -397
- data/spec/vidibus/inheritance/validators/ancestor_validator_spec.rb +11 -13
- data/vidibus-inheritance.gemspec +7 -3
- metadata +8 -4
@@ -1,27 +1,25 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "Vidibus::Inheritance::Validators::AncestorValidator" do
|
4
|
-
|
5
|
-
include ActiveModel::Validations
|
6
|
-
attr_accessor :ancestor
|
7
|
-
validates :ancestor, :ancestor => true
|
8
|
-
end
|
9
|
-
|
10
|
-
class InvalidModel; end
|
11
|
-
|
12
|
-
let(:model) { ValidModel.new }
|
3
|
+
describe "Vidibus::Inheritance::Validators::AncestorValidator" do
|
4
|
+
let(:model) { ValidatedModel.new }
|
13
5
|
|
14
6
|
it "should be available as ancestor validator" do
|
15
7
|
Model.validators_on(:ancestor).first.should be_a_kind_of(Vidibus::Inheritance::Validators::AncestorValidator)
|
16
8
|
end
|
17
9
|
|
18
10
|
it "should validate an ancestor of same class" do
|
19
|
-
model.ancestor =
|
11
|
+
model.ancestor = ValidatedModel.new
|
20
12
|
model.valid?.should be_true
|
21
13
|
end
|
22
14
|
|
23
|
-
it "should add an error
|
24
|
-
model.ancestor =
|
15
|
+
it "should add an error if ancestor is of a different class" do
|
16
|
+
model.ancestor = Clerk.new
|
17
|
+
model.valid?.should be_false
|
18
|
+
model.errors[:ancestor].should_not be_blank
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should add an error if ancestor is of a subclass" do
|
22
|
+
model.ancestor = ValidatedModelSubclass.new
|
25
23
|
model.valid?.should be_false
|
26
24
|
model.errors[:ancestor].should_not be_blank
|
27
25
|
end
|
data/vidibus-inheritance.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{vidibus-inheritance}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andre Pankratz"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-11}
|
13
13
|
s.description = %q{This gem allows inheritance of objects for Rails 3 with Mongoid. It will update all attributes and embedded documents of inheritors when ancestor gets changed.}
|
14
14
|
s.email = %q{andre@vidibus.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,8 +30,10 @@ Gem::Specification.new do |s|
|
|
30
30
|
"lib/vidibus/inheritance/mongoid.rb",
|
31
31
|
"lib/vidibus/inheritance/validators.rb",
|
32
32
|
"lib/vidibus/inheritance/validators/ancestor_validator.rb",
|
33
|
+
"spec/models.rb",
|
33
34
|
"spec/spec.opts",
|
34
35
|
"spec/spec_helper.rb",
|
36
|
+
"spec/vidibus/inheritance/inheritance_spec.rb",
|
35
37
|
"spec/vidibus/inheritance/mongoid_spec.rb",
|
36
38
|
"spec/vidibus/inheritance/validators/ancestor_validator_spec.rb",
|
37
39
|
"vidibus-inheritance.gemspec"
|
@@ -42,7 +44,9 @@ Gem::Specification.new do |s|
|
|
42
44
|
s.rubygems_version = %q{1.3.7}
|
43
45
|
s.summary = %q{Provides inheritance for models.}
|
44
46
|
s.test_files = [
|
45
|
-
"spec/
|
47
|
+
"spec/models.rb",
|
48
|
+
"spec/spec_helper.rb",
|
49
|
+
"spec/vidibus/inheritance/inheritance_spec.rb",
|
46
50
|
"spec/vidibus/inheritance/mongoid_spec.rb",
|
47
51
|
"spec/vidibus/inheritance/validators/ancestor_validator_spec.rb"
|
48
52
|
]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vidibus-inheritance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 9
|
10
|
+
version: 0.3.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andre Pankratz
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-11 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -131,8 +131,10 @@ files:
|
|
131
131
|
- lib/vidibus/inheritance/mongoid.rb
|
132
132
|
- lib/vidibus/inheritance/validators.rb
|
133
133
|
- lib/vidibus/inheritance/validators/ancestor_validator.rb
|
134
|
+
- spec/models.rb
|
134
135
|
- spec/spec.opts
|
135
136
|
- spec/spec_helper.rb
|
137
|
+
- spec/vidibus/inheritance/inheritance_spec.rb
|
136
138
|
- spec/vidibus/inheritance/mongoid_spec.rb
|
137
139
|
- spec/vidibus/inheritance/validators/ancestor_validator_spec.rb
|
138
140
|
- vidibus-inheritance.gemspec
|
@@ -171,6 +173,8 @@ signing_key:
|
|
171
173
|
specification_version: 3
|
172
174
|
summary: Provides inheritance for models.
|
173
175
|
test_files:
|
176
|
+
- spec/models.rb
|
174
177
|
- spec/spec_helper.rb
|
178
|
+
- spec/vidibus/inheritance/inheritance_spec.rb
|
175
179
|
- spec/vidibus/inheritance/mongoid_spec.rb
|
176
180
|
- spec/vidibus/inheritance/validators/ancestor_validator_spec.rb
|