edge_rider 0.3.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +28 -31
  3. data/CHANGELOG.md +18 -0
  4. data/{gemfiles/Gemfile.3.2.mysql2 → Gemfile.3.2.mysql2} +1 -1
  5. data/{gemfiles/Gemfile.3.2.mysql2.lock → Gemfile.3.2.mysql2.lock} +3 -3
  6. data/{gemfiles/Gemfile.4.2.mysql2 → Gemfile.4.2.mysql2} +1 -1
  7. data/{gemfiles/Gemfile.4.2.mysql2.lock → Gemfile.4.2.mysql2.lock} +3 -3
  8. data/{gemfiles/Gemfile.4.2.pg → Gemfile.4.2.pg} +1 -1
  9. data/{gemfiles/Gemfile.4.2.pg.lock → Gemfile.4.2.pg.lock} +3 -3
  10. data/{gemfiles/Gemfile.5.1.mysql2 → Gemfile.5.2.mysql2} +3 -2
  11. data/{gemfiles/Gemfile.5.1.mysql2.lock → Gemfile.5.2.mysql2.lock} +19 -17
  12. data/Gemfile.5.2.pg +16 -0
  13. data/{gemfiles/Gemfile.5.1.pg.lock → Gemfile.5.2.pg.lock} +19 -17
  14. data/{gemfiles/Gemfile.5.1.pg → Gemfile.6.0.pg} +2 -2
  15. data/Gemfile.6.0.pg.lock +64 -0
  16. data/README.md +21 -42
  17. data/Rakefile +1 -1
  18. data/lib/edge_rider.rb +0 -1
  19. data/lib/edge_rider/collect_column.rb +8 -15
  20. data/lib/edge_rider/origin_class.rb +2 -10
  21. data/lib/edge_rider/scoped.rb +1 -1
  22. data/lib/edge_rider/to_id_query.rb +1 -1
  23. data/lib/edge_rider/traverse_association.rb +2 -2
  24. data/lib/edge_rider/util.rb +8 -15
  25. data/lib/edge_rider/version.rb +1 -1
  26. data/spec/edge_rider/collect_column_spec.rb +21 -21
  27. data/spec/edge_rider/collect_ids_spec.rb +16 -16
  28. data/spec/edge_rider/origin_class_spec.rb +9 -9
  29. data/spec/edge_rider/preload_associations_spec.rb +3 -3
  30. data/spec/edge_rider/scoped_spec.rb +17 -19
  31. data/spec/edge_rider/to_id_query_spec.rb +12 -12
  32. data/spec/edge_rider/traverse_association_spec.rb +47 -53
  33. data/spec/support/database.rb +1 -1
  34. data/spec/support/models.rb +14 -18
  35. metadata +46 -69
  36. data/gemfiles/Gemfile.2.3.mysql2 +0 -16
  37. data/gemfiles/Gemfile.2.3.mysql2.lock +0 -37
  38. data/lib/edge_rider/to_sql.rb +0 -13
  39. data/spec/edge_rider/to_sql_spec.rb +0 -14
data/README.md CHANGED
@@ -31,13 +31,13 @@ Say we have a `Post` model and each `Post` belongs to an author:
31
31
 
32
32
  To turn a relation of posts into a relation of its authors:
33
33
 
34
- posts = Post.where(:archived => false)
34
+ posts = Post.where(archived: false)
35
35
  authors = posts.traverse_association(:author)
36
36
 
37
37
  You can traverse multiple associations in a single call.
38
38
  E.g. to turn a relation of posts into a relation of all posts of their authors:
39
39
 
40
- posts = Post.where(:archived => false)
40
+ posts = Post.where(archived: false)
41
41
  posts_by_same_authors = posts.traverse_association(:author, :posts)
42
42
 
43
43
  *Implementation note:* The traversal is achieved internally by collecting all foreign keys in the current relation
@@ -56,10 +56,10 @@ its ID.
56
56
  Edge Rider has a better way. Your relations gain a method `#collect_ids` that will
