added wiki page
This commit is contained in:
7
test/factories/wiki_page.rb
Normal file
7
test/factories/wiki_page.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user