aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-04-30 23:42:26 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-04-30 23:42:26 -0700
commitf48c642852b5bb6be62dbbc7502d34b64e53716b (patch)
tree50b65f7ff7253201924336fa65eb6481df913f84 /spec
parent57d6bce28b07f864c97a7b58d758fd5621196b00 (diff)
downloadrails-f48c642852b5bb6be62dbbc7502d34b64e53716b.tar.gz
rails-f48c642852b5bb6be62dbbc7502d34b64e53716b.tar.bz2
rails-f48c642852b5bb6be62dbbc7502d34b64e53716b.zip
the big obstacle
Diffstat (limited to 'spec')
-rw-r--r--spec/arel/unit/relations/alias_spec.rb6
-rw-r--r--spec/arel/unit/relations/join_spec.rb11
-rw-r--r--spec/arel/unit/relations/relation_spec.rb24
3 files changed, 18 insertions, 23 deletions
diff --git a/spec/arel/unit/relations/alias_spec.rb b/spec/arel/unit/relations/alias_spec.rb
index 420a91c806..25dbf70668 100644
--- a/spec/arel/unit/relations/alias_spec.rb
+++ b/spec/arel/unit/relations/alias_spec.rb
@@ -4,12 +4,12 @@ module Arel
describe Alias do
before do
@relation = Table.new(:users)
- @alias_relation = Alias.new(@relation, :foo)
end
- describe '#alias' do
+ describe '==' do
it "returns the alias" do
- @alias_relation.alias.should == :foo
+ Alias.new(@relation).should_not == Alias.new(@relation)
+ (aliaz = Alias.new(@relation)).should == aliaz
end
end
end
diff --git a/spec/arel/unit/relations/join_spec.rb b/spec/arel/unit/relations/join_spec.rb
index b14d951aae..c3f33e1ae7 100644
--- a/spec/arel/unit/relations/join_spec.rb
+++ b/spec/arel/unit/relations/join_spec.rb
@@ -129,7 +129,7 @@ module Arel
describe 'when joining a relation to itself' do
before do
- @aliased_relation = @relation1.as(:alias)
+ @aliased_relation = @relation1.alias
@predicate = @relation1[:id].eq(@aliased_relation[:id])
end
@@ -145,6 +145,13 @@ module Arel
describe 'when joining the same relation to itself' do
describe '#to_sql' do
+ it '' do
+ @relation1 \
+ .join(@relation1.alias.join(@relation1.alias).on(@relation1[:id].eq(1))) \
+ .on(@relation1[:id].eq(1)) \
+ .to_sql.should be_like("")
+ end
+
it 'aliases the table and attributes properly in the join predicate and the where clause' do
@relation1.join(@aliased_relation).on(@relation1[:id].eq(@aliased_relation[:id])).to_sql.should be_like("
SELECT `users`.`id`, `users`.`name`, `users_2`.`id`, `users_2`.`name`
@@ -173,7 +180,7 @@ module Arel
SELECT `users`.`id`, `users`.`name`
FROM `users`
INNER JOIN asdf ON fdsa
- ")
+ ")
end
end
end
diff --git a/spec/arel/unit/relations/relation_spec.rb b/spec/arel/unit/relations/relation_spec.rb
index d6874a1554..3b8be55c7d 100644
--- a/spec/arel/unit/relations/relation_spec.rb
+++ b/spec/arel/unit/relations/relation_spec.rb
@@ -30,12 +30,6 @@ module Arel
@relation.should_not be_aggregation
end
end
-
- describe '#alias?' do
- it "returns false" do
- @relation.should_not be_alias
- end
- end
end
describe Relation::Operations do
@@ -86,31 +80,25 @@ module Arel
end
end
- describe '#as' do
+ describe '#alias' do
it "manufactures an alias relation" do
- @relation.as(:paul).should == Alias.new(@relation, :paul)
- end
-
- describe 'when given a blank alias' do
- it 'returns self' do
- @relation.as.should == @relation
- end
+ @relation.alias.relation.should == Alias.new(@relation).relation
end
end
-
+
describe '#select' do
before do
@predicate = Equality.new(@attribute1, @attribute2)
end
-
+
it "manufactures a selection relation" do
@relation.select(@predicate).should == Selection.new(@relation, @predicate)
end
-
+
it "accepts arbitrary strings" do
@relation.select("arbitrary").should == Selection.new(@relation, "arbitrary")
end
-
+
describe 'when given a blank predicate' do
it 'returns self' do
@relation.select.should == @relation