somehow_has_relation 0.0.1 → 0.0.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.
@@ -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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
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 00:00:00 +01:00
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