Permalink
Browse files

Minor documentation mods, remove some defunct tests, restore filterin…

…g of polymorphic assocs pending further testing
  • Loading branch information...
1 parent 68296e6 commit fcfe8a37413dd1f91a8a1cdd34702c832185a5a4 @sdsykes sdsykes committed Mar 22, 2009
View
@@ -72,7 +72,7 @@ h4. As a Gem
h2. Stability
-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.
+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.
<pre>
<code>
@@ -203,7 +203,7 @@ on subsequent requests :
h4. How it tracks
-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.
+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.
h4. Storage
@@ -221,12 +221,14 @@ The tracking and scoping phases is superseded by this implementation - none of t
h2. Todo
-* Deeper coverage for Scrooge::AttributesProxy ( pending conversion to a subclass of Hash instead )
+* Deeper coverage for Scrooge::AttributesProxy, possible handling of replace
-* Test cases for Scrooge::Callsite
+* More test cases for Scrooge::Callsite
* Have invoking Model#attributes not associate all columns with the callsite
* Avoid possible missing attribute exceptions for destroyed objects
+* Track rows of result set to allow more targeted loading of associations for a callsite
+
(c) 2009 Lourens Naudé (methodmissing) and Stephen Sykes (sdsykes)
View
@@ -26,7 +26,7 @@ begin
Jeweler::Tasks.new do |s|
s.name = "scrooge"
s.summary = "Scrooge - Fetch exactly what you need"
- s.email = "lourens@methodmissing.com or sds@switchstep.com"
+ s.email = "lourens@methodmissing.com or sdsykes@gmail.com"
s.homepage = "http://github.com/methodmissing/scrooge"
s.description = "An ActiveRecord attribute tracker to ensure production
Ruby applications only fetch the database content needed to minimize wire traffic
@@ -51,7 +51,7 @@ def scrooge_preloading_exclude
#
def preloadable_associations
@@preloadable_associations[self.name] ||=
- reflect_on_all_associations.reject{|a| a.options[:xxxpolymorphic] || a.macro == :xxxhas_many}.map(&:name)
+ reflect_on_all_associations.reject{|a| a.options[:polymorphic] || a.macro == :has_many}.map(&:name)
end
end
@@ -60,7 +60,7 @@ def scrooge_reload( p_keys, missing_columns )
end
# Only scope n-1 rows by default.
- # Stephen: Temp. relaxed the LIMIT constraint - please advise.
+ #
def scope_with_scrooge?( sql )
sql =~ scrooge_select_regex &&
column_names.include?(self.primary_key.to_s) &&
View
@@ -15,19 +15,7 @@ def setup
Scrooge::Callsite.any_instance.stubs(:inheritance_column).returns("inheritance")
assert_equal Scrooge::Callsite.new( MysqlUser, 123456 ).columns, Set["User","inheritance"]
end
-
- test "should be able to return all augmented columns" do
- assert_equal @callsite.augmented_columns, Set.new
- @callsite.column! :Db
- assert_equal @callsite.augmented_columns, Set[:Db]
- end
-
- test "should be able to determine if any columns has been augmented" do
- assert !@callsite.augmented_columns?
- @callsite.column! :Db
- assert @callsite.augmented_columns?
- end
-
+
test "should be inspectable" do
@callsite.association! :mysql_user
@callsite.column! :db
@@ -49,14 +37,5 @@ def setup
@callsite.association! :mysql_user
end
end
-
- test "should be able to overload given association preload options" do
- assert_equal @callsite.preload( { :nested => :include } ), { :nested => :include }
- assert_equal @callsite.preload( [:column_privilege] ), [:column_privilege]
- @callsite.association! :column_privilege
- @callsite.association! :mysql_user
- assert_equal @callsite.preload( nil ).sort_by(&:to_s), [:column_privilege, :mysql_user].sort_by(&:to_s)
- end
-
-
+
end
@@ -4,14 +4,6 @@
class OptimizationsAssociationsMacroTest < ActiveSupport::TestCase
- test "should flag a record as being scrooged when found through a supported SQL query" do
- assert MysqlUser.find(:first).scrooged?
- end
-
- test "should always flag records via Model.find with a custom :select requirement as scrooged" do
- assert MysqlUser.find(:first, :select => 'user.Password' ).scrooged?
- end
-
test "should be able to flag any associations instantiated from a record" do
@user = MysqlUser.find(:first)
@user.host
View
@@ -39,6 +39,10 @@ class ScroogeTest < ActiveSupport::TestCase
assert MysqlUser.find(:first).scrooged?
assert_instance_of Scrooge::Callsite, MysqlUser.scrooge_callsite( first_callsite )
end
+
+ test "should not flag records via Model.find with a custom :select requirement as scrooged" do
+ assert !MysqlUser.find(:first, :select => 'user.Password' ).scrooged?
+ end
test "should be able to augment an existing callsite with attributes" do
MysqlUser.find(:first)
View
@@ -1,3 +1,3 @@
require 'rubygems'
require 'activerecord'
-require File.join( File.dirname(__FILE__), '..', 'lib', 'scrooge' )
+require File.join( File.dirname(__FILE__), '..', 'lib', 'scrooge' )

0 comments on commit fcfe8a3

Please sign in to comment.