aboutsummaryrefslogtreecommitdiffstats
path: root/spec/active_relation/relations/projection_spec.rb
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-12 18:57:22 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-12 18:57:22 -0800
commit45d2557ae097da1e5dd3dc532444233b4fed0b31 (patch)
tree5b114baa2fe0791435b750d2251f5453263f84e5 /spec/active_relation/relations/projection_spec.rb
parentc2cbe7bb27b6cd2e136ac06f4f36d6de0ec52459 (diff)
downloadrails-45d2557ae097da1e5dd3dc532444233b4fed0b31.tar.gz
rails-45d2557ae097da1e5dd3dc532444233b4fed0b31.tar.bz2
rails-45d2557ae097da1e5dd3dc532444233b4fed0b31.zip
missing files
Diffstat (limited to 'spec/active_relation/relations/projection_spec.rb')
-rw-r--r--spec/active_relation/relations/projection_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/active_relation/relations/projection_spec.rb b/spec/active_relation/relations/projection_spec.rb
new file mode 100644
index 0000000000..8ba571e06c
--- /dev/null
+++ b/spec/active_relation/relations/projection_spec.rb
@@ -0,0 +1,34 @@
+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