diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-09-22 16:25:09 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-09-22 16:25:09 +0000 |
commit | 1f2f9536875a0383f0ac61e0fdd089b666c96070 (patch) | |
tree | 856bfa4645d723b5eb39c754369fa1a00d3ccd86 /test/functional/comments_controller_test.rb | |
parent | 3b20774c543d33afe10ff794ee8382f1d8e017e9 (diff) | |
download | redmine-1f2f9536875a0383f0ac61e0fdd089b666c96070.tar.gz redmine-1f2f9536875a0383f0ac61e0fdd089b666c96070.zip |
Refactor: move NewsController#add_comment to CommentsController#create
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4170 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/comments_controller_test.rb')
-rw-r--r-- | test/functional/comments_controller_test.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb new file mode 100644 index 000000000..1a9d628d8 --- /dev/null +++ b/test/functional/comments_controller_test.rb @@ -0,0 +1,46 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require File.dirname(__FILE__) + '/../test_helper' + +class CommentsControllerTest < ActionController::TestCase + fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :news, :comments + + def setup + User.current = nil + end + + def test_add_comment + @request.session[:user_id] = 2 + post :create, :id => 1, :comment => { :comments => 'This is a test comment' } + assert_redirected_to 'news/1' + + comment = News.find(1).comments.find(:first, :order => 'created_on DESC') + assert_not_nil comment + assert_equal 'This is a test comment', comment.comments + assert_equal User.find(2), comment.author + end + + def test_empty_comment_should_not_be_added + @request.session[:user_id] = 2 + assert_no_difference 'Comment.count' do + post :create, :id => 1, :comment => { :comments => '' } + assert_response :redirect + assert_redirected_to 'news/1' + end + end +end |