New permission added: protect wiki pages. Once a page is protected, it can be edited/renamed/deleted only by users who have this permission. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1415 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -160,4 +160,60 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user