From d0ba361c93aa94865ccfe739e9ab65654771e38e Mon Sep 17 00:00:00 2001
From: Nick Kallen <nkallen@nick-kallens-computer-2.local>
Date: Sat, 16 Feb 2008 16:37:00 -0800
Subject: more test coverage

---
 lib/active_relation/relations/join.rb       | 10 ++++------
 lib/active_relation/relations/projection.rb |  7 +++++--
 lib/active_relation/relations/relation.rb   |  2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)

(limited to 'lib/active_relation')

diff --git a/lib/active_relation/relations/join.rb b/lib/active_relation/relations/join.rb
index ede8b272cb..4c4f2e66a2 100644
--- a/lib/active_relation/relations/join.rb
+++ b/lib/active_relation/relations/join.rb
@@ -7,12 +7,10 @@ module ActiveRelation
     end
 
     def ==(other)
-      self.class == other.class and
-      predicates == other.predicates and (
-        (relation1 == other.relation1 and
-         relation2 == other.relation2) or
-        (relation2 == other.relation1 and
-         relation1 == other.relation2)
+      self.class == other.class       and
+      predicates == other.predicates  and (
+        (relation1 == other.relation1 and relation2 == other.relation2) or
+        (relation2 == other.relation1 and relation1 == other.relation2)
       )
     end
 
diff --git a/lib/active_relation/relations/projection.rb b/lib/active_relation/relations/projection.rb
index 9e0725f6c5..d0c68869bd 100644
--- a/lib/active_relation/relations/projection.rb
+++ b/lib/active_relation/relations/projection.rb
@@ -1,14 +1,17 @@
 module ActiveRelation
   class Projection < Compound
     attr_reader :projections
-    alias_method :attributes, :projections
     
     def initialize(relation, *projections)
       @relation, @projections = relation, projections
     end
 
+    def attributes
+      projections.collect { |p| p.bind(self) }
+    end
+    
     def ==(other)
-      self.class  == other.class and
+      self.class  == other.class    and
       relation    == other.relation and
       projections == other.projections
     end
diff --git a/lib/active_relation/relations/relation.rb b/lib/active_relation/relations/relation.rb
index c5409bc9ff..c65120a75c 100644
--- a/lib/active_relation/relations/relation.rb
+++ b/lib/active_relation/relations/relation.rb
@@ -109,7 +109,7 @@ module ActiveRelation
     end
     
     def attribute_for_name(name)
-      attributes.detect { |a| a.alias_or_name == name }
+      attributes.detect { |a| a.alias_or_name.to_s == name.to_s }
     end
     
     def attribute_for_attribute(attribute)
-- 
cgit v1.2.3