aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-12 17:57:35 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-12 17:57:35 -0800
commitcebfc0c1d830799c8b26834760fe40b44efb2d08 (patch)
tree7739a18a907065c43ac6209449a42ab756ff6df5
parentd9f200f2fb14907137a27d5c9522575274bb0cde (diff)
downloadrails-cebfc0c1d830799c8b26834760fe40b44efb2d08.tar.gz
rails-cebfc0c1d830799c8b26834760fe40b44efb2d08.tar.bz2
rails-cebfc0c1d830799c8b26834760fe40b44efb2d08.zip
removed operator overloading; renamed spec files
-rw-r--r--lib/active_relation/relations/attribute.rb2
-rw-r--r--lib/active_relation/relations/base.rb4
-rw-r--r--spec/active_relation/integration/scratch_spec.rb7
-rw-r--r--spec/active_relation/predicates/binary_predicate_spec.rb42
-rw-r--r--spec/active_relation/predicates/equality_predicate_spec.rb25
-rw-r--r--spec/active_relation/predicates/relation_inclusion_predicate_spec.rb16
-rw-r--r--spec/active_relation/relations/deletion_relation_spec.rb24
-rw-r--r--spec/active_relation/relations/insertion_relation_spec.rb26
-rw-r--r--spec/active_relation/relations/join_relation_spec.rb43
-rw-r--r--spec/active_relation/relations/order_relation_spec.rb28
-rw-r--r--spec/active_relation/relations/projection_relation_spec.rb34
-rw-r--r--spec/active_relation/relations/range_relation_spec.rb30
-rw-r--r--spec/active_relation/relations/relation_spec.rb96
-rw-r--r--spec/active_relation/relations/rename_relation_spec.rb61
-rw-r--r--spec/active_relation/relations/selection_relation_spec.rb42
-rw-r--r--spec/active_relation/relations/table_relation_spec.rb30
16 files changed, 6 insertions, 504 deletions
diff --git a/lib/active_relation/relations/attribute.rb b/lib/active_relation/relations/attribute.rb
index 30cd9798d9..b7233a4b17 100644
--- a/lib/active_relation/relations/attribute.rb
+++ b/lib/active_relation/relations/attribute.rb
@@ -22,7 +22,7 @@ module ActiveRelation
end
def eql?(other)
- relation == other.relation and name == other.name and self.alias == other.alias
+ relation == other.relation and name == other.name and @alias == other.alias
end
module Predications
diff --git a/lib/active_relation/relations/base.rb b/lib/active_relation/relations/base.rb
index 67a64b9aa6..960735f07f 100644
--- a/lib/active_relation/relations/base.rb
+++ b/lib/active_relation/relations/base.rb
@@ -17,11 +17,11 @@ module ActiveRelation
include Iteration
module Operations
- def <=>(other)
+ def join(other)
JoinOperation.new("INNER JOIN", self, other)
end
- def <<(other)
+ def outer_join(other)
JoinOperation.new("LEFT OUTER JOIN", self, other)
end
diff --git a/spec/active_relation/integration/scratch_spec.rb b/spec/active_relation/integration/scratch_spec.rb
index 93d332eea7..cd4b4cd004 100644
--- a/spec/active_relation/integration/scratch_spec.rb
+++ b/spec/active_relation/integration/scratch_spec.rb
@@ -51,15 +51,14 @@ describe 'ActiveRelation', 'A proposed refactoring to ActiveRecord, introducing
primary_key = User.reflections[:photos].klass.primary_key.to_sym
foreign_key = User.reflections[:photos].primary_key_name.to_sym
- # << is the left outer join operator
- (user_relation << @photos).on(user_relation[primary_key] == @photos[foreign_key])
+ user_relation.outer_join(@photos).on(user_relation[primary_key] == @photos[foreign_key])
end
def photo_belongs_to_camera(photo_relation)
primary_key = Photo.reflections[:camera].klass.primary_key.to_sym
foreign_key = Photo.reflections[:camera].primary_key_name.to_sym
- (photo_relation << @cameras).on(photo_relation[foreign_key] == @cameras[primary_key])
+ photo_relation.outer_join(@cameras).on(photo_relation[foreign_key] == @cameras[primary_key])
end
describe 'Relational Algebra', 'a relational algebra allows the implementation of
@@ -124,7 +123,7 @@ describe 'ActiveRelation', 'A proposed refactoring to ActiveRecord, introducing
end
it 'allows arbitrary sql to be passed through' do
- (@users << @photos).on("asdf").to_sql.should be_like("""
+ @users.outer_join(@photos).on("asdf").to_sql.should be_like("""
SELECT `users`.`name`, `users`.`id`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id`
FROM `users`
LEFT OUTER JOIN `photos`
diff --git a/spec/active_relation/predicates/binary_predicate_spec.rb b/spec/active_relation/predicates/binary_predicate_spec.rb
deleted file mode 100644
index 02c72ef96d..0000000000
--- a/spec/active_relation/predicates/binary_predicate_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Predicates::Binary do
- before do
- @relation1 = ActiveRelation::Relations::Table.new(:foo)
- @relation2 = ActiveRelation::Relations::Table.new(:bar)
- @attribute1 = ActiveRelation::Primitives::Attribute.new(@relation1, :name1)
- @attribute2 = ActiveRelation::Primitives::Attribute.new(@relation2, :name2)
- class ActiveRelation::Predicates::ConcreteBinary < ActiveRelation::Predicates::Binary
- def predicate_sql
- "<=>"
- end
- end
- end
-
- describe '==' do
- it "obtains if attribute1 and attribute2 are identical" do
- ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2).should == ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2)
- ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2).should_not == ActiveRelation::Predicates::Binary.new(@attribute1, @attribute1)
- end
-
- it "obtains if the concrete type of the ActiveRelation::Predicates::Binarys are identical" do
- ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2).should == ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2)
- ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2).should_not == ActiveRelation::Predicates::ConcreteBinary.new(@attribute1, @attribute2)
- end
- end
-
- describe '#qualify' do
- it "distributes over the predicates and attributes" do
- ActiveRelation::Predicates::ConcreteBinary.new(@attribute1, @attribute2).qualify. \
- should == ActiveRelation::Predicates::ConcreteBinary.new(@attribute1.qualify, @attribute2.qualify)
- end
- end
-
- describe '#to_sql' do
- it 'manufactures correct sql' do
- ActiveRelation::Predicates::ConcreteBinary.new(@attribute1, @attribute2).to_sql.should be_like("""
- `foo`.`name1` <=> `bar`.`name2`
- """)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/predicates/equality_predicate_spec.rb b/spec/active_relation/predicates/equality_predicate_spec.rb
deleted file mode 100644
index b3c7b597a0..0000000000
--- a/spec/active_relation/predicates/equality_predicate_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Predicates::Equality do
- before do
- @relation1 = ActiveRelation::Relations::Table.new(:foo)
- @relation2 = ActiveRelation::Relations::Table.new(:bar)
- @attribute1 = ActiveRelation::Primitives::Attribute.new(@relation1, :name)
- @attribute2 = ActiveRelation::Primitives::Attribute.new(@relation2, :name)
- end
-
- describe '==' do
- it "obtains if attribute1 and attribute2 are identical" do
- ActiveRelation::Predicates::Equality.new(@attribute1, @attribute2).should == ActiveRelation::Predicates::Equality.new(@attribute1, @attribute2)
- ActiveRelation::Predicates::Equality.new(@attribute1, @attribute2).should_not == ActiveRelation::Predicates::Equality.new(@attribute1, @attribute1)
- end
-
- it "obtains if the concrete type of the predicates are identical" do
- ActiveRelation::Predicates::Equality.new(@attribute1, @attribute2).should_not == ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2)
- end
-
- it "is commutative on the attributes" do
- ActiveRelation::Predicates::Equality.new(@attribute1, @attribute2).should == ActiveRelation::Predicates::Equality.new(@attribute2, @attribute1)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/predicates/relation_inclusion_predicate_spec.rb b/spec/active_relation/predicates/relation_inclusion_predicate_spec.rb
deleted file mode 100644
index a01f4fb76b..0000000000
--- a/spec/active_relation/predicates/relation_inclusion_predicate_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Predicates::RelationInclusion do
- before do
- @relation1 = ActiveRelation::Relations::Table.new(:foo)
- @relation2 = ActiveRelation::Relations::Table.new(:bar)
- @attribute = @relation1[:baz]
- end
-
- describe ActiveRelation::Predicates::RelationInclusion, '==' do
- it "obtains if attribute1 and attribute2 are identical" do
- ActiveRelation::Predicates::RelationInclusion.new(@attribute, @relation1).should == ActiveRelation::Predicates::RelationInclusion.new(@attribute, @relation1)
- ActiveRelation::Predicates::RelationInclusion.new(@attribute, @relation1).should_not == ActiveRelation::Predicates::RelationInclusion.new(@attribute, @relation2)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/relations/deletion_relation_spec.rb b/spec/active_relation/relations/deletion_relation_spec.rb
deleted file mode 100644
index b80589bde6..0000000000
--- a/spec/active_relation/relations/deletion_relation_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Relations::Deletion do
- before do
- @relation = ActiveRelation::Relations::Table.new(:users)
- end
-
- describe '#to_sql' do
- it 'manufactures sql deleting a table relation' do
- ActiveRelation::Relations::Deletion.new(@relation).to_sql.should be_like("""
- DELETE
- FROM `users`
- """)
- end
-
- it 'manufactures sql deleting a selection relation' do
- ActiveRelation::Relations::Deletion.new(@relation.select(@relation[:id] == 1)).to_sql.should be_like("""
- DELETE
- FROM `users`
- WHERE `users`.`id` = 1
- """)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/relations/insertion_relation_spec.rb b/spec/active_relation/relations/insertion_relation_spec.rb
deleted file mode 100644
index da39edf773..0000000000
--- a/spec/active_relation/relations/insertion_relation_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Relations::Insertion do
- before do
- @relation = ActiveRelation::Relations::Table.new(:users)
- end
-
- describe '#to_sql' do
- it 'manufactures sql inserting the data for one item' do
- ActiveRelation::Relations::Insertion.new(@relation, @relation[:name] => "nick").to_sql.should be_like("""
- INSERT
- INTO `users`
- (`users`.`name`) VALUES ('nick')
- """)
- end
-
- it 'manufactures sql inserting the data for multiple items' do
- nested_insertion = ActiveRelation::Relations::Insertion.new(@relation, @relation[:name] => "cobra")
- ActiveRelation::Relations::Insertion.new(nested_insertion, nested_insertion[:name] => "commander").to_sql.should be_like("""
- INSERT
- INTO `users`
- (`users`.`name`) VALUES ('cobra'), ('commander')
- """)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/relations/join_relation_spec.rb b/spec/active_relation/relations/join_relation_spec.rb
deleted file mode 100644
index 32771428a8..0000000000
--- a/spec/active_relation/relations/join_relation_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Relations::Join do
- before do
- @relation1 = ActiveRelation::Relations::Table.new(:foo)
- @relation2 = ActiveRelation::Relations::Table.new(:bar)
- @predicate = ActiveRelation::Predicates::Equality.new(@relation1[:id], @relation2[:id])
- end
-
- describe '==' do
- it 'obtains if the two relations and the predicate are identical' do
- ActiveRelation::Relations::Join.new("INNER JOIN", @relation1, @relation2, @predicate).should == ActiveRelation::Relations::Join.new("INNER JOIN", @relation1, @relation2, @predicate)
- ActiveRelation::Relations::Join.new("INNER JOIN", @relation1, @relation2, @predicate).should_not == ActiveRelation::Relations::Join.new("INNER JOIN", @relation1, @relation1, @predicate)
- end
-
- it 'is commutative on the relations' do
- ActiveRelation::Relations::Join.new("INNER JOIN", @relation1, @relation2, @predicate).should == ActiveRelation::Relations::Join.new("INNER JOIN", @relation2, @relation1, @predicate)
- end
- end
-
- describe '#qualify' do
- it 'distributes over the relations and predicates' do
- ActiveRelation::Relations::Join.new("INNER JOIN", @relation1, @relation2, @predicate).qualify. \
- should == ActiveRelation::Relations::Join.new("INNER JOIN", @relation1.qualify, @relation2.qualify, @predicate.qualify)
- end
- end
-
- describe '#to_sql' do
- before do
- @relation1 = @relation1.select(@relation1[:id] == 1)
- end
-
- it 'manufactures sql joining the two tables on the predicate, merging the selects' do
- ActiveRelation::Relations::Join.new("INNER JOIN", @relation1, @relation2, @predicate).to_sql.should be_like("""
- SELECT `foo`.`name`, `foo`.`id`, `bar`.`name`, `bar`.`foo_id`, `bar`.`id`
- FROM `foo`
- INNER JOIN `bar` ON `foo`.`id` = `bar`.`id`
- WHERE
- `foo`.`id` = 1
- """)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/relations/order_relation_spec.rb b/spec/active_relation/relations/order_relation_spec.rb
deleted file mode 100644
index edf2faf455..0000000000
--- a/spec/active_relation/relations/order_relation_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Relations::Order do
- before do
- @relation1 = ActiveRelation::Relations::Table.new(:foo)
- @relation2 = ActiveRelation::Relations::Table.new(:bar)
- @attribute1 = @relation1[:id]
- @attribute2 = @relation2[:id]
- end
-
- describe '#qualify' do
- it "distributes over the relation and attributes" do
- ActiveRelation::Relations::Order.new(@relation1, @attribute1).qualify. \
- should == ActiveRelation::Relations::Order.new(@relation1.qualify, @attribute1.qualify)
- end
- end
-
- describe '#to_sql' do
- it "manufactures sql with an order clause" do
- ActiveRelation::Relations::Order.new(@relation1, @attribute1).to_sql.should be_like("""
- SELECT `foo`.`name`, `foo`.`id`
- FROM `foo`
- ORDER BY `foo`.`id`
- """)
- end
- end
-
-end \ No newline at end of file
diff --git a/spec/active_relation/relations/projection_relation_spec.rb b/spec/active_relation/relations/projection_relation_spec.rb
deleted file mode 100644
index 8ba571e06c..0000000000
--- a/spec/active_relation/relations/projection_relation_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Relations::Projection do
- before do
- @relation1 = ActiveRelation::Relations::Table.new(:foo)
- @relation2 = ActiveRelation::Relations::Table.new(:bar)
- @attribute1 = @relation1[:id]
- @attribute2 = @relation2[:id]
- end
-
- describe '==' do
- it "obtains if the relations and attributes are identical" do
- ActiveRelation::Relations::Projection.new(@relation1, @attribute1, @attribute2).should == ActiveRelation::Relations::Projection.new(@relation1, @attribute1, @attribute2)
- ActiveRelation::Relations::Projection.new(@relation1, @attribute1).should_not == ActiveRelation::Relations::Projection.new(@relation2, @attribute1)
- ActiveRelation::Relations::Projection.new(@relation1, @attribute1).should_not == ActiveRelation::Relations::Projection.new(@relation1, @attribute2)
- end
- end
-
- describe '#qualify' do
- it "distributes over teh relation and attributes" do
- ActiveRelation::Relations::Projection.new(@relation1, @attribute1).qualify. \
- should == ActiveRelation::Relations::Projection.new(@relation1.qualify, @attribute1.qualify)
- end
- end
-
- describe '#to_sql' do
- it "manufactures sql with a limited select clause" do
- ActiveRelation::Relations::Projection.new(@relation1, @attribute1).to_sql.should be_like("""
- SELECT `foo`.`id`
- FROM `foo`
- """)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/relations/range_relation_spec.rb b/spec/active_relation/relations/range_relation_spec.rb
deleted file mode 100644
index d4107259aa..0000000000
--- a/spec/active_relation/relations/range_relation_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Relations::Range do
- before do
- @relation1 = ActiveRelation::Relations::Table.new(:foo)
- @relation2 = ActiveRelation::Relations::Table.new(:bar)
- @range1 = 1..2
- @range2 = 4..9
- end
-
- describe '#qualify' do
- it "distributes over the relation and attributes" do
- pending
- end
- end
-
- describe '#to_sql' do
- it "manufactures sql with limit and offset" do
- range_size = @range2.last - @range2.first + 1
- range_start = @range2.first
- ActiveRelation::Relations::Range.new(@relation1, @range2).to_s.should be_like("""
- SELECT `foo`.`name`, `foo`.`id`
- FROM `foo`
- LIMIT #{range_size}
- OFFSET #{range_start}
- """)
- end
- end
-
-end \ No newline at end of file
diff --git a/spec/active_relation/relations/relation_spec.rb b/spec/active_relation/relations/relation_spec.rb
deleted file mode 100644
index caee3bb527..0000000000
--- a/spec/active_relation/relations/relation_spec.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Relations::Base do
- before do
- @relation1 = ActiveRelation::Relations::Table.new(:foo)
- @relation2 = ActiveRelation::Relations::Table.new(:bar)
- @attribute1 = ActiveRelation::Primitives::Attribute.new(@relation1, :id)
- @attribute2 = ActiveRelation::Primitives::Attribute.new(@relation1, :name)
- end
-
- describe '[]' do
- it "manufactures an attribute when given a symbol" do
- @relation1[:id].should == ActiveRelation::Primitives::Attribute.new(@relation1, :id)
- end
-
- it "manufactures a range relation when given a range" do
- @relation1[1..2].should == ActiveRelation::Relations::Range.new(@relation1, 1..2)
- end
- end
-
- describe '#include?' do
- it "manufactures an inclusion predicate" do
- @relation1.include?(@attribute1).should be_kind_of(ActiveRelation::Predicates::RelationInclusion)
- end
- end
-
- describe 'read operations' do
- describe 'joins' do
- before do
- @predicate = @relation1[:id] == @relation2[:id]
- end
-
- describe '<=>' do
- it "manufactures an inner join operation between those two relations" do
- (@relation1 <=> @relation2).on(@predicate).should == ActiveRelation::Relations::Join.new("INNER JOIN", @relation1, @relation2, @predicate)
- end
- end
-
- describe '<<' do
- it "manufactures a left outer join operation between those two relations" do
- (@relation1 << @relation2).on(@predicate).should == ActiveRelation::Relations::Join.new("LEFT OUTER JOIN", @relation1, @relation2, @predicate)
- end
- end
- end
-
- describe '#project' do
- it "collapses identical projections" do
- pending
- end
-
- it "manufactures a projection relation" do
- @relation1.project(@attribute1, @attribute2).should be_kind_of(ActiveRelation::Relations::Projection)
- end
- end
-
- describe '#rename' do
- it "manufactures a rename relation" do
- @relation1.rename(@attribute1, :foo).should be_kind_of(ActiveRelation::Relations::Rename)
- end
- end
-
- describe '#select' do
- before do
- @predicate = ActiveRelation::Predicates::Equality.new(@attribute1, @attribute2)
- end
-
- it "manufactures a selection relation" do
- @relation1.select(@predicate).should be_kind_of(ActiveRelation::Relations::Selection)
- end
-
- it "accepts arbitrary strings" do
- @relation1.select("arbitrary").should be_kind_of(ActiveRelation::Relations::Selection)
- end
- end
-
- describe '#order' do
- it "manufactures an order relation" do
- @relation1.order(@attribute1, @attribute2).should be_kind_of(ActiveRelation::Relations::Order)
- end
- end
- end
-
- describe 'write operations' do
- describe '#delete' do
- it 'manufactures a deletion relation' do
- @relation1.delete.should be_kind_of(ActiveRelation::Relations::Deletion)
- end
- end
-
- describe '#insert' do
- it 'manufactures an insertion relation' do
- @relation1.insert(record = {:id => 1}).should be_kind_of(ActiveRelation::Relations::Insertion)
- end
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/relations/rename_relation_spec.rb b/spec/active_relation/relations/rename_relation_spec.rb
deleted file mode 100644
index 6fac206ff1..0000000000
--- a/spec/active_relation/relations/rename_relation_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Relations::Rename do
- before do
- @relation = ActiveRelation::Relations::Table.new(:foo)
- @renamed_relation = ActiveRelation::Relations::Rename.new(@relation, @relation[:id] => :schmid)
- end
-
- describe '#initialize' do
- it "manufactures nested rename relations if multiple renames are provided" do
- ActiveRelation::Relations::Rename.new(@relation, @relation[:id] => :humpty, @relation[:name] => :dumpty). \
- should == ActiveRelation::Relations::Rename.new(ActiveRelation::Relations::Rename.new(@relation, @relation[:id] => :humpty), @relation[:name] => :dumpty)
- end
-
- it "raises an exception if the alias provided is already used" do
- pending
- end
- end
-
- describe '==' do
- it "obtains if the relation, attribute, and alias are identical" do
- pending
- end
- end
-
- describe '#attributes' do
- it "manufactures a list of attributes with the renamed attribute aliased" do
- ActiveRelation::Relations::Rename.new(@relation, @relation[:id] => :schmid).attributes.should ==
- (@relation.attributes - [@relation[:id]]) + [@relation[:id].alias(:schmid)]
- end
- end
-
- describe '[]' do
- it 'indexes attributes by alias' do
- @renamed_relation[:id].should be_nil
- @renamed_relation[:schmid].should == @relation[:id]
- end
- end
-
- describe '#schmattribute' do
- it "should be renamed" do
- pending
- end
- end
-
- describe '#qualify' do
- it "distributes over the relation and renames" do
- ActiveRelation::Relations::Rename.new(@relation, @relation[:id] => :schmid).qualify. \
- should == ActiveRelation::Relations::Rename.new(@relation.qualify, @relation[:id].qualify => :schmid)
- end
- end
-
- describe '#to_sql' do
- it 'manufactures sql aliasing the attribute' do
- @renamed_relation.to_sql.should be_like("""
- SELECT `foo`.`name`, `foo`.`id` AS 'schmid'
- FROM `foo`
- """)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/relations/selection_relation_spec.rb b/spec/active_relation/relations/selection_relation_spec.rb
deleted file mode 100644
index 90dc3169b6..0000000000
--- a/spec/active_relation/relations/selection_relation_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Relations::Selection do
- before do
- @relation1 = ActiveRelation::Relations::Table.new(:foo)
- @relation2 = ActiveRelation::Relations::Table.new(:bar)
- @predicate1 = ActiveRelation::Predicates::Equality.new(@relation1[:id], @relation2[:foo_id])
- @predicate2 = ActiveRelation::Predicates::LessThan.new(@relation1[:age], 2)
- end
-
- describe '#initialize' do
- it "manufactures nested selection relations if multiple predicates are provided" do
- ActiveRelation::Relations::Selection.new(@relation1, @predicate1, @predicate2). \
- should == ActiveRelation::Relations::Selection.new(ActiveRelation::Relations::Selection.new(@relation1, @predicate2), @predicate1)
- end
- end
-
- describe '#qualify' do
- it "distributes over the relation and predicates" do
- ActiveRelation::Relations::Selection.new(@relation1, @predicate1).qualify. \
- should == ActiveRelation::Relations::Selection.new(@relation1.qualify, @predicate1.qualify)
- end
- end
-
- describe '#to_sql' do
- it "manufactures sql with where clause conditions" do
- ActiveRelation::Relations::Selection.new(@relation1, @predicate1).to_sql.should be_like("""
- SELECT `foo`.`name`, `foo`.`id`
- FROM `foo`
- WHERE `foo`.`id` = `bar`.`foo_id`
- """)
- end
-
- it "allows arbitrary sql" do
- ActiveRelation::Relations::Selection.new(@relation1, "asdf").to_sql.should be_like("""
- SELECT `foo`.`name`, `foo`.`id`
- FROM `foo`
- WHERE asdf
- """)
- end
- end
-end \ No newline at end of file
diff --git a/spec/active_relation/relations/table_relation_spec.rb b/spec/active_relation/relations/table_relation_spec.rb
deleted file mode 100644
index 62b8e44980..0000000000
--- a/spec/active_relation/relations/table_relation_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
-
-describe ActiveRelation::Relations::Table do
- before do
- @relation = ActiveRelation::Relations::Table.new(:users)
- end
-
- describe '#to_sql' do
- it "returns a simple SELECT query" do
- @relation.to_sql.should be_like("""
- SELECT `users`.`name`, `users`.`id`
- FROM `users`
- """)
- end
- end
-
- describe '#attributes' do
- it 'manufactures attributes corresponding to columns in the table' do
- pending
- end
- end
-
- describe '#qualify' do
- it 'manufactures a rename relation with all attribute names qualified' do
- @relation.qualify.should == ActiveRelation::Relations::Rename.new(
- ActiveRelation::Relations::Rename.new(@relation, @relation[:id] => 'users.id'), @relation[:name] => 'users.name'
- )
- end
- end
-end \ No newline at end of file