diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-11 18:24:18 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-11 18:24:18 -0700 |
commit | ae0fe8f6c8c41b5abf8ced6a99b19dacdf8f57eb (patch) | |
tree | 3f3e9a0bc779b489033a4def6dcf31603953fec6 /spec/active_relation/unit/relations/skip_spec.rb | |
parent | 3967bd524da7b3c0b985c57670ceb7f5d48a0f1b (diff) | |
download | rails-ae0fe8f6c8c41b5abf8ced6a99b19dacdf8f57eb.tar.gz rails-ae0fe8f6c8c41b5abf8ced6a99b19dacdf8f57eb.tar.bz2 rails-ae0fe8f6c8c41b5abf8ced6a99b19dacdf8f57eb.zip |
redesigned the way limit and offset work
- was range now have special 'take' and 'skip' operations. (the terminology comes from linq)
Diffstat (limited to 'spec/active_relation/unit/relations/skip_spec.rb')
-rw-r--r-- | spec/active_relation/unit/relations/skip_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/active_relation/unit/relations/skip_spec.rb b/spec/active_relation/unit/relations/skip_spec.rb new file mode 100644 index 0000000000..77f2b8db27 --- /dev/null +++ b/spec/active_relation/unit/relations/skip_spec.rb @@ -0,0 +1,32 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') + +module ActiveRelation + describe Skip do + before do + @relation = Table.new(:users) + @skip = 4 + end + + describe '#qualify' do + it "descends" do + Skip.new(@relation, @skip).qualify.should == Skip.new(@relation, @skip).descend(&:qualify) + end + end + + describe '#descend' do + it "distributes a block over the relation" do + Skip.new(@relation, @skip).descend(&:qualify).should == Skip.new(@relation.descend(&:qualify), @skip) + end + end + + describe '#to_sql' do + it "manufactures sql with limit and offset" do + Skip.new(@relation, @skip).to_s.should be_like(" + SELECT `users`.`id`, `users`.`name` + FROM `users` + OFFSET #{@skip} + ") + end + end + end +end
\ No newline at end of file |