57
57
  fetch all IDs in a single query without instantiating a single ActiveRecord object:
58
58
 
59
- posts = Post.where(:archived => false)
59
+ posts = Post.where(archived: false)
60
60
  post_ids = posts.collect_ids
61
61
 
62
- *Implementation note:* In Rails 3.2+, `#collect_ids` delegates to [`#pluck`](http://apidock.com/rails/ActiveRecord/Calculations/pluck),
62
+ *Implementation note:* `#collect_ids` delegates to [`#pluck`](https://apidock.com/rails/ActiveRecord/Calculations/pluck),
63
63
  which can be used for the same purpose.
64
64
 
65
65
 
@@ -76,7 +76,7 @@ any kind of argument that can be turned into a list of IDs:
76
76
 
77
77
  For this use case Edge Rider defines `#collect_ids` on many different types:
78
78
 
79
- Post.where(:id => [1, 2]).collect_ids # => [1, 2]
79
+ Post.where(id: [1, 2]).collect_ids # => [1, 2]
80
80
  [Post.find(1), Post.find(2)].collect_ids # => [1, 2]
81
81
  Post.find(1).collect_ids # => [1]
82
82
  [1, 2, 3].collect_ids # => [1, 2, 3]
@@ -89,7 +89,7 @@ You can now write `Post.by_author` from the example above without a single `if`
89
89
  belongs_to :author
90
90
 
91
91
  def self.for_author(author_or_authors)
92
- where(:author_id => author_or_authors.collect_ids)
92
+ where(author_id: author_or_authors.collect_ids)
93
93
  end
94
94
 
95
95
  end
@@ -106,42 +106,23 @@ its column value.
106
106
  Edge Rider has a better way. Your relations gain a method `#collect_column` that will
107
107
  fetch all column values in a single query without instantiating a single ActiveRecord object:
108
108
 
109
- posts = Post.where(:archived => false)
109
+ posts = Post.where(archived: false)
110
110
  subjects = posts.collect_column(:subject)
111
111
 
112
- *Implementation note:* In Rails 3.2+, `#collect_column` delegates to [`#pluck`](http://apidock.com/rails/ActiveRecord/Calculations/pluck),
112
+ *Implementation note:* `#collect_column` delegates to [`#pluck`](https://apidock.com/rails/ActiveRecord/Calculations/pluck),
113
113
  which can be used for the same effect.
114
114
 
115
115
  #### Collect unique values in a relation's column
116
116
 
117
- If you only care about *unique* values, use the `:distinct => true` option:
117
+ If you only care about *unique* values, use the `distinct: true` option:
118
118
 
119
- posts = Post.where(:archived => false)
120
- distinct_subjects = posts.collect_column(:subject, :distinct => true)
119
+ posts = Post.where(archived: false)
120
+ distinct_subjects = posts.collect_column(:subject, distinct: true)
121
121
 
122
122
  With this options duplicates are discarded by the database before making their way into Ruby.
123
123
 
124
- *Implementation note:* In Rails 3.2+, the `:distinct` option is implemented with [`#uniq`](http://apidock.com/rails/ActiveRecord/QueryMethods/uniq)
125
- which can be used for the same effect.
126
-
127
-
128
- ### Retrieve the SQL a relation would produce
129
-
130
- Sometimes it is useful to ask a relation which SQL query it would trigger,
131
- if it was evaluated right now. For this, Edge Rider gives your relations a method
132
- `#to_sql`:
133
-
134
- # Rails 2 scope
135
- Post.scoped(:conditions => { :id => [1, 2] }).to_sql
136
- # => "SELECT `posts`.* FROM `posts` WHERE `posts.id` IN (1, 2)"
137
-
138
- # Rails 3 relation
139
- Post.where(:id => [1, 2]).to_sql
140
- # => "SELECT `posts`.* FROM `posts` WHERE `posts.id` IN (1, 2)"
141
-
142
- *Implementation note*: Rails 3+ implements `#to_sql`. Edge Rider backports this method to Rails 2 so you can use it
143
- regardless of your Rails version.
144
-
124
+ *Implementation note:* The `:distinct` option is implemented with [`#uniq`](https://apidock.com/rails/ActiveRecord/QueryMethods/uniq)
125
+ or [`#distinct`](https://apidock.com/rails/ActiveRecord/QueryMethods/distinct) which can be used for the same effect.
145
126
 
146
127
  ### Simplify a complex relation for better chainability
147
128
 
@@ -155,7 +136,7 @@ mashes together strings that mostly happen to look like a MySQL query in the end
155
136
 
156
137
  Edge Rider gives your relations a new method `#to_id_query`:
157
138
 
158
- Site.joins(:user).where(:users => { :name => 'Bruce' }).to_id_query
139
+ Site.joins(user).where(:users: { name: 'Bruce' }).to_id_query
159
140
 
160
141
  `#to_id_query` will immediately run an SQL query where it collects all the IDs that match your relation:
161
142
 
@@ -173,9 +154,9 @@ Sometimes you want to fetch associations for records that you already instantiat
173
154
  Edge Rider gives your model classes a method `.preload_associations`. The method can be used to preload associations for loaded objects like this:
174
155
 
175
156
  @user = User.find(params[:id])
176
- User.preload_associations [@user], { :threads => { :posts => :author }, :messages => :sender }
157
+ User.preload_associations [@user], { threads: { posts: :author }, messages: :sender }
177
158
 
178
- *Implementation note*: Rails 2.3 and Rails 3.0 already has a method [`.preload_associations`](http://apidock.com/rails/ActiveRecord/AssociationPreload/ClassMethods/preload_associations)
159
+ *Implementation note*: Rails 3.0 already has a method [`.preload_associations`](https://apidock.com/rails/ActiveRecord/AssociationPreload/ClassMethods/preload_associations)
179
160
  which Edge Rider merely makes public. Edge Rider ports this method forward to Rails 3.1+.
180
161
 
181
162
 
@@ -188,7 +169,7 @@ This is useful e.g. to perform unscoped record look-up.
188
169
  Post.recent.origin_class
189
170
  # => Post
190
171
 
191
- Note that `#origin_class` it roughly equivalent to the blockless form of [`unscoped`](http://apidock.com/rails/ActiveRecord/Scoping/Default/ClassMethods/unscoped) from Rails 3.2+,
172
+ Note that `#origin_class` it roughly equivalent to the blockless form of [`unscoped`](https://apidock.com/rails/ActiveRecord/Scoping/Default/ClassMethods/unscoped) from Rails 3.2+,
192
173
  but it works consistently across all Rails versions.
193
174
 
194
175
 
@@ -202,8 +183,8 @@ across all versions of Rails.
202
183
  User.scoped # just calls User.all in Rails 4
203
184
  User.active.scoped(conditions: { admin: true })
204
185
 
205
- *Implementation note*: Rails 2 and 3 already have a method
206
- [`.scoped`](http://apidock.com/rails/ActiveRecord/Scoping/Named/ClassMethods/scoped) which Edge Rider does not touch. Rails 4 has removed this method and
186
+ *Implementation note*: Rails 3 already have a method
187
+ [`.scoped`](https://apidock.com/rails/ActiveRecord/Scoping/Named/ClassMethods/scoped) which Edge Rider does not touch. Rails 4 has removed this method and
207
188
  splits its functionality into the query methods known from Rails 3 (`.where`,
208
189
  `.order` etc.) and an `.all` method that just returns a scope.
209
190
 
@@ -227,10 +208,10 @@ Development
227
208
  -----------
228
209
 
229
210
  - There are tests in `spec`. We only accept PRs with tests.
230
- - We currently develop using Ruby 2.2.4 (see `.ruby-version`) since that version works for all versions of ActiveRecord that we support. Travis CI will test additional Ruby versions (2.1.8 and 2.3.1).
211
+ - We currently develop using the Ruby version in `.ruby-version`. It is required to change the Ruby Version to cover all Rails version or just use Travis CI.
231
212
  - Put your database credentials into `spec/support/database.yml`. There's a `database.sample.yml` you can use as a template.
232
213
  - Create a database `edge_rider_test` in both MySQL and PostgreSQL.
233
- - There are gem bundles in `gemfiles` for each combination of ActiveRecord version and database type that we support.
214
+ - There are gem bundles in the project root for each combination of ActiveRecord version and database type that we support.
234
215
  - You can bundle all test applications by saying `bundle exec rake matrix:install`
235
216
  - You can run specs from the project root by saying `bundle exec rake matrix:spec`. This will run all gemfiles compatible with your current Ruby.
236
217
 
@@ -245,5 +226,3 @@ Credits
245
226
  -------
246
227
 
247
228
  Henning Koch from [makandra](http://makandra.com/)
248
-
249
-
data/Rakefile CHANGED
@@ -7,4 +7,4 @@ rescue LoadError
7
7
  puts 'Run `gem install gemika` for additional tasks'
8
8
  end
9
9
 
10
- task :default => 'matrix:spec'
10
+ task default: 'matrix:spec'
@@ -12,4 +12,3 @@ require 'edge_rider/origin_class'
12
12
  require 'edge_rider/scoped'
13
13
  require 'edge_rider/traverse_association'
14
14
  require 'edge_rider/to_id_query'
15
- require 'edge_rider/to_sql'
@@ -4,23 +4,16 @@ module EdgeRider
4
4
  def collect_column(column_name, find_options = {})
5
5
  distinct = find_options.delete(:distinct)
6
6
  qualified_column_name = EdgeRider::Util.qualify_column_name(self, column_name)
7
- if respond_to?(:pluck) # Rails 3.2+
8
- scope = scoped({})
9
- if distinct
10
- if ActiveRecord::VERSION::MAJOR < 5
11
- scope = scope.uniq
12
- else
13
- scope = scope.distinct
14
- end
7
+
8
+ scope = scoped({})
9
+ if distinct
10
+ if ActiveRecord::VERSION::MAJOR < 5
11
+ scope = scope.uniq
12
+ else
13
+ scope = scope.distinct
15
14
  end
16
- scope.pluck(qualified_column_name)
17
- else # Rails 2
18
- select = distinct ? "DISTINCT #{qualified_column_name}" : qualified_column_name
19
- query = scoped(find_options.merge(:select => select)).to_sql
20
- raw_values = connection.select_values(query)
21
- column = columns_hash[column_name.to_s] or raise "Could not retrieve column information: #{column_name}"
22
- raw_values.collect { |value| column.type_cast(value) }
23
15
  end
16
+ scope.pluck(qualified_column_name)
24
17
  end
25
18
 
26
19
  ActiveRecord::Base.extend(self)
@@ -3,16 +3,8 @@ module EdgeRider
3
3
 
4
4
  def origin_class
5
5
  scope = scoped({})
6
- if Util.activerecord2?
7
- # Rails 2
8
- while scope.respond_to?(:proxy_scope, true)
9
- scope = scope.proxy_scope
10
- end
11
- else
12
- # Rails 3
13
- while scope.respond_to?(:klass, true)
14
- scope = scope.klass
15
- end
6
+ while scope.respond_to?(:klass, true)
7
+ scope = scope.klass
16
8
  end
17
9
  scope
18
10
  end
@@ -3,7 +3,7 @@ module EdgeRider
3
3
 
4
4
  VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset,
5
5
  :order, :select, :readonly, :group, :having, :from, :lock ]
6
-
6
+
7
7
  def scoped(options = nil)
8
8
  options ||= {}
9
9
  relation = all
@@ -3,7 +3,7 @@ module EdgeRider
3
3
 
4
4
  def to_id_query
5
5
  ids = collect_ids
6
- EdgeRider::Util.exclusive_query(self, :id => ids)
6
+ EdgeRider::Util.exclusive_query(self, id: ids)
7
7
  end
8
8
 
9
9
  ActiveRecord::Base.send(:extend, self)
@@ -18,8 +18,8 @@ module EdgeRider
18
18
  raise NotImplementedError if reflection.options[:conditions] or (reflection.respond_to?(:scope) && reflection.scope)
19
19
 
20
20
  if reflection.macro == :belongs_to # belongs_to
21
- ids = scope.collect_column(foreign_key, :distinct => true)
22
- scope = EdgeRider::Util.exclusive_query(reflection.klass, :id => ids)
21
+ ids = scope.collect_column(foreign_key, distinct: true)
22
+ scope = EdgeRider::Util.exclusive_query(reflection.klass, id: ids)
23
23
  elsif reflection.macro == :has_many || reflection.macro == :has_one
24
24
  if reflection.through_reflection # has_many :through
25
25
  scope = scope.traverse_association(reflection.through_reflection.name, reflection.source_reflection.name)
@@ -21,13 +21,7 @@ module EdgeRider
21
21
  end
22
22
 
23
23
  def exclusive_query(model, conditions)
24
- if activerecord2?
25
- model.send(:with_exclusive_scope) do
26
- model.scoped(:conditions => conditions)
27
- end
28
- else
29
- model.unscoped.where(conditions)
30
- end
24
+ model.unscoped.where(conditions)
31
25
  end
32
26
 
33
27
  def scope?(object)
@@ -35,13 +29,16 @@ module EdgeRider
35
29
  end
36
30
 
37
31
  def define_scope(klass, name, lambda)
38
- if ActiveRecord::VERSION::MAJOR < 4 # Rails 2/3
39
- scope_definition = ActiveRecord::VERSION::MAJOR < 3 ? :named_scope : :scope
40
- klass.send scope_definition, name, lambda
32
+ if ActiveRecord::VERSION::MAJOR == 3
33
+ klass.send :scope, name, lambda
41
34
  else
42
35
  klass.send :scope, name, lambda { |*args|
43
36
  options = lambda.call(*args)
44
- klass.scoped(options.slice :conditions)
37
+ if ActiveRecord::VERSION::MAJOR < 6
38
+ klass.scoped(options.slice :conditions)
39
+ else
40
+ scoped(options.slice :conditions)
41
+ end
45
42
  }
46
43
  end
47
44
  end
@@ -63,10 +60,6 @@ module EdgeRider
63
60
  ActiveRecord::VERSION::MAJOR
64
61
  end
65
62
 
66
- def activerecord2?
67
- active_record_version < 3
68
- end
69
-
70
63
  def rspec_version
71
64
  if defined?(Spec)
72
65
  1
@@ -1,3 +1,3 @@
1
1
  module EdgeRider
2
- VERSION = '0.3.3'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -5,16 +5,16 @@ describe EdgeRider::CollectColumn do
5
5
  describe '#collect_column' do
6
6
 
7
7
  it 'should collect the given value from a scope' do
8
- Forum.create!(:id => 1, :name => 'Name 1')
9
- Forum.create!(:id => 2, :name => 'Name 2')
10
- Forum.create!(:id => 3, :name => 'Name 3')
11
- scope = Forum.scoped(:conditions => { :id => [2, 3] })
8
+ Forum.create!(id: 1, name: 'Name 1')
9
+ Forum.create!(id: 2, name: 'Name 2')
10
+ Forum.create!(id: 3, name: 'Name 3')
11
+ scope = Forum.scoped(conditions: { id: [2, 3] })
12
12
  scope.collect_column(:name).should =~ ['Name 2', 'Name 3']
13
13
  end
14
14
 
15
15
  it 'should collect the given value from an ActiveRecord class' do
16
- Forum.create!(:id => 1, :name => 'Name 1')
17
- Forum.create!(:id => 2, :name => 'Name 2')
16
+ Forum.create!(id: 1, name: 'Name 1')
17
+ Forum.create!(id: 2, name: 'Name 2')
18
18
  Forum.collect_column(:name).should =~ ['Name 1', 'Name 2']
19
19
  end
20
20
 
@@ -24,23 +24,23 @@ describe EdgeRider::CollectColumn do
24
24
  end
25
25
 
26
26
  it 'should not instantiate ActiveRecord objects when collecting values' do
27
- Forum.create!(:name => 'Name')
27
+ Forum.create!(name: 'Name')
28
28
  Forum.should_not_receive(:new)
29
29
  Forum.collect_column(:name).should == ['Name']
30
30
  end
31
31
 
32
32
  it 'should qualify the column name to resolve any ambiguities' do
33
- expect { Topic.scoped(:joins => :forum).collect_column(:id) }.to_not raise_error
33
+ expect { Topic.scoped(joins: :forum).collect_column(:id) }.to_not raise_error
34
34
  end
35
35
 
36
36
  context 'with :distinct option' do
37
37
 
38
38
  it 'should return unique values' do
39
- Forum.create!(:id => 1, :name => 'Name 1')
40
- Forum.create!(:id => 2, :name => 'Name 2')
41
- Forum.create!(:id => 3, :name => 'Name 2')
42
- scope = Forum.scoped(:conditions => { :id => [2, 3] })
43
- scope.collect_column(:name, :distinct => true).should =~ ['Name 2']
39
+ Forum.create!(id: 1, name: 'Name 1')
40
+ Forum.create!(id: 2, name: 'Name 2')
41
+ Forum.create!(id: 3, name: 'Name 2')
42
+ scope = Forum.scoped(conditions: { id: [2, 3] })
43
+ scope.collect_column(:name, distinct: true).should =~ ['Name 2']
44
44
  end
45
45
 
46
46
  end
@@ -49,8 +49,8 @@ describe EdgeRider::CollectColumn do
49
49
 
50
50
  it 'should collect the given value' do
51
51
  topic = Topic.create!
52
- post = Post.create!(:topic => topic, :id => 1)
53
- post = Post.create!(:topic => topic, :id => 2)
52
+ post = Post.create!(topic: topic, id: 1)
53
+ post = Post.create!(topic: topic, id: 2)
54
54
  topic.reload
55
55
  topic.posts.to_a
56
56
  topic.posts.collect_column(:id).should =~ [1,2]
@@ -58,21 +58,21 @@ describe EdgeRider::CollectColumn do
58
58
 
59
59
  it 'should return values when further restricted with an anonymous scope' do
60
60
  topic = Topic.create!
61
- post = Post.create!(:topic => topic, :id => 1)
62
- post = Post.create!(:topic => topic, :id => 2)
61
+ post = Post.create!(topic: topic, id: 1)
62
+ post = Post.create!(topic: topic, id: 2)
63
63
  topic.reload
64
64
  topic.posts.to_a
65
65
  if topic.posts.respond_to?(:where)
66
- topic.posts.where(:id => [1]).collect_ids.should =~ [1]
66
+ topic.posts.where(id: [1]).collect_ids.should =~ [1]
67
67
  else
68
- topic.posts.scoped(:conditions => {:id => [1]}).collect_column(:id).should =~ [1]
68
+ topic.posts.scoped(conditions: {id: [1]}).collect_column(:id).should =~ [1]
69
69
  end
70
70
  end
71
71
 
72
72
  it 'should return values when further restricted with a named scope' do
73
73
  topic = Topic.create!
74
- post = Post.create!(:topic => topic, :id => 1)
75
- post = Post.create!(:topic => topic, :id => 2)
74
+ post = Post.create!(topic: topic, id: 1)
75
+ post = Post.create!(topic: topic, id: 2)
76
76
  topic.reload
77
77
  topic.posts.to_a
78
78
  topic.posts.these([1]).collect_column(:id).should =~ [1]
@@ -7,8 +7,8 @@ describe EdgeRider::CollectIds do
7
7
  context 'when called on an ActiveRecord class' do
8
8
 
9
9
  it 'should return the ids for all records of that class' do
10
- Forum.create!(:id => 1)
11
- Forum.create!(:id => 2)
10
+ Forum.create!(id: 1)
11
+ Forum.create!(id: 2)
12
12
  Forum.collect_ids.should =~ [1, 2]
13
13
  end
14
14
 
@@ -17,10 +17,10 @@ describe EdgeRider::CollectIds do
17
17
  context 'when called on a scope' do
18
18
 
19
19
  it 'should return the ids for all records matching that scope' do
20
- Forum.create!(:id => 1, :name => 'Name 1')
21
- Forum.create!(:id => 2, :name => 'Name 2')
22
- Forum.create!(:id => 3, :name => 'Name 2')
23
- scope = Forum.scoped(:conditions => { :name => 'Name 2' })
20
+ Forum.create!(id: 1, name: 'Name 1')
21
+ Forum.create!(id: 2, name: 'Name 2')
22
+ Forum.create!(id: 3, name: 'Name 2')
23
+ scope = Forum.scoped(conditions: { name: 'Name 2' })
24
24
  scope.collect_ids.should =~ [2, 3]
25
25
  end
26
26
 
@@ -53,8 +53,8 @@ describe EdgeRider::CollectIds do
53
53
  context 'when called on an array of ActiveRecords' do
54
54
 
55
55
  it 'should return the ids collected from that list' do
56
- forum_1 = Forum.create!(:id => 1)
57
- forum_2 = Forum.create!(:id => 2)
56
+ forum_1 = Forum.create!(id: 1)
57
+ forum_2 = Forum.create!(id: 2)
58
58
  [forum_1, forum_2].collect_ids.should =~ [1, 2]
59
59
  end
60
60
 
@@ -72,8 +72,8 @@ describe EdgeRider::CollectIds do
72
72
 
73
73
  it 'should return the ids' do
74
74
  topic = Topic.create!
75
- post = Post.create!(:topic => topic, :id => 1)
76
- post = Post.create!(:topic => topic, :id => 2)
75
+ post = Post.create!(topic: topic, id: 1)
76
+ post = Post.create!(topic: topic, id: 2)
77
77
  topic.reload
78
78
  topic.posts.to_a
79
79
  topic.posts.collect_ids.should =~ [1,2]
@@ -81,21 +81,21 @@ describe EdgeRider::CollectIds do
81
81
 
82
82
  it 'should return ids when further restricted with an anonymous scope' do
83
83
  topic = Topic.create!
84
- post = Post.create!(:topic => topic, :id => 1)
85
- post = Post.create!(:topic => topic, :id => 2)
84
+ post = Post.create!(topic: topic, id: 1)
85
+ post = Post.create!(topic: topic, id: 2)
86
86
  topic.reload
87
87
  topic.posts.to_a
88
88
  if topic.posts.respond_to?(:where)
89
- topic.posts.where(:id => [1]).collect_ids.should =~ [1]
89
+ topic.posts.where(id: [1]).collect_ids.should =~ [1]
90
90
  else
91
- topic.posts.scoped(:conditions => {:id => [1]}).collect_ids.should =~ [1]
91
+ topic.posts.scoped(conditions: {id: [1]}).collect_ids.should =~ [1]
92
92
  end
93
93
  end
94
94
 
95
95
  it 'should return ids when further restricted with a named scope' do
96
96
  topic = Topic.create!
97
- post = Post.create!(:topic => topic, :id => 1)
98
- post = Post.create!(:topic => topic, :id => 2)
97
+ post = Post.create!(topic: topic, id: 1)
98
+ post = Post.create!(topic: topic, id: 2)
99
99
  topic.reload
100
100
  topic.posts.to_a
101
101
  topic.posts.these([1]).collect_ids.should =~ [1]