You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wikis_controller_test.rb 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2015 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. require File.expand_path('../../test_helper', __FILE__)
  18. class WikisControllerTest < ActionController::TestCase
  19. fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis
  20. def setup
  21. User.current = nil
  22. end
  23. def test_create
  24. @request.session[:user_id] = 1
  25. assert_nil Project.find(3).wiki
  26. assert_difference 'Wiki.count' do
  27. xhr :post, :edit, :id => 3, :wiki => { :start_page => 'Start page' }
  28. assert_response :success
  29. assert_template 'edit'
  30. assert_equal 'text/javascript', response.content_type
  31. end
  32. wiki = Project.find(3).wiki
  33. assert_not_nil wiki
  34. assert_equal 'Start page', wiki.start_page
  35. end
  36. def test_create_with_failure
  37. @request.session[:user_id] = 1
  38. assert_no_difference 'Wiki.count' do
  39. xhr :post, :edit, :id => 3, :wiki => { :start_page => '' }
  40. assert_response :success
  41. assert_template 'edit'
  42. assert_equal 'text/javascript', response.content_type
  43. end
  44. assert_include 'errorExplanation', response.body
  45. assert_include "Start page cannot be blank", response.body
  46. end
  47. def test_update
  48. @request.session[:user_id] = 1
  49. assert_no_difference 'Wiki.count' do
  50. xhr :post, :edit, :id => 1, :wiki => { :start_page => 'Other start page' }
  51. assert_response :success
  52. assert_template 'edit'
  53. assert_equal 'text/javascript', response.content_type
  54. end
  55. wiki = Project.find(1).wiki
  56. assert_equal 'Other start page', wiki.start_page
  57. end
  58. def test_destroy
  59. @request.session[:user_id] = 1
  60. post :destroy, :id => 1, :confirm => 1
  61. assert_redirected_to :controller => 'projects',
  62. :action => 'settings', :id => 'ecookbook', :tab => 'wiki'
  63. assert_nil Project.find(1).wiki
  64. end
  65. def test_not_found
  66. @request.session[:user_id] = 1
  67. post :destroy, :id => 999, :confirm => 1
  68. assert_response 404
  69. end
  70. end