annotate .svn/pristine/ed/ed5bb906160f4429daa38295e07869df8d886c4e.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

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