remove trailing white-spaces from functional wiki controller test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5802 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-05-16 22:56:04 +00:00
parent 3ec87dd73f
commit dfa509b69e

View File

@ -5,12 +5,12 @@
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -23,14 +23,14 @@ class WikiController; def rescue_action(e) raise e end; end
class WikiControllerTest < ActionController::TestCase class WikiControllerTest < ActionController::TestCase
fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments
def setup def setup
@controller = WikiController.new @controller = WikiController.new
@request = ActionController::TestRequest.new @request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new @response = ActionController::TestResponse.new
User.current = nil User.current = nil
end end
def test_show_start_page def test_show_start_page
get :show, :project_id => 'ecookbook' get :show, :project_id => 'ecookbook'
assert_response :success assert_response :success
@ -43,7 +43,7 @@ class WikiControllerTest < ActionController::TestCase
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' }, :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
:content => 'Page with an inline image' } } :content => 'Page with an inline image' } }
end end
def test_show_page_with_name def test_show_page_with_name
get :show, :project_id => 1, :id => 'Another_page' get :show, :project_id => 1, :id => 'Another_page'
assert_response :success assert_response :success
@ -54,37 +54,37 @@ class WikiControllerTest < ActionController::TestCase
assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3', assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3',
:alt => 'This is a logo' } :alt => 'This is a logo' }
end end
def test_show_redirected_page def test_show_redirected_page
WikiRedirect.create!(:wiki_id => 1, :title => 'Old_title', :redirects_to => 'Another_page') WikiRedirect.create!(:wiki_id => 1, :title => 'Old_title', :redirects_to => 'Another_page')
get :show, :project_id => 'ecookbook', :id => 'Old_title' get :show, :project_id => 'ecookbook', :id => 'Old_title'
assert_redirected_to '/projects/ecookbook/wiki/Another_page' assert_redirected_to '/projects/ecookbook/wiki/Another_page'
end end
def test_show_with_sidebar def test_show_with_sidebar
page = Project.find(1).wiki.pages.new(:title => 'Sidebar') page = Project.find(1).wiki.pages.new(:title => 'Sidebar')
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
page.save! page.save!
get :show, :project_id => 1, :id => 'Another_page' get :show, :project_id => 1, :id => 'Another_page'
assert_response :success assert_response :success
assert_tag :tag => 'div', :attributes => {:id => 'sidebar'}, assert_tag :tag => 'div', :attributes => {:id => 'sidebar'},
:content => /Side bar content for test_show_with_sidebar/ :content => /Side bar content for test_show_with_sidebar/
end end
def test_show_unexistent_page_without_edit_right def test_show_unexistent_page_without_edit_right
get :show, :project_id => 1, :id => 'Unexistent page' get :show, :project_id => 1, :id => 'Unexistent page'
assert_response 404 assert_response 404
end end
def test_show_unexistent_page_with_edit_right def test_show_unexistent_page_with_edit_right
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :show, :project_id => 1, :id => 'Unexistent page' get :show, :project_id => 1, :id => 'Unexistent page'
assert_response :success assert_response :success
assert_template 'edit' assert_template 'edit'
end end
def test_create_page def test_create_page
@request.session[:user_id] = 2 @request.session[:user_id] = 2
put :update, :project_id => 1, put :update, :project_id => 1,
@ -98,7 +98,7 @@ class WikiControllerTest < ActionController::TestCase
assert_not_nil page.content assert_not_nil page.content
assert_equal 'Created the page', page.content.comments assert_equal 'Created the page', page.content.comments
end end
def test_create_page_with_attachments def test_create_page_with_attachments
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'WikiPage.count' do assert_difference 'WikiPage.count' do
@ -132,7 +132,7 @@ class WikiControllerTest < ActionController::TestCase
end end
end end
assert_redirected_to '/projects/ecookbook/wiki/Another_page' assert_redirected_to '/projects/ecookbook/wiki/Another_page'
page = Wiki.find(1).pages.find_by_title('Another_page') page = Wiki.find(1).pages.find_by_title('Another_page')
assert_equal "edited", page.content.text assert_equal "edited", page.content.text
assert_equal 2, page.content.version assert_equal 2, page.content.version
@ -156,19 +156,19 @@ class WikiControllerTest < ActionController::TestCase
end end
assert_response :success assert_response :success
assert_template 'edit' assert_template 'edit'
assert_error_tag :descendant => {:content => /Comment is too long/} assert_error_tag :descendant => {:content => /Comment is too long/}
assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => 'edited' assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => 'edited'
assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'} assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'}
end end
def test_update_stale_page_should_not_raise_an_error def test_update_stale_page_should_not_raise_an_error
@request.session[:user_id] = 2 @request.session[:user_id] = 2
c = Wiki.find(1).find_page('Another_page').content c = Wiki.find(1).find_page('Another_page').content
c.text = 'Previous text' c.text = 'Previous text'
c.save! c.save!
assert_equal 2, c.version assert_equal 2, c.version
assert_no_difference 'WikiPage.count' do assert_no_difference 'WikiPage.count' do
assert_no_difference 'WikiContent.count' do assert_no_difference 'WikiContent.count' do
assert_no_difference 'WikiContent::Version.count' do assert_no_difference 'WikiContent::Version.count' do
@ -187,17 +187,17 @@ class WikiControllerTest < ActionController::TestCase
assert_tag :div, assert_tag :div,
:attributes => { :class => /error/ }, :attributes => { :class => /error/ },
:content => /Data has been updated by another user/ :content => /Data has been updated by another user/
assert_tag 'textarea', assert_tag 'textarea',
:attributes => { :name => 'content[text]' }, :attributes => { :name => 'content[text]' },
:content => /Text should not be lost/ :content => /Text should not be lost/
assert_tag 'input', assert_tag 'input',
:attributes => { :name => 'content[comments]', :value => 'My comments' } :attributes => { :name => 'content[comments]', :value => 'My comments' }
c.reload c.reload
assert_equal 'Previous text', c.text assert_equal 'Previous text', c.text
assert_equal 2, c.version assert_equal 2, c.version
end end
def test_preview def test_preview
@request.session[:user_id] = 2 @request.session[:user_id] = 2
xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation', xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation',
@ -208,7 +208,7 @@ class WikiControllerTest < ActionController::TestCase
assert_template 'common/_preview' assert_template 'common/_preview'
assert_tag :tag => 'strong', :content => /previewed text/ assert_tag :tag => 'strong', :content => /previewed text/
end end
def test_preview_new_page def test_preview_new_page
@request.session[:user_id] = 2 @request.session[:user_id] = 2
xhr :post, :preview, :project_id => 1, :id => 'New page', xhr :post, :preview, :project_id => 1, :id => 'New page',
@ -219,7 +219,7 @@ class WikiControllerTest < ActionController::TestCase
assert_template 'common/_preview' assert_template 'common/_preview'
assert_tag :tag => 'h1', :content => /New page/ assert_tag :tag => 'h1', :content => /New page/
end end
def test_history def test_history
get :history, :project_id => 1, :id => 'CookBook_documentation' get :history, :project_id => 1, :id => 'CookBook_documentation'
assert_response :success assert_response :success
@ -237,7 +237,7 @@ class WikiControllerTest < ActionController::TestCase
assert_equal 1, assigns(:versions).size assert_equal 1, assigns(:versions).size
assert_select "input[type=submit][name=commit]", false assert_select "input[type=submit][name=commit]", false
end end
def test_diff def test_diff
get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => 2, :version_from => 1 get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => 2, :version_from => 1
assert_response :success assert_response :success
@ -245,7 +245,7 @@ class WikiControllerTest < ActionController::TestCase
assert_tag :tag => 'span', :attributes => { :class => 'diff_in'}, assert_tag :tag => 'span', :attributes => { :class => 'diff_in'},
:content => /updated/ :content => /updated/
end end
def test_annotate def test_annotate
get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => 2 get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => 2
assert_response :success assert_response :success
@ -273,7 +273,7 @@ class WikiControllerTest < ActionController::TestCase
:attributes => {:selected => 'selected'}, :attributes => {:selected => 'selected'},
:parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}} :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
end end
def test_get_rename_child_page def test_get_rename_child_page
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :rename, :project_id => 1, :id => 'Child_1' get :rename, :project_id => 1, :id => 'Child_1'
@ -291,7 +291,7 @@ class WikiControllerTest < ActionController::TestCase
:attributes => {:name => 'wiki_page[parent_id]'} :attributes => {:name => 'wiki_page[parent_id]'}
} }
end end
def test_rename_with_redirect def test_rename_with_redirect
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :rename, :project_id => 1, :id => 'Another_page', post :rename, :project_id => 1, :id => 'Another_page',
@ -314,7 +314,7 @@ class WikiControllerTest < ActionController::TestCase
# Check that there's no redirects # Check that there's no redirects
assert_nil wiki.find_page('Another page') assert_nil wiki.find_page('Another page')
end end
def test_rename_with_parent_assignment def test_rename_with_parent_assignment
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :rename, :project_id => 1, :id => 'Another_page', post :rename, :project_id => 1, :id => 'Another_page',
@ -330,13 +330,13 @@ class WikiControllerTest < ActionController::TestCase
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1' assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1'
assert_nil WikiPage.find_by_title('Child_1').parent assert_nil WikiPage.find_by_title('Child_1').parent
end end
def test_destroy_child def test_destroy_child
@request.session[:user_id] = 2 @request.session[:user_id] = 2
delete :destroy, :project_id => 1, :id => 'Child_1' delete :destroy, :project_id => 1, :id => 'Child_1'
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
end end
def test_destroy_parent def test_destroy_parent
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_no_difference('WikiPage.count') do assert_no_difference('WikiPage.count') do
@ -345,7 +345,7 @@ class WikiControllerTest < ActionController::TestCase
assert_response :success assert_response :success
assert_template 'destroy' assert_template 'destroy'
end end
def test_destroy_parent_with_nullify def test_destroy_parent_with_nullify
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference('WikiPage.count', -1) do assert_difference('WikiPage.count', -1) do
@ -354,7 +354,7 @@ class WikiControllerTest < ActionController::TestCase
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_nil WikiPage.find_by_id(2) assert_nil WikiPage.find_by_id(2)
end end
def test_destroy_parent_with_cascade def test_destroy_parent_with_cascade
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference('WikiPage.count', -3) do assert_difference('WikiPage.count', -3) do
@ -364,7 +364,7 @@ class WikiControllerTest < ActionController::TestCase
assert_nil WikiPage.find_by_id(2) assert_nil WikiPage.find_by_id(2)
assert_nil WikiPage.find_by_id(5) assert_nil WikiPage.find_by_id(5)
end end
def test_destroy_parent_with_reassign def test_destroy_parent_with_reassign
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference('WikiPage.count', -1) do assert_difference('WikiPage.count', -1) do
@ -374,7 +374,7 @@ class WikiControllerTest < ActionController::TestCase
assert_nil WikiPage.find_by_id(2) assert_nil WikiPage.find_by_id(2)
assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
end end
def test_index def test_index
get :index, :project_id => 'ecookbook' get :index, :project_id => 'ecookbook'
assert_response :success assert_response :success
@ -383,7 +383,7 @@ class WikiControllerTest < ActionController::TestCase
assert_not_nil pages assert_not_nil pages
assert_equal Project.find(1).wiki.pages.size, pages.size assert_equal Project.find(1).wiki.pages.size, pages.size
assert_equal pages.first.content.updated_on, pages.first.updated_on assert_equal pages.first.content.updated_on, pages.first.updated_on
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' }, :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
:content => 'CookBook documentation' }, :content => 'CookBook documentation' },
@ -394,7 +394,7 @@ class WikiControllerTest < ActionController::TestCase
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' }, :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
:content => 'Another page' } } :content => 'Another page' } }
end end
def test_index_should_include_atom_link def test_index_should_include_atom_link
get :index, :project_id => 'ecookbook' get :index, :project_id => 'ecookbook'
assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'} assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'}
@ -406,7 +406,7 @@ class WikiControllerTest < ActionController::TestCase
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :export, :project_id => 'ecookbook' get :export, :project_id => 'ecookbook'
end end
should_respond_with :success should_respond_with :success
should_assign_to :pages should_assign_to :pages
should_respond_with_content_type "text/html" should_respond_with_content_type "text/html"
@ -415,7 +415,7 @@ class WikiControllerTest < ActionController::TestCase
assert_select "a[name=?]", "Another_page" assert_select "a[name=?]", "Another_page"
assert_select "a[name=?]", "Page_with_an_inline_image" assert_select "a[name=?]", "Page_with_an_inline_image"
end end
end end
context "with an unauthorized user" do context "with an unauthorized user" do
@ -437,17 +437,17 @@ class WikiControllerTest < ActionController::TestCase
should_assign_to :pages should_assign_to :pages
should_assign_to :pages_by_date should_assign_to :pages_by_date
should_render_template 'wiki/date_index' should_render_template 'wiki/date_index'
should "include atom link" do should "include atom link" do
assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'} assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'}
end end
end end
def test_not_found def test_not_found
get :show, :project_id => 999 get :show, :project_id => 999
assert_response 404 assert_response 404
end end
def test_protect_page def test_protect_page
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page') page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
assert !page.protected? assert !page.protected?
@ -456,7 +456,7 @@ class WikiControllerTest < ActionController::TestCase
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page' assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page'
assert page.reload.protected? assert page.reload.protected?
end end
def test_unprotect_page def test_unprotect_page
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation') page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation')
assert page.protected? assert page.protected?
@ -465,7 +465,7 @@ class WikiControllerTest < ActionController::TestCase
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'CookBook_documentation' assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'CookBook_documentation'
assert !page.reload.protected? assert !page.reload.protected?
end end
def test_show_page_with_edit_link def test_show_page_with_edit_link
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :show, :project_id => 1 get :show, :project_id => 1
@ -473,15 +473,15 @@ class WikiControllerTest < ActionController::TestCase
assert_template 'show' assert_template 'show'
assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
end end
def test_show_page_without_edit_link def test_show_page_without_edit_link
@request.session[:user_id] = 4 @request.session[:user_id] = 4
get :show, :project_id => 1 get :show, :project_id => 1
assert_response :success assert_response :success
assert_template 'show' assert_template 'show'
assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
end end
def test_edit_unprotected_page def test_edit_unprotected_page
# Non members can edit unprotected wiki pages # Non members can edit unprotected wiki pages
@request.session[:user_id] = 4 @request.session[:user_id] = 4
@ -489,21 +489,21 @@ class WikiControllerTest < ActionController::TestCase
assert_response :success assert_response :success
assert_template 'edit' assert_template 'edit'
end end
def test_edit_protected_page_by_nonmember def test_edit_protected_page_by_nonmember
# Non members can't edit protected wiki pages # Non members can't edit protected wiki pages
@request.session[:user_id] = 4 @request.session[:user_id] = 4
get :edit, :project_id => 1, :id => 'CookBook_documentation' get :edit, :project_id => 1, :id => 'CookBook_documentation'
assert_response 403 assert_response 403
end end
def test_edit_protected_page_by_member def test_edit_protected_page_by_member
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :edit, :project_id => 1, :id => 'CookBook_documentation' get :edit, :project_id => 1, :id => 'CookBook_documentation'
assert_response :success assert_response :success
assert_template 'edit' assert_template 'edit'
end end
def test_history_of_non_existing_page_should_return_404 def test_history_of_non_existing_page_should_return_404
get :history, :project_id => 1, :id => 'Unknown_page' get :history, :project_id => 1, :id => 'Unknown_page'
assert_response 404 assert_response 404