mongoa 0.2.1 → 0.2.2
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 +1 -1
- data/lib/mongoa/mongo_mapper/associations/all.rb +2 -1
- data/mongoa.gemspec +2 -2
- data/spec/assoications/all_spec.rb +16 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -82,12 +82,13 @@ module Mongoa
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def belongs_to_foreign_key_exists?
|
85
|
-
foreign_key = model_class.keys["#{
|
85
|
+
foreign_key = model_class.keys["#{association.name}_id"]
|
86
86
|
foreign_key && foreign_key.type
|
87
87
|
end
|
88
88
|
|
89
89
|
def reflection_name
|
90
90
|
@reflection ||= association.class_name.underscore
|
91
|
+
@reflection
|
91
92
|
end
|
92
93
|
|
93
94
|
def find_association(model_class, name)
|
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.2"
|
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{2010-10-
|
12
|
+
s.date = %q{2010-10-22}
|
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 = [
|
@@ -22,6 +22,14 @@ class Comment
|
|
22
22
|
belongs_to :post
|
23
23
|
end
|
24
24
|
|
25
|
+
class CommentWPostOfADifferentName
|
26
|
+
include MongoMapper::Document
|
27
|
+
key :description, String
|
28
|
+
key :article_id, ObjectId
|
29
|
+
|
30
|
+
belongs_to :article, :class_name => "Post"
|
31
|
+
end
|
32
|
+
|
25
33
|
class EmbeddedComment
|
26
34
|
include MongoMapper::EmbeddedDocument
|
27
35
|
key :description, String
|
@@ -86,6 +94,13 @@ describe Mongoa::MongoMapper do
|
|
86
94
|
matcher = Mongoa::MongoMapper::MongoAssociationMatcher.new(:belongs_to, :post)
|
87
95
|
matcher.should_not be_matches(CommentWOutFKAddedDynamicallyOnCreate.new)
|
88
96
|
end
|
97
|
+
|
98
|
+
it "should handle when the class name cannot be inferred by the association name" do
|
99
|
+
post = Post.create(:name => "my post")
|
100
|
+
CommentWPostOfADifferentName.create(:description => "hello", :article => post)
|
101
|
+
matcher = Mongoa::MongoMapper::MongoAssociationMatcher.new(:belongs_to, :article)
|
102
|
+
matcher.should be_matches(CommentWPostOfADifferentName.new)
|
103
|
+
end
|
89
104
|
end
|
90
105
|
|
91
106
|
describe "embedded" do
|
@@ -123,5 +138,5 @@ describe Mongoa::MongoMapper do
|
|
123
138
|
matcher = Mongoa::MongoMapper::MongoAssociationMatcher.new(:has_one, :office)
|
124
139
|
matcher.should_not be_matches(EmployeeWOutHO.new)
|
125
140
|
end
|
126
|
-
|
141
|
+
end
|
127
142
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Scott J. Tamosunas
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-22 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|