added wiki page

This commit is contained in:
albert
2010-02-15 17:32:32 -05:00
parent e745a87e5f
commit 80f033f253
9 changed files with 247 additions and 6 deletions

View File

@@ -0,0 +1,7 @@
Factory.define(:wiki_page) do |f|
f.creator {|x| x.association(:user)}
f.title {|x| Faker::Lorem.words}
f.body {Faker::Lorem.sentences}
f.updater_id {|x| x.creator_id}
f.updater_ip_addr "127.0.0.1"
end

View File

@@ -1,8 +1,39 @@
require 'test_helper'
require File.dirname(__FILE__) + '/../test_helper'
class WikiPageTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
context "A wiki page" do
setup do
MEMCACHE.flush_all
end
should "normalize its title" do
wp = Factory.create(:wiki_page, :title => "HOT POTATO")
assert_equal("hot_potato", wp.title)
end
should "search by title" do
Factory.create(:wiki_page, :title => "HOT POTATO")
matches = WikiPage.titled("hot potato")
assert_equal(1, matches.count)
assert_equal("hot_potato", matches.first.title)
end
should "create versions" do
wp = nil
user = Factory.create(:user)
assert_difference("WikiPageVersion.count") do
wp = Factory.create(:wiki_page, :title => "xxx")
end
assert_difference("WikiPageVersion.count") do
wp.update_attributes(:title => "yyy", :updater_id => user.id, :updater_ip_addr => "127.0.0.1")
end
version = WikiPageVersion.first
wp.revert_to!(version)
assert_equal("xxx", wp.title)
end
end
end