aboutsummaryrefslogtreecommitdiffstats
path: root/spec/relations
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-01 16:44:33 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-01 16:44:33 -0800
commit6c89e3818d85e3169a7fb8de27b25357c2259881 (patch)
tree2ffe9fbe8765239733a864646ce71f9551736151 /spec/relations
parent0496a59e1fe0caf2d295defb588a00460cf15efb (diff)
downloadrails-6c89e3818d85e3169a7fb8de27b25357c2259881.tar.gz
rails-6c89e3818d85e3169a7fb8de27b25357c2259881.tar.bz2
rails-6c89e3818d85e3169a7fb8de27b25357c2259881.zip
integration test
Diffstat (limited to 'spec/relations')
-rw-r--r--spec/relations/attribute_spec.rb4
-rw-r--r--spec/relations/join_relation_spec.rb12
-rw-r--r--spec/relations/order_relation_spec.rb8
-rw-r--r--spec/relations/projection_relation_spec.rb4
-rw-r--r--spec/relations/range_relation_spec.rb2
-rw-r--r--spec/relations/selection_relation_spec.rb7
-rw-r--r--spec/relations/table_relation_spec.rb2
7 files changed, 27 insertions, 12 deletions
diff --git a/spec/relations/attribute_spec.rb b/spec/relations/attribute_spec.rb
index 78d602abf9..5ddbaa96b5 100644
--- a/spec/relations/attribute_spec.rb
+++ b/spec/relations/attribute_spec.rb
@@ -59,7 +59,9 @@ describe Attribute do
describe '#to_sql' do
it "manufactures a column" do
- Attribute.new(@relation1, :attribute_name).to_sql.should == ColumnBuilder.new(@relation1.table, :attribute_name)
+ Attribute.new(@relation1, :attribute_name, :alias).to_sql.should == SelectsBuilder.new do
+ column :foo, :attribute_name, :alias
+ end
end
end
end
diff --git a/spec/relations/join_relation_spec.rb b/spec/relations/join_relation_spec.rb
index c6fae90ff3..a7c15fd76a 100644
--- a/spec/relations/join_relation_spec.rb
+++ b/spec/relations/join_relation_spec.rb
@@ -30,14 +30,20 @@ describe 'between two relations' do
it 'manufactures sql joining the two tables on the predicate, merging the selects' do
ConcreteJoinRelation.new(@relation1, @relation2, @predicate).to_sql.to_s.should == SelectBuilder.new do
- select :*
+ select { all }
from :foo do
inner_join :bar do
- equals 'foo.a', 'bar.b'
+ equals do
+ column :foo, :a
+ column :bar, :b
+ end
end
end
where do
- equals 'foo.c', 'bar.d'
+ equals do
+ column :foo, :c
+ column :bar, :d
+ end
end
end.to_s
end
diff --git a/spec/relations/order_relation_spec.rb b/spec/relations/order_relation_spec.rb
index 4f7a18fc8e..8050aa981c 100644
--- a/spec/relations/order_relation_spec.rb
+++ b/spec/relations/order_relation_spec.rb
@@ -16,12 +16,14 @@ describe OrderRelation do
end
end
- describe '#to_s' do
+ describe '#to_sql' do
it "manufactures sql with an order clause" do
OrderRelation.new(@relation1, @attribute1).to_sql.should == SelectBuilder.new do
- select :*
+ select { all }
from :foo
- order_by 'foo.foo'
+ order_by do
+ column :foo, :foo
+ end
end
end
end
diff --git a/spec/relations/projection_relation_spec.rb b/spec/relations/projection_relation_spec.rb
index ba5620dcde..f17f57df7b 100644
--- a/spec/relations/projection_relation_spec.rb
+++ b/spec/relations/projection_relation_spec.rb
@@ -19,7 +19,9 @@ describe ProjectionRelation do
describe '#to_sql' do
it "manufactures sql with a limited select clause" do
ProjectionRelation.new(@relation1, @attribute1).to_sql.should == SelectBuilder.new do
- select 'foo.foo'
+ select do
+ column :foo, :foo
+ end
from :foo
end
end
diff --git a/spec/relations/range_relation_spec.rb b/spec/relations/range_relation_spec.rb
index fc7094c873..e6caa32e80 100644
--- a/spec/relations/range_relation_spec.rb
+++ b/spec/relations/range_relation_spec.rb
@@ -21,7 +21,7 @@ describe RangeRelation do
range_size = @range2.last - @range2.first + 1
range_start = @range2.first
RangeRelation.new(@relation1, @range2).to_sql.to_s.should == SelectBuilder.new do
- select :*
+ select { all }
from :foo
limit range_size
offset range_start
diff --git a/spec/relations/selection_relation_spec.rb b/spec/relations/selection_relation_spec.rb
index 1f8b760272..ceb771b46d 100644
--- a/spec/relations/selection_relation_spec.rb
+++ b/spec/relations/selection_relation_spec.rb
@@ -29,10 +29,13 @@ describe SelectionRelation do
describe '#to_sql' do
it "manufactures sql with where clause conditions" do
SelectionRelation.new(@relation1, @predicate1).to_sql.should == SelectBuilder.new do
- select :*
+ select { all }
from :foo
where do
- equals 'foo.id', 'bar.foo_id'
+ equals do
+ column :foo, :id
+ column :bar, :foo_id
+ end
end
end
end
diff --git a/spec/relations/table_relation_spec.rb b/spec/relations/table_relation_spec.rb
index a0647aa541..7a820782df 100644
--- a/spec/relations/table_relation_spec.rb
+++ b/spec/relations/table_relation_spec.rb
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
describe TableRelation, '#to_sql' do
it "returns a simple SELECT query" do
TableRelation.new(:users).to_sql.should == SelectBuilder.new do |s|
- select :*
+ select { all }
from :users
end
end