diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-12 16:43:48 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-12 16:43:48 -0700 |
commit | 1b8f72746b38ce1e08b5fab48f3251eb09f2cba0 (patch) | |
tree | 3782ef3e88474bb6d79ba3e25b08b235fca78040 /spec/active_relation/unit/relations | |
parent | 6de1f350ce117129e46353f12f90a138ca3d3ead (diff) | |
download | rails-1b8f72746b38ce1e08b5fab48f3251eb09f2cba0.tar.gz rails-1b8f72746b38ce1e08b5fab48f3251eb09f2cba0.tar.bz2 rails-1b8f72746b38ce1e08b5fab48f3251eb09f2cba0.zip |
- removed #qualify and #descend helper
- qualify seems no longer neccessary since everything is fully qualified
- finished pending specs
Diffstat (limited to 'spec/active_relation/unit/relations')
-rw-r--r-- | spec/active_relation/unit/relations/join_spec.rb | 14 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/order_spec.rb | 14 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/projection_spec.rb | 14 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/relation_spec.rb | 9 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/rename_spec.rb | 14 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/selection_spec.rb | 20 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/skip_spec.rb | 12 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/table_spec.rb | 11 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/take_spec.rb | 18 |
9 files changed, 9 insertions, 117 deletions
diff --git a/spec/active_relation/unit/relations/join_spec.rb b/spec/active_relation/unit/relations/join_spec.rb index 423e513be4..73dd67bec8 100644 --- a/spec/active_relation/unit/relations/join_spec.rb +++ b/spec/active_relation/unit/relations/join_spec.rb @@ -32,20 +32,6 @@ module ActiveRelation end end - describe '#qualify' do - it 'descends' do - Join.new("INNER JOIN", @relation1, @relation2, @predicate).qualify. \ - should == Join.new("INNER JOIN", @relation1, @relation2, @predicate).descend(&:qualify) - end - end - - describe '#descend' do - it 'distributes over the relations and predicates' do - Join.new("INNER JOIN", @relation1, @relation2, @predicate).qualify. \ - should == Join.new("INNER JOIN", @relation1.qualify, @relation2.qualify, @predicate.qualify) - end - end - describe '#prefix_for' do describe 'when the joined relations are simple' do it "returns the name of the relation containing the attribute" do diff --git a/spec/active_relation/unit/relations/order_spec.rb b/spec/active_relation/unit/relations/order_spec.rb index db322fe00b..e8a2f4c227 100644 --- a/spec/active_relation/unit/relations/order_spec.rb +++ b/spec/active_relation/unit/relations/order_spec.rb @@ -18,20 +18,6 @@ module ActiveRelation end end - describe '#qualify' do - it "descends" do - Order.new(@relation, @attribute).qualify. \ - should == Order.new(@relation, @attribute).descend(&:qualify) - end - end - - describe '#descend' do - it "distributes a block over the relation and attributes" do - Order.new(@relation, @attribute).descend(&:qualify). \ - should == Order.new(@relation.descend(&:qualify), @attribute.qualify) - end - end - describe '#to_sql' do describe "when given an attribute" do it "manufactures sql with an order clause populated by the attribute" do diff --git a/spec/active_relation/unit/relations/projection_spec.rb b/spec/active_relation/unit/relations/projection_spec.rb index f58564840b..529998a8d4 100644 --- a/spec/active_relation/unit/relations/projection_spec.rb +++ b/spec/active_relation/unit/relations/projection_spec.rb @@ -30,20 +30,6 @@ module ActiveRelation end end - describe '#qualify' do - it "descends" do - Projection.new(@relation, @attribute).qualify. \ - should == Projection.new(@relation, @attribute).descend(&:qualify) - end - end - - describe '#descend' do - it "distributes a block over the relation and attributes" do - Projection.new(@relation, @attribute).descend(&:qualify). \ - should == Projection.new(@relation.descend(&:qualify), @attribute.qualify) - end - end - describe '#to_sql' do describe 'when given an attribute' do it "manufactures sql with a limited select clause" do diff --git a/spec/active_relation/unit/relations/relation_spec.rb b/spec/active_relation/unit/relations/relation_spec.rb index 2a04276aeb..fa66352c91 100644 --- a/spec/active_relation/unit/relations/relation_spec.rb +++ b/spec/active_relation/unit/relations/relation_spec.rb @@ -174,12 +174,9 @@ module ActiveRelation end describe Relation::Enumerable do - it "is enumerable" do - pending "I don't like this mock-based test" - data = [1,2,3] - mock.instance_of(Session).read(anything) { data } - @relation.collect.should == data - @relation.first.should == data.first + it "implements enumerable" do + @relation.collect.should == @relation.session.read(@relation) + @relation.first.should == @relation.session.read(@relation).first end end end diff --git a/spec/active_relation/unit/relations/rename_spec.rb b/spec/active_relation/unit/relations/rename_spec.rb index 9a63c4fc80..192c819848 100644 --- a/spec/active_relation/unit/relations/rename_spec.rb +++ b/spec/active_relation/unit/relations/rename_spec.rb @@ -38,20 +38,6 @@ module ActiveRelation end end - describe '#qualify' do - it "descends" do - Rename.new(@relation, @relation[:id] => :schmid).qualify. \ - should == Rename.new(@relation, @relation[:id] => :schmid).descend(&:qualify) - end - end - - describe '#descend' do - it "distributes a block over the relation and renames" do - Rename.new(@relation, @relation[:id] => :schmid).descend(&:qualify). \ - should == Rename.new(@relation.descend(&:qualify), @relation[:id].qualify => :schmid) - end - end - describe '#to_sql' do it 'manufactures sql renaming the attribute' do Rename.new(@relation, @relation[:id] => :schmid).to_sql.should be_like(" diff --git a/spec/active_relation/unit/relations/selection_spec.rb b/spec/active_relation/unit/relations/selection_spec.rb index 20833de58d..d87e075f98 100644 --- a/spec/active_relation/unit/relations/selection_spec.rb +++ b/spec/active_relation/unit/relations/selection_spec.rb @@ -17,25 +17,7 @@ module ActiveRelation should == Selection.new(Selection.new(@relation, @another_predicate), @predicate) end end - - describe '#qualify' do - it "descends" do - Selection.new(@relation, @predicate).qualify. \ - should == Selection.new(@relation, @predicate).descend(&:qualify) - end - end - - describe '#descend' do - before do - @selection = Selection.new(@relation, @predicate) - end - - it "distributes a block over the relation and predicates" do - @selection.descend(&:qualify). \ - should == Selection.new(@selection.relation.descend(&:qualify), @selection.predicate.qualify) - end - end - + describe '#to_sql' do describe 'when given a predicate' do it "manufactures sql with where clause conditions" do diff --git a/spec/active_relation/unit/relations/skip_spec.rb b/spec/active_relation/unit/relations/skip_spec.rb index d50ef715ee..219bfdd80e 100644 --- a/spec/active_relation/unit/relations/skip_spec.rb +++ b/spec/active_relation/unit/relations/skip_spec.rb @@ -7,18 +7,6 @@ module ActiveRelation @skipped = 4 end - describe '#qualify' do - it "descends" do - Skip.new(@relation, @skipped).qualify.should == Skip.new(@relation, @skipped).descend(&:qualify) - end - end - - describe '#descend' do - it "distributes a block over the relation" do - Skip.new(@relation, @skipped).descend(&:qualify).should == Skip.new(@relation.descend(&:qualify), @skipped) - end - end - describe '#to_sql' do it "manufactures sql with limit and offset" do Skip.new(@relation, @skipped).to_s.should be_like(" diff --git a/spec/active_relation/unit/relations/table_spec.rb b/spec/active_relation/unit/relations/table_spec.rb index 6286ea9de1..2751d9cb63 100644 --- a/spec/active_relation/unit/relations/table_spec.rb +++ b/spec/active_relation/unit/relations/table_spec.rb @@ -46,8 +46,8 @@ module ActiveRelation end describe '#column_for' do - it "" do - @relation[:id].column.should == @relation.columns.detect { |c| c.name == 'id' } + it "returns the column corresponding to the attribute" do + @relation.column_for(@relation[:id]).should == @relation.columns.detect { |c| c.name == 'id' } end end @@ -68,19 +68,12 @@ module ActiveRelation describe '#reset' do it "reloads columns from the database" do - pending lambda { stub(@relation.engine).columns { [] } }.should_not change { @relation.attributes } lambda { @relation.reset }.should change { @relation.attributes } end end end - describe '#qualify' do - it 'manufactures a rename relation with all attribute names qualified' do - @relation.qualify.should == Rename.new(@relation, @relation[:name] => 'users.name', @relation[:id] => 'users.id') - end - end - describe 'hashing' do it "implements hash equality" do Table.new(:users).should hash_the_same_as(Table.new(:users)) diff --git a/spec/active_relation/unit/relations/take_spec.rb b/spec/active_relation/unit/relations/take_spec.rb index beaa9e2f8c..8c13732258 100644 --- a/spec/active_relation/unit/relations/take_spec.rb +++ b/spec/active_relation/unit/relations/take_spec.rb @@ -4,27 +4,15 @@ module ActiveRelation describe Take do before do @relation = Table.new(:users) - @takene = 4 + @taken = 4 end - describe '#qualify' do - it "descends" do - Take.new(@relation, @takene).qualify.should == Take.new(@relation, @takene).descend(&:qualify) - end - end - - describe '#descend' do - it "distributes a block over the relation" do - Take.new(@relation, @takene).descend(&:qualify).should == Take.new(@relation.descend(&:qualify), @takene) - end - end - describe '#to_sql' do it "manufactures sql with limit and offset" do - Take.new(@relation, @takene).to_s.should be_like(" + Take.new(@relation, @taken).to_s.should be_like(" SELECT `users`.`id`, `users`.`name` FROM `users` - LIMIT #{@takene} + LIMIT #{@taken} ") end end |