edge_rider 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8ed3b13a9ec04ce5b38b0ee4de01b59db38db014
4
+ data.tar.gz: 1e2068497c3ac2be587f132e9d3dcb32acf28b5b
5
+ SHA512:
6
+ metadata.gz: b9fa666dda10ba72f454dbb6f6799f55922a1a8b7942eb93e1b5b7cfde6a48680fbf6b145b2aece148afa8a5ae9cd3ab8c95c798e1625e329d6165a421793026
7
+ data.tar.gz: d933ccb1317493550e3293e7ac47cd4e787e8257be9c4c7465d245c2f5096f28c9df779198298be02b74dfb9af2259ba861cee7af779ae79c2baee677b71099f
@@ -38,6 +38,8 @@ module EdgeRider
38
38
  end
39
39
 
40
40
  ::ActiveRecord::Base.send(:extend, ActiveRecordScope)
41
+ ::ActiveRecord::Associations::HasManyAssociation.send(:include, ActiveRecordScope)
42
+ ::ActiveRecord::Associations::HasManyThroughAssociation.send(:include, ActiveRecordScope)
41
43
 
42
44
  module Fixnum
43
45
 
@@ -1,3 +1,3 @@
1
1
  module EdgeRider
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- edge_rider (0.2.2)
4
+ edge_rider (0.2.4)
5
5
  activerecord
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- edge_rider (0.2.2)
4
+ edge_rider (0.2.4)
5
5
  activerecord
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- edge_rider (0.2.2)
4
+ edge_rider (0.2.4)
5
5
  activerecord
6
6
 
7
7
  GEM
@@ -6,4 +6,10 @@ class Post < ActiveRecord::Base
6
6
 
7
7
  has_defaults :trashed => false
8
8
 
9
+ if respond_to?(:named_scope)
10
+ named_scope :these, lambda { |array| { :conditions => { :id => array } } }
11
+ else
12
+ scope :these, lambda { |array| { :conditions => { :id => array } } }
13
+ end
14
+
9
15
  end
@@ -68,6 +68,41 @@ describe EdgeRider::CollectIds do
68
68
 
69
69
  end
70
70
 
71
+ context 'when called on a has many association' do
72
+
73
+ it 'should return the ids' do
74
+ topic = Topic.create!
75
+ post = Post.create!(:topic => topic, :id => 1)
76
+ post = Post.create!(:topic => topic, :id => 2)
77
+ topic.reload
78
+ topic.posts.to_a
79
+ topic.posts.collect_ids.should =~ [1,2]
80
+ end
81
+
82
+ it 'should return ids when further restricted with an anonymous scope' do
83
+ topic = Topic.create!
84
+ post = Post.create!(:topic => topic, :id => 1)
85
+ post = Post.create!(:topic => topic, :id => 2)
86
+ topic.reload
87
+ topic.posts.to_a
88
+ if topic.posts.respond_to?(:where)
89
+ topic.posts.where(:id => [1]).collect_ids.should =~ [1]
90
+ else
91
+ topic.posts.scoped(:conditions => {:id => [1]}).collect_ids.should =~ [1]
92
+ end
93
+ end
94
+
95
+ it 'should return ids when further restricted with a named scope' do
96
+ topic = Topic.create!
97
+ post = Post.create!(:topic => topic, :id => 1)
98
+ post = Post.create!(:topic => topic, :id => 2)
99
+ topic.reload
100
+ topic.posts.to_a
101
+ topic.posts.these([1]).collect_ids.should =~ [1]
102
+ end
103
+
104
+ end
105
+
71
106
  end
72
107
 
73
108
  end
metadata CHANGED
@@ -1,46 +1,35 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: edge_rider
3
- version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 3
10
- version: 0.2.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.4
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Henning Koch
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-09-17 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: activerecord
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
33
20
  type: :runtime
34
- version_requirements: *id001
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
35
27
  description: Power tools for ActiveRecord relations (scopes)
36
28
  email: henning.koch@makandra.de
37
29
  executables: []
38
-
39
30
  extensions: []
40
-
41
31
  extra_rdoc_files: []
42
-
43
- files:
32
+ files:
44
33
  - .gitignore
45
34
  - .rvmrc
46
35
  - .travis.yml
@@ -126,39 +115,28 @@ files:
126
115
  - spec/shared/spec/edge_rider/to_sql_spec.rb
127
116
  - spec/shared/spec/edge_rider/traverse_association_spec.rb
128
117
  - spec/shared/spec/edge_rider/util_spec.rb
129
- has_rdoc: true
130
118
  homepage: https://github.com/makandra/edge_rider
131
- licenses:
119
+ licenses:
132
120
  - MIT
121
+ metadata: {}
133
122
  post_install_message:
134
123
  rdoc_options: []
135
-
136
- require_paths:
124
+ require_paths:
137
125
  - lib
138
- required_ruby_version: !ruby/object:Gem::Requirement
139
- none: false
140
- requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- hash: 3
144
- segments:
145
- - 0
146
- version: "0"
147
- required_rubygems_version: !ruby/object:Gem::Requirement
148
- none: false
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- hash: 3
153
- segments:
154
- - 0
155
- version: "0"
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
156
136
  requirements: []
157
-
158
137
  rubyforge_project:
159
- rubygems_version: 1.3.9.5
138
+ rubygems_version: 2.2.1
160
139
  signing_key:
161
- specification_version: 3
140
+ specification_version: 4
162
141
  summary: Power tools for ActiveRecord relations (scopes)
163
142
  test_files: []
164
-