aboutsummaryrefslogtreecommitdiffstats
path: root/spec/active_relation/relations/range_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/range_spec.rb
parentc2cbe7bb27b6cd2e136ac06f4f36d6de0ec52459 (diff)
downloadrails-45d2557ae097da1e5dd3dc532444233b4fed0b31.tar.gz
rails-45d2557ae097da1e5dd3dc532444233b4fed0b31.tar.bz2
rails-45d2557ae097da1e5dd3dc532444233b4fed0b31.zip
missing files
Diffstat (limited to 'spec/active_relation/relations/range_spec.rb')
-rw-r--r--spec/active_relation/relations/range_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/active_relation/relations/range_spec.rb b/spec/active_relation/relations/range_spec.rb
new file mode 100644
index 0000000000..d4107259aa
--- /dev/null
+++ b/spec/active_relation/relations/range_spec.rb
@@ -0,0 +1,30 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+describe ActiveRelation::Relations::Range do
+ before do
+ @relation1 = ActiveRelation::Relations::Table.new(:foo)
+ @relation2 = ActiveRelation::Relations::Table.new(:bar)
+ @range1 = 1..2
+ @range2 = 4..9
+ end
+
+ describe '#qualify' do
+ it "distributes over the relation and attributes" do
+ pending
+ end
+ end
+
+ describe '#to_sql' do
+ it "manufactures sql with limit and offset" do
+ range_size = @range2.last - @range2.first + 1
+ range_start = @range2.first
+ ActiveRelation::Relations::Range.new(@relation1, @range2).to_s.should be_like("""
+ SELECT `foo`.`name`, `foo`.`id`
+ FROM `foo`
+ LIMIT #{range_size}
+ OFFSET #{range_start}
+ """)
+ end
+ end
+
+end \ No newline at end of file