aboutsummaryrefslogtreecommitdiffstats
path: root/spec/shared/relation_spec.rb
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-03-12 17:19:59 -0800
committerCarl Lerche <carllerche@mac.com>2010-03-12 17:19:59 -0800
commitc2f9f707fc56ca610fb1706886b3111dfe1d286f (patch)
treefc8b0a8e41d65d5f284526861002d1618b400aea /spec/shared/relation_spec.rb
parent07e133e97ed422436810b7398dcbd780cabea2c3 (diff)
downloadrails-c2f9f707fc56ca610fb1706886b3111dfe1d286f.tar.gz
rails-c2f9f707fc56ca610fb1706886b3111dfe1d286f.tar.bz2
rails-c2f9f707fc56ca610fb1706886b3111dfe1d286f.zip
Add shared tests for skip
Diffstat (limited to 'spec/shared/relation_spec.rb')
-rw-r--r--spec/shared/relation_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/shared/relation_spec.rb b/spec/shared/relation_spec.rb
index aa03ab6c0a..5f0ae4b46e 100644
--- a/spec/shared/relation_spec.rb
+++ b/spec/shared/relation_spec.rb
@@ -116,4 +116,27 @@ share_examples_for 'A Relation' do
actual.should == expected[0,3]
end
end
+
+ describe "#skip" do
+ it "returns a relation" do
+ @relation.skip(3).should be_a(Arel::Relation)
+ end
+
+ it "skips X items from the collection" do
+ length = @expected.length
+
+ @relation.skip(3).each do |resource|
+ @expected.delete_if { |r| r.tuple == resource.tuple }
+ end
+
+ @expected.length.should == 3
+ end
+
+ it "works with ordering" do
+ expected = @expected.sort_by { |r| [r[@relation[:age]], r[@relation[:id]]] }.map { |r| r[@relation[:id]] }
+ actual = @relation.order(@relation[:age].asc, @relation[:id].asc).skip(3).map { |r| r[@relation[:id]] }
+
+ actual.should == expected[3..-1]
+ end
+ end
end \ No newline at end of file