Skip to content

Commit fcfe8a3

Browse files
committed
Minor documentation mods, remove some defunct tests, restore filtering of polymorphic assocs pending further testing
1 parent 68296e6 commit fcfe8a3

File tree

8 files changed

+16
-39
lines changed

8 files changed

+16
-39
lines changed

README.textile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ h4. As a Gem
7272

7373
h2. Stability
7474

75-
The whole ActiveRecord test suite passes with scrooge, except for 9 failures related to callsite augmentation (note the SQL reload snippets below).Thoughts on handling or circumventing this much appreciated.
75+
The whole Rails 2.3.2 ActiveRecord test suite passes with scrooge, except for 13 failures related to callsite augmentation (note the SQL reload snippets below). Thoughts on handling or circumventing this much appreciated.
7676

7777
<pre>
7878
<code>
@@ -203,7 +203,7 @@ on subsequent requests :
203203

204204
h4. How it tracks
205205

206-
The ActiveRecord attributes Hash is replaced with a proxy that automatically augments the callsite with any attributes referenced through the Hash lookup keys.We're also able to learn which associations is invoked from a given callsite, for preloading on subsequent requests.
206+
The ActiveRecord attributes Hash is replaced with a proxy that automatically augments the callsite with any attributes referenced through the Hash lookup keys. We're also able to learn which associations is invoked from a given callsite, for preloading on subsequent requests.
207207

208208
h4. Storage
209209

@@ -221,12 +221,14 @@ The tracking and scoping phases is superseded by this implementation - none of t
221221

222222
h2. Todo
223223

224-
* Deeper coverage for Scrooge::AttributesProxy ( pending conversion to a subclass of Hash instead )
224+
* Deeper coverage for Scrooge::AttributesProxy, possible handling of replace
225225

226-
* Test cases for Scrooge::Callsite
226+
* More test cases for Scrooge::Callsite
227227

228228
* Have invoking Model#attributes not associate all columns with the callsite
229229

230230
* Avoid possible missing attribute exceptions for destroyed objects
231231

232+
* Track rows of result set to allow more targeted loading of associations for a callsite
233+
232234
(c) 2009 Lourens Naudé (methodmissing) and Stephen Sykes (sdsykes)

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ begin
2626
Jeweler::Tasks.new do |s|
2727
s.name = "scrooge"
2828
s.summary = "Scrooge - Fetch exactly what you need"
29-
s.email = "[email protected] or sds@switchstep.com"
29+
s.email = "[email protected] or sdsykes@gmail.com"
3030
s.homepage = "http://github.com/methodmissing/scrooge"
3131
s.description = "An ActiveRecord attribute tracker to ensure production
3232
Ruby applications only fetch the database content needed to minimize wire traffic

lib/optimizations/associations/macro.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def scrooge_preloading_exclude
5151
#
5252
def preloadable_associations
5353
@@preloadable_associations[self.name] ||=
54-
reflect_on_all_associations.reject{|a| a.options[:xxxpolymorphic] || a.macro == :xxxhas_many}.map(&:name)
54+
reflect_on_all_associations.reject{|a| a.options[:polymorphic] || a.macro == :has_many}.map(&:name)
5555
end
5656

5757
end

lib/optimizations/columns/macro.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def scrooge_reload( p_keys, missing_columns )
6060
end
6161

6262
# Only scope n-1 rows by default.
63-
# Stephen: Temp. relaxed the LIMIT constraint - please advise.
63+
#
6464
def scope_with_scrooge?( sql )
6565
sql =~ scrooge_select_regex &&
6666
column_names.include?(self.primary_key.to_s) &&

test/callsite_test.rb

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,7 @@ def setup
1515
Scrooge::Callsite.any_instance.stubs(:inheritance_column).returns("inheritance")
1616
assert_equal Scrooge::Callsite.new( MysqlUser, 123456 ).columns, Set["User","inheritance"]
1717
end
18-
19-
test "should be able to return all augmented columns" do
20-
assert_equal @callsite.augmented_columns, Set.new
21-
@callsite.column! :Db
22-
assert_equal @callsite.augmented_columns, Set[:Db]
23-
end
24-
25-
test "should be able to determine if any columns has been augmented" do
26-
assert !@callsite.augmented_columns?
27-
@callsite.column! :Db
28-
assert @callsite.augmented_columns?
29-
end
30-
18+
3119
test "should be inspectable" do
3220
@callsite.association! :mysql_user
3321
@callsite.column! :db
@@ -49,14 +37,5 @@ def setup
4937
@callsite.association! :mysql_user
5038
end
5139
end
52-
53-
test "should be able to overload given association preload options" do
54-
assert_equal @callsite.preload( { :nested => :include } ), { :nested => :include }
55-
assert_equal @callsite.preload( [:column_privilege] ), [:column_privilege]
56-
@callsite.association! :column_privilege
57-
@callsite.association! :mysql_user
58-
assert_equal @callsite.preload( nil ).sort_by(&:to_s), [:column_privilege, :mysql_user].sort_by(&:to_s)
59-
end
60-
61-
40+
6241
end

test/optimizations/associations/macro_test.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44

55
class OptimizationsAssociationsMacroTest < ActiveSupport::TestCase
66

7-
test "should flag a record as being scrooged when found through a supported SQL query" do
8-
assert MysqlUser.find(:first).scrooged?
9-
end
10-
11-
test "should always flag records via Model.find with a custom :select requirement as scrooged" do
12-
assert MysqlUser.find(:first, :select => 'user.Password' ).scrooged?
13-
end
14-
157
test "should be able to flag any associations instantiated from a record" do
168
@user = MysqlUser.find(:first)
179
@user.host

test/scrooge_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class ScroogeTest < ActiveSupport::TestCase
3939
assert MysqlUser.find(:first).scrooged?
4040
assert_instance_of Scrooge::Callsite, MysqlUser.scrooge_callsite( first_callsite )
4141
end
42+
43+
test "should not flag records via Model.find with a custom :select requirement as scrooged" do
44+
assert !MysqlUser.find(:first, :select => 'user.Password' ).scrooged?
45+
end
4246

4347
test "should be able to augment an existing callsite with attributes" do
4448
MysqlUser.find(:first)

test/setup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
require 'rubygems'
22
require 'activerecord'
3-
require File.join( File.dirname(__FILE__), '..', 'lib', 'scrooge' )
3+
require File.join( File.dirname(__FILE__), '..', 'lib', 'scrooge' )

0 commit comments

Comments
 (0)