diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-02-11 23:17:45 -0800 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-02-11 23:17:45 -0800 |
commit | c910ac7554ad4989c8dd4e942fc14ae78eeddc3d (patch) | |
tree | 24727f05d7e8bcde9381f72b767cbc557edc0b30 | |
parent | 0d70ce37e510c83d5fc42f88b04314f40d87fe96 (diff) | |
download | rails-c910ac7554ad4989c8dd4e942fc14ae78eeddc3d.tar.gz rails-c910ac7554ad4989c8dd4e942fc14ae78eeddc3d.tar.bz2 rails-c910ac7554ad4989c8dd4e942fc14ae78eeddc3d.zip |
removing unneccessary tests now that attribute lookup is so simple
-rw-r--r-- | lib/active_relation/relations/join.rb | 1 | ||||
-rw-r--r-- | spec/active_relation/primitives/attribute_spec.rb | 2 | ||||
-rw-r--r-- | spec/active_relation/primitives/expression_spec.rb | 2 | ||||
-rw-r--r-- | spec/active_relation/relations/compound_spec.rb | 32 | ||||
-rw-r--r-- | spec/active_relation/relations/join_spec.rb | 18 | ||||
-rw-r--r-- | spec/active_relation/relations/relation_spec.rb | 4 | ||||
-rw-r--r-- | spec/active_relation/relations/rename_spec.rb | 59 | ||||
-rw-r--r-- | spec/active_relation/relations/table_spec.rb | 29 |
8 files changed, 29 insertions, 118 deletions
diff --git a/lib/active_relation/relations/join.rb b/lib/active_relation/relations/join.rb index 6d59ffcf39..ede8b272cb 100644 --- a/lib/active_relation/relations/join.rb +++ b/lib/active_relation/relations/join.rb @@ -28,7 +28,6 @@ module ActiveRelation end def prefix_for(attribute) - # test me (relation1[attribute] && relation1.aliased_prefix_for(attribute)) || (relation2[attribute] && relation2.aliased_prefix_for(attribute)) end diff --git a/spec/active_relation/primitives/attribute_spec.rb b/spec/active_relation/primitives/attribute_spec.rb index ecc9014658..6d0020d5da 100644 --- a/spec/active_relation/primitives/attribute_spec.rb +++ b/spec/active_relation/primitives/attribute_spec.rb @@ -18,7 +18,7 @@ module ActiveRelation end describe '#bind' do - it "manufactures an attribute with the relation bindd and self as an ancestor" do + it "manufactures an attribute with the relation bound and self as an ancestor" do derived_relation = @relation.select(@relation[:id].equals(1)) @attribute.bind(derived_relation).should == Attribute.new(derived_relation, @attribute.name, nil, @attribute) end diff --git a/spec/active_relation/primitives/expression_spec.rb b/spec/active_relation/primitives/expression_spec.rb index 2ec5130386..f90ae899c3 100644 --- a/spec/active_relation/primitives/expression_spec.rb +++ b/spec/active_relation/primitives/expression_spec.rb @@ -13,7 +13,7 @@ module ActiveRelation end describe '#bind' do - it "manufactures an attribute with a bindd relation and self as the ancestor" do + it "manufactures an attribute with a rebound relation and self as the ancestor" do derived_relation = @relation.select(@relation[:id] == 1) @expression.bind(derived_relation).should == Expression.new(@attribute.bind(derived_relation), "COUNT", nil, @expression) end diff --git a/spec/active_relation/relations/compound_spec.rb b/spec/active_relation/relations/compound_spec.rb index bb2919a318..b0f122ca97 100644 --- a/spec/active_relation/relations/compound_spec.rb +++ b/spec/active_relation/relations/compound_spec.rb @@ -17,37 +17,5 @@ module ActiveRelation @compound_relation.attributes.should == @relation.attributes.collect { |a| a.bind(@compound_relation) } end end - - describe '[]' do - describe 'when given a', Symbol do - it 'manufactures attributes associated with the compound relation if the symbol names an attribute within the relation' do - @compound_relation[:id].should == @relation[:id].bind(@compound_relation) - @compound_relation[:does_not_exist].should be_nil - end - end - - describe 'when given an', Attribute do - it "manufactures a bindd attribute when given an attribute within the relation" do - @compound_relation[@relation[:id]].should == @relation[:id].bind(@compound_relation) - @compound_relation[@compound_relation[:id]].should == @compound_relation[:id] - pending "test nil" - end - end - - describe 'when given an', Expression do - before do - @nested_expression = Expression.new(Attribute.new(@relation, :id), "COUNT") - @nested_relation = Aggregation.new(@relation, :expressions => [@nested_expression]) - @unprojected_expression = Expression.new(Attribute.new(@relation, :id), "SUM") - @compound_relation = ConcreteCompound.new(@nested_relation) - end - - it "manufactures a bindd Expression when given an Expression within the relation" do - @compound_relation[@nested_expression].should == @nested_relation[@nested_expression].bind(@compound_relation) - @compound_relation[@compound_relation[@expression]].should == @compound_relation[@expression] - @compound_relation[@unprojected_expression].should be_nil - end - end - end end end
\ No newline at end of file diff --git a/spec/active_relation/relations/join_spec.rb b/spec/active_relation/relations/join_spec.rb index 5c86c72a18..b131ac6918 100644 --- a/spec/active_relation/relations/join_spec.rb +++ b/spec/active_relation/relations/join_spec.rb @@ -18,12 +18,6 @@ module ActiveRelation Join.new("INNER JOIN", @relation1, @relation2, @predicate).should == Join.new("INNER JOIN", @relation2, @relation1, @predicate) end end - - describe '[]' do - it "" do - pending - end - end describe '#qualify' do it 'distributes over the relations and predicates' do @@ -42,15 +36,19 @@ module ActiveRelation @join.attributes.should == (@relation1.attributes + @relation2.attributes).collect { |a| a.bind(@join) } end - end - - describe 'with aggregated relations' do - it '' do + + it 'does something peculiar with expressions when aggregate' do pending end end end + describe '#prefix_for' do + it 'needs a test' do + pending + end + end + describe '#to_sql' do describe 'with simple relations' do it 'manufactures sql joining the two tables on the predicate' do diff --git a/spec/active_relation/relations/relation_spec.rb b/spec/active_relation/relations/relation_spec.rb index e28487b373..91eabe485b 100644 --- a/spec/active_relation/relations/relation_spec.rb +++ b/spec/active_relation/relations/relation_spec.rb @@ -13,6 +13,10 @@ module ActiveRelation it "manufactures a range relation when given a range" do @relation1[1..2].should == Range.new(@relation1, 1..2) end + + it "needs to test attributes and names" do + pending + end end describe '#include?' do diff --git a/spec/active_relation/relations/rename_spec.rb b/spec/active_relation/relations/rename_spec.rb index 5a6cecc39e..339bb2f39f 100644 --- a/spec/active_relation/relations/rename_spec.rb +++ b/spec/active_relation/relations/rename_spec.rb @@ -27,64 +27,7 @@ module ActiveRelation it "manufactures a list of attributes with the renamed attribute renameed" do @renamed_relation.attributes.should include(@renamed_relation[:schmid]) @renamed_relation.should have(@relation1.attributes.size).attributes - end - end - - describe '[]' do - describe 'when given a', Symbol do - it 'indexes attributes by rename if the symbol names an attribute within the relation' do - @renamed_relation[:id].should be_nil - @renamed_relation[:schmid].should == @relation1[:id].as(:schmid).bind(@renamed_relation) - @renamed_relation[:does_not_exist].should be_nil - end - end - - describe 'when given an', Attribute do - it 'manufactures a bindd and renamed attribute if the attribute is within the relation' do - @renamed_relation[@relation1[:id]].should == @relation1[:id].as(:schmid).bind(@renamed_relation) - @renamed_relation[@relation1[:name]].should == @relation1[:name].bind(@renamed_relation) - @renamed_relation[@renamed_relation[:name]].should == @renamed_relation[:name] - @renamed_relation[@relation2[:id]].should be_nil - end - end - - describe 'when given an', Expression do - it "manufactures a bindd and renamed expression if the expression is within the relation" do - pending - end - end - - describe 'when the rename is constructed with a derived attribute' do - before do - @renamed_renamed_relation = Rename.new(@renamed_relation, @relation1[:id] => :flid) - end - - describe 'when given a', Symbol do - it 'manufactures a bindd and renamed attribute if the attribute is within the relation' do - @renamed_renamed_relation[:id].should be_nil - @renamed_renamed_relation[:schmid].should be_nil - @renamed_renamed_relation[:flid].should == @renamed_relation[:schmid].as(:flid).bind(@renamed_renamed_relation) - end - end - - describe 'when given an', Attribute do - it "manufactures a bindd and renamed attribute if the attribute is within the relation -- even if the provided attribute derived" do - @renamed_renamed_relation[@renamed_relation[:schmid]].should == @renamed_relation[:schmid].as(:flid).bind(@renamed_renamed_relation) - @renamed_renamed_relation[@relation1[:id]].should == @renamed_relation[:schmid].as(:flid).bind(@renamed_renamed_relation) - end - end - - describe 'when given an', Expression do - before do - @expression = @relation1[:id].count - @aggregation = Aggregation.new(@relation1, :expressions => [@expression]) - @renamed_relation = Rename.new(@aggregation, @expression => :cnt) - end - - it "manufactures a bindd and renamed expression if the expression is within the relation" do - @renamed_relation[@expression].should == @aggregation[@expression].as(:cnt).bind(@renamed_relation) - end - end + pending "this should be more rigorous" end end diff --git a/spec/active_relation/relations/table_spec.rb b/spec/active_relation/relations/table_spec.rb index 03b4836e80..498d841040 100644 --- a/spec/active_relation/relations/table_spec.rb +++ b/spec/active_relation/relations/table_spec.rb @@ -3,43 +3,42 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper') module ActiveRelation describe Table do before do - @table = Table.new(:users) - @relation2 = Table.new(:photos) + @relation = Table.new(:users) end describe '[]' do describe 'when given a', Symbol do it "manufactures an attribute if the symbol names an attribute within the relation" do - @table[:id].should == Attribute.new(@table, :id) - @table[:does_not_exist].should be_nil + @relation[:id].should == Attribute.new(@relation, :id) + @relation[:does_not_exist].should be_nil end end describe 'when given an', Attribute do it "returns the attribute if the attribute is within the relation" do - @table[@table[:id]].should == @table[:id] + @relation[@relation[:id]].should == @relation[:id] end it "returns nil if the attribtue is not within the relation" do another_relation = Table.new(:photos) - @table[another_relation[:id]].should be_nil + @relation[another_relation[:id]].should be_nil end end describe 'when given an', Expression do before do - @expression = Expression.new(Attribute.new(@table, :id), "COUNT") + @expression = Expression.new(Attribute.new(@relation, :id), "COUNT") end it "returns the Expression if the Expression is within the relation" do - @table[@expression].should be_nil + @relation[@expression].should be_nil end end end describe '#to_sql' do it "manufactures a simple select query" do - @table.to_sql.should be_like(""" + @relation.to_sql.should be_like(""" SELECT `users`.`id`, `users`.`name` FROM `users` """) @@ -48,28 +47,28 @@ module ActiveRelation describe '#prefix_for' do it "returns the table name" do - @table.prefix_for(Attribute.new(@table, :id)).should == :users + @relation.prefix_for(Attribute.new(@relation, :id)).should == :users end end describe '#aliased_prefix_for' do it "returns the table name" do - @table.aliased_prefix_for(Attribute.new(@table, :id)).should == :users + @relation.aliased_prefix_for(Attribute.new(@relation, :id)).should == :users end end describe '#attributes' do it 'manufactures attributes corresponding to columns in the table' do - @table.attributes.should == [ - Attribute.new(@table, :id), - Attribute.new(@table, :name) + @relation.attributes.should == [ + Attribute.new(@relation, :id), + Attribute.new(@relation, :name) ] end end describe '#qualify' do it 'manufactures a rename relation with all attribute names qualified' do - @table.qualify.should == Rename.new(@table, @table[:name] => 'users.name', @table[:id] => 'users.id') + @relation.qualify.should == Rename.new(@relation, @relation[:name] => 'users.name', @relation[:id] => 'users.id') end end end |