somehow_has_relation 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +82 -0
- data/lib/somehow_has_relation/version.rb +1 -1
- data/lib/somehow_has_relation.rb +3 -1
- data/test/dummy2/log/test.log +1155 -0
- data/test/somehow_has_relation_test.rb +13 -0
- metadata +6 -4
@@ -111,4 +111,17 @@ class SomehowHasRelationTest < ActiveSupport::TestCase
|
|
111
111
|
Bio.somehow_has :one => :author, :if => Proc.new{|author| author.created_at <= 10.years.ago}
|
112
112
|
assert_nil @bio.related_author
|
113
113
|
end
|
114
|
+
|
115
|
+
test "multiple somehow_has methods should define multiple recursive relations" do
|
116
|
+
comments1, comments2 = [Comment.create, Comment.create], [Comment.create, Comment.create]
|
117
|
+
bio = Bio.create(:comments => comments1)
|
118
|
+
@author = Author.create(:posts => [Post.create(:comments => comments2)], :bio => bio)
|
119
|
+
|
120
|
+
Author.somehow_has :one => :bio
|
121
|
+
Author.somehow_has :many => :comments, :through => :bio, :as => :related_bio_comments
|
122
|
+
Author.somehow_has :many => :comments, :through => :posts, :as => :related_posts_comments
|
123
|
+
assert_equal bio, @author.related_bio
|
124
|
+
assert_equal comments1, @author.related_bio_comments
|
125
|
+
assert_equal comments2, @author.related_posts_comments
|
126
|
+
end
|
114
127
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: somehow_has_relation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matteo Latini
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-21 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -32,6 +32,8 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- .gitignore
|
34
34
|
- Gemfile
|
35
|
+
- LICENSE
|
36
|
+
- README.rdoc
|
35
37
|
- Rakefile
|
36
38
|
- lib/somehow_has_relation.rb
|
37
39
|
- lib/somehow_has_relation/version.rb
|