diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-11 15:53:45 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-11 15:53:45 -0700 |
commit | 3967bd524da7b3c0b985c57670ceb7f5d48a0f1b (patch) | |
tree | 8e342a0ad2f6b27948731ad1c1433bcfb8aa2f29 /spec | |
parent | eee3a766160cd32a4d9b5e1352858597005c9cee (diff) | |
download | rails-3967bd524da7b3c0b985c57670ceb7f5d48a0f1b.tar.gz rails-3967bd524da7b3c0b985c57670ceb7f5d48a0f1b.tar.bz2 rails-3967bd524da7b3c0b985c57670ceb7f5d48a0f1b.zip |
string passthrough for joins
Diffstat (limited to 'spec')
-rw-r--r-- | spec/active_relation/unit/relations/join_spec.rb | 4 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/relation_spec.rb | 27 |
2 files changed, 21 insertions, 10 deletions
diff --git a/spec/active_relation/unit/relations/join_spec.rb b/spec/active_relation/unit/relations/join_spec.rb index b274da7565..423e513be4 100644 --- a/spec/active_relation/unit/relations/join_spec.rb +++ b/spec/active_relation/unit/relations/join_spec.rb @@ -161,10 +161,10 @@ module ActiveRelation describe 'when joining with a string' do it "passes the string through to the where clause" do - Join.new("INNER JOIN ON asdf", @relation1).to_sql.should be_like(" + Join.new("INNER JOIN asdf ON fdsa", @relation1).to_sql.should be_like(" SELECT `users`.`id`, `users`.`name` FROM `users` - INNER JOIN ON asdf + INNER JOIN asdf ON fdsa ") end end diff --git a/spec/active_relation/unit/relations/relation_spec.rb b/spec/active_relation/unit/relations/relation_spec.rb index 682ec88f10..70bf87271a 100644 --- a/spec/active_relation/unit/relations/relation_spec.rb +++ b/spec/active_relation/unit/relations/relation_spec.rb @@ -51,24 +51,35 @@ module ActiveRelation end describe '#join' do - it "manufactures an inner join operation between those two relations" do - @relation.join(@relation).on(@predicate).should == Join.new("INNER JOIN", @relation, @relation, @predicate) + describe 'when given a relation' do + it "manufactures an inner join operation between those two relations" do + @relation.join(@relation).on(@predicate). \ + should == Join.new("INNER JOIN", @relation, @relation, @predicate) + end + end + + describe "when given a string" do + it "manufactures a join operation with the string passed through" do + @relation.join(arbitrary_string = "ASDF").should == Join.new(arbitrary_string, @relation) + end end end - + describe '#outer_join' do it "manufactures a left outer join operation between those two relations" do - @relation.outer_join(@relation).on(@predicate).should == Join.new("LEFT OUTER JOIN", @relation, @relation, @predicate) - end + @relation.outer_join(@relation).on(@predicate). \ + should == Join.new("LEFT OUTER JOIN", @relation, @relation, @predicate) + end end end - + describe '#project' do it "manufactures a projection relation" do - @relation.project(@attribute1, @attribute2).should == Projection.new(@relation, @attribute1, @attribute2) + @relation.project(@attribute1, @attribute2). \ + should == Projection.new(@relation, @attribute1, @attribute2) end end - + describe '#as' do it "manufactures an alias relation" do @relation.as(:paul).should == Alias.new(@relation, :paul) |