Merged trunk r1773.

git-svn-id: http://redmine.rubyforge.org/svn/branches/work@1774 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-08-30 14:41:07 +00:00
parent ab83ed5d8e
commit a377069fb2
398 changed files with 14736 additions and 5683 deletions
+95 -4
View File
@@ -32,10 +32,16 @@ class WikiControllerTest < Test::Unit::TestCase
end
def test_show_start_page
get :index, :id => 1
get :index, :id => 'ecookbook'
assert_response :success
assert_template 'show'
assert_tag :tag => 'h1', :content => /CookBook documentation/
# child_pages macro
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
:child => { :tag => 'li',
:child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' },
:content => 'Page with an inline image' } }
end
def test_show_page_with_name
@@ -86,14 +92,35 @@ class WikiControllerTest < Test::Unit::TestCase
assert_tag :tag => 'strong', :content => /previewed text/
end
def test_preview_new_page
@request.session[:user_id] = 2
xhr :post, :preview, :id => 1, :page => 'New page',
:content => { :text => 'h1. New page',
:comments => '',
:version => 0 }
assert_response :success
assert_template 'common/_preview'
assert_tag :tag => 'h1', :content => /New page/
end
def test_history
get :history, :id => 1, :page => 'CookBook_documentation'
assert_response :success
assert_template 'history'
assert_not_nil assigns(:versions)
assert_equal 3, assigns(:versions).size
assert_select "input[type=submit][name=commit]"
end
def test_history_with_one_version
get :history, :id => 1, :page => 'Another_page'
assert_response :success
assert_template 'history'
assert_not_nil assigns(:versions)
assert_equal 1, assigns(:versions).size
assert_select "input[type=submit][name=commit]", false
end
def test_diff
get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
assert_response :success
@@ -152,12 +179,76 @@ class WikiControllerTest < Test::Unit::TestCase
pages = assigns(:pages)
assert_not_nil pages
assert_equal Project.find(1).wiki.pages.size, pages.size
assert_tag :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' },
:content => /CookBook documentation/
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' },
:content => 'CookBook documentation' },
:child => { :tag => 'ul',
:child => { :tag => 'li',
:child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' },
:content => 'Page with an inline image' } } } },
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Another_page' },
:content => 'Another page' } }
end
def test_not_found
get :index, :id => 999
assert_response 404
end
def test_protect_page
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
assert !page.protected?
@request.session[:user_id] = 2
post :protect, :id => 1, :page => page.title, :protected => '1'
assert_redirected_to 'wiki/ecookbook/Another_page'
assert page.reload.protected?
end
def test_unprotect_page
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation')
assert page.protected?
@request.session[:user_id] = 2
post :protect, :id => 1, :page => page.title, :protected => '0'
assert_redirected_to 'wiki/ecookbook'
assert !page.reload.protected?
end
def test_show_page_with_edit_link
@request.session[:user_id] = 2
get :index, :id => 1
assert_response :success
assert_template 'show'
assert_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' }
end
def test_show_page_without_edit_link
@request.session[:user_id] = 4
get :index, :id => 1
assert_response :success
assert_template 'show'
assert_no_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' }
end
def test_edit_unprotected_page
# Non members can edit unprotected wiki pages
@request.session[:user_id] = 4
get :edit, :id => 1, :page => 'Another_page'
assert_response :success
assert_template 'edit'
end
def test_edit_protected_page_by_nonmember
# Non members can't edit protected wiki pages
@request.session[:user_id] = 4
get :edit, :id => 1, :page => 'CookBook_documentation'
assert_response 403
end
def test_edit_protected_page_by_member
@request.session[:user_id] = 2
get :edit, :id => 1, :page => 'CookBook_documentation'
assert_response :success
assert_template 'edit'
end
end