aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-21 20:12:21 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-21 20:12:21 -0800
commit3f50d5c23719b6877124fcd9669bbf4811f4c2eb (patch)
tree747aa417444d99d999e23a4a39fbff423eed70ca
parent7f35d492372fd91cd35e7f9a2408efd64d28ccf5 (diff)
downloadrails-3f50d5c23719b6877124fcd9669bbf4811f4c2eb.tar.gz
rails-3f50d5c23719b6877124fcd9669bbf4811f4c2eb.tar.bz2
rails-3f50d5c23719b6877124fcd9669bbf4811f4c2eb.zip
filling out some pending specs
-rw-r--r--lib/active_relation/relations/compound.rb1
-rw-r--r--lib/active_relation/relations/range.rb4
-rw-r--r--spec/active_relation/relations/range_spec.rb4
-rw-r--r--spec/active_relation/relations/relation_spec.rb4
-rw-r--r--spec/active_relation/relations/rename_spec.rb27
-rw-r--r--spec/active_relation/relations/table_spec.rb5
6 files changed, 23 insertions, 22 deletions
diff --git a/lib/active_relation/relations/compound.rb b/lib/active_relation/relations/compound.rb
index d71d0ffeb5..332147523e 100644
--- a/lib/active_relation/relations/compound.rb
+++ b/lib/active_relation/relations/compound.rb
@@ -1,7 +1,6 @@
module ActiveRelation
class Compound < Relation
attr_reader :relation
-
delegate :projections, :attributes, :attribute, :joins, :selects, :orders, :groupings, :table_sql, :inserts, :limit,
:offset, :name, :alias, :aggregation?,
:to => :relation
diff --git a/lib/active_relation/relations/range.rb b/lib/active_relation/relations/range.rb
index e8b7f4b69d..83af03fc0e 100644
--- a/lib/active_relation/relations/range.rb
+++ b/lib/active_relation/relations/range.rb
@@ -17,5 +17,9 @@ module ActiveRelation
def offset
range.begin
end
+
+ def qualify
+ Range.new(relation.qualify, range)
+ end
end
end \ No newline at end of file
diff --git a/spec/active_relation/relations/range_spec.rb b/spec/active_relation/relations/range_spec.rb
index f417626fed..51171c759b 100644
--- a/spec/active_relation/relations/range_spec.rb
+++ b/spec/active_relation/relations/range_spec.rb
@@ -10,8 +10,8 @@ module ActiveRelation
end
describe '#qualify' do
- it "distributes over the relation and attributes" do
- pending
+ it "distributes over the relation" do
+ Range.new(@relation1, @range1).qualify.should == Range.new(@relation1.qualify, @range1)
end
end
diff --git a/spec/active_relation/relations/relation_spec.rb b/spec/active_relation/relations/relation_spec.rb
index f78f1b31b7..05330206e0 100644
--- a/spec/active_relation/relations/relation_spec.rb
+++ b/spec/active_relation/relations/relation_spec.rb
@@ -51,10 +51,6 @@ module ActiveRelation
end
describe '#project' do
- it "collapses identical projections" do
- pending
- end
-
it "manufactures a projection relation" do
@relation1.project(@attribute1, @attribute2).should == Projection.new(@relation1, @attribute1, @attribute2)
end
diff --git a/spec/active_relation/relations/rename_spec.rb b/spec/active_relation/relations/rename_spec.rb
index eb0e1f48dd..1616d5fdb7 100644
--- a/spec/active_relation/relations/rename_spec.rb
+++ b/spec/active_relation/relations/rename_spec.rb
@@ -3,45 +3,44 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
module ActiveRelation
describe Rename do
before do
- @relation = Table.new(:foo)
- @renamed_relation = Rename.new(@relation, @relation[:id] => :schmid)
+ @relation1 = Table.new(:foo)
+ @relation2 = Table.new(:bar)
+ @renamed_relation = Rename.new(@relation1, @relation1[:id] => :schmid)
end
describe '#initialize' do
it "manufactures nested rename relations if multiple renames are provided" do
- Rename.new(@relation, @relation[:id] => :humpty, @relation[:name] => :dumpty). \
- should == Rename.new(Rename.new(@relation, @relation[:id] => :humpty), @relation[:name] => :dumpty)
- end
-
- it "raises an exception if the rename provided is already used" do
- pending
+ Rename.new(@relation1, @relation1[:id] => :humpty, @relation1[:name] => :dumpty). \
+ should == Rename.new(Rename.new(@relation1, @relation1[:id] => :humpty), @relation1[:name] => :dumpty)
end
end
describe '==' do
it "obtains if the relation, attribute, and rename are identical" do
- pending
+ Rename.new(@relation1, @relation1[:id] => :humpty).should == Rename.new(@relation1, @relation1[:id] => :humpty)
+ Rename.new(@relation1, @relation1[:id] => :humpty).should_not == Rename.new(@relation1, @relation1[:id] => :dumpty)
+ Rename.new(@relation1, @relation1[:id] => :humpty).should_not == Rename.new(@relation2, @relation2[:id] => :humpty)
end
end
describe '#attributes' do
it "manufactures a list of attributes with the renamed attribute renameed" do
- Rename.new(@relation, @relation[:id] => :schmid).attributes.should ==
- (@relation.attributes - [@relation[:id]]) + [@relation[:id].as(:schmid)]
+ Rename.new(@relation1, @relation1[:id] => :schmid).attributes.should ==
+ (@relation1.attributes - [@relation1[:id]]) + [@relation1[:id].as(:schmid)]
end
end
describe '[]' do
it 'indexes attributes by rename' do
@renamed_relation[:id].should be_nil
- @renamed_relation[:schmid].should == @relation[:id].as(:schmid)
+ @renamed_relation[:schmid].should == @relation1[:id].as(:schmid)
end
end
describe '#qualify' do
it "distributes over the relation and renames" do
- Rename.new(@relation, @relation[:id] => :schmid).qualify. \
- should == Rename.new(@relation.qualify, @relation[:id].qualify => :schmid)
+ Rename.new(@relation1, @relation1[:id] => :schmid).qualify. \
+ should == Rename.new(@relation1.qualify, @relation1[:id].qualify => :schmid)
end
end
diff --git a/spec/active_relation/relations/table_spec.rb b/spec/active_relation/relations/table_spec.rb
index ec6e6e10bd..c8679707f5 100644
--- a/spec/active_relation/relations/table_spec.rb
+++ b/spec/active_relation/relations/table_spec.rb
@@ -17,7 +17,10 @@ module ActiveRelation
describe '#attributes' do
it 'manufactures attributes corresponding to columns in the table' do
- pending
+ @relation.attributes.should == [
+ Attribute.new(@relation, :name),
+ Attribute.new(@relation, :id)
+ ]
end
end