aboutsummaryrefslogtreecommitdiffstats
path: root/spec/active_relation/unit
diff options
context:
space:
mode:
Diffstat (limited to 'spec/active_relation/unit')
-rw-r--r--spec/active_relation/unit/relations/join_spec.rb4
-rw-r--r--spec/active_relation/unit/relations/relation_spec.rb27
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)