From dca946b2b8e4c5e556f76f66caa325ad4446dc2f Mon Sep 17 00:00:00 2001 From: albert Date: Fri, 22 Mar 2013 19:20:38 -0400 Subject: [PATCH] add test cases --- test/unit/note_test.rb | 4 ++++ test/unit/post_test.rb | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/test/unit/note_test.rb b/test/unit/note_test.rb index b23193a0f..da44e81bb 100644 --- a/test/unit/note_test.rb +++ b/test/unit/note_test.rb @@ -44,6 +44,8 @@ class NoteTest < ActiveSupport::TestCase assert_equal(1, @note.versions.count) assert_equal(@note.body, @note.versions.first.body) + assert_equal(1, @note.version) + assert_equal(1, @note.versions.first.version) end should "update the post's last_noted_at field" do @@ -92,7 +94,9 @@ class NoteTest < ActiveSupport::TestCase @note.update_attributes(:body => "fafafa") end assert_equal(2, @note.versions.count) + assert_equal(2, @note.versions.last.version) assert_equal("fafafa", @note.versions.last.body) + assert_equal(2, @note.version) end context "for a note-locked post" do diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 3c0b05b43..458ffedc7 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -764,6 +764,20 @@ class PostTest < ActiveSupport::TestCase end end end + + context "Paginating:" do + setup do + CurrentUser.user.stubs(:per_page).returns(3) + 4.times do + FactoryGirl.create(:post) + end + end + + should "delegate the default limit to the user" do + posts = Post.tag_match("").paginate(1).all + assert_equal(3, posts.size) + end + end context "Searching:" do should "return posts for the ' tag" do