diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-11-24 12:25:07 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-11-24 12:25:07 +0000 |
commit | 29b3614bcb759214bb1aba77c27ac11c8ef6b15b (patch) | |
tree | 1783bd1f65552a4e2cea332bda9f42b1831d4e78 /test | |
parent | 866e9e2503713c67fd33b389d4e840c04ce1562d (diff) | |
download | redmine-29b3614bcb759214bb1aba77c27ac11c8ef6b15b.tar.gz redmine-29b3614bcb759214bb1aba77c27ac11c8ef6b15b.zip |
Forums enhancements:
* messages can now be edited/deleted (explicit permissions need to be given)
* topics can be locked so that no reply can be added (only by users allowed to edit messages)
* topics can be marked as sticky so that they always appear at the top of the list (only by users allowed to edit messages)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@926 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/boards.yml | 6 | ||||
-rw-r--r-- | test/fixtures/messages.yml | 38 | ||||
-rw-r--r-- | test/functional/boards_controller_test.rb | 50 | ||||
-rw-r--r-- | test/functional/messages_controller_test.rb | 49 | ||||
-rw-r--r-- | test/unit/message_test.rb | 26 |
5 files changed, 163 insertions, 6 deletions
diff --git a/test/fixtures/boards.yml b/test/fixtures/boards.yml index 7f2944fac..b6b42aaa3 100644 --- a/test/fixtures/boards.yml +++ b/test/fixtures/boards.yml @@ -2,12 +2,12 @@ boards_001:
name: Help
project_id: 1
- topics_count: 1
+ topics_count: 2
id: 1
description: Help board
position: 1
- last_message_id: 2
- messages_count: 2
+ last_message_id: 5
+ messages_count: 5
boards_002:
name: Discussion
project_id: 1
diff --git a/test/fixtures/messages.yml b/test/fixtures/messages.yml index 88f54dbc2..5bb2438dd 100644 --- a/test/fixtures/messages.yml +++ b/test/fixtures/messages.yml @@ -4,8 +4,8 @@ messages_001: updated_on: 2007-05-12 17:15:32 +02:00
subject: First post
id: 1
- replies_count: 1
- last_reply_id: 2
+ replies_count: 2
+ last_reply_id: 3
content: "This is the very first post\n\
in the forum"
author_id: 1
@@ -22,4 +22,36 @@ messages_002: author_id: 1
parent_id: 1
board_id: 1
-
\ No newline at end of file +messages_003:
+ created_on: 2007-05-12 17:18:02 +02:00
+ updated_on: 2007-05-12 17:18:02 +02:00
+ subject: "RE: First post"
+ id: 3
+ replies_count: 0
+ last_reply_id:
+ content: "An other reply"
+ author_id:
+ parent_id: 1
+ board_id: 1
+messages_004:
+ created_on: 2007-08-12 17:15:32 +02:00
+ updated_on: 2007-08-12 17:15:32 +02:00
+ subject: Post 2
+ id: 4
+ replies_count: 1
+ last_reply_id: 5
+ content: "This is an other post"
+ author_id:
+ parent_id:
+ board_id: 1
+messages_005:
+ created_on: 2007-09-12 17:18:00 +02:00
+ updated_on: 2007-09-12 17:18:00 +02:00
+ subject: 'RE: post 2'
+ id: 5
+ replies_count: 0
+ last_reply_id:
+ content: "Reply to the second post"
+ author_id: 1
+ parent_id: 4
+ board_id: 1
diff --git a/test/functional/boards_controller_test.rb b/test/functional/boards_controller_test.rb new file mode 100644 index 000000000..3ff71bc4e --- /dev/null +++ b/test/functional/boards_controller_test.rb @@ -0,0 +1,50 @@ +# 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' +require 'boards_controller' + +# Re-raise errors caught by the controller. +class BoardsController; def rescue_action(e) raise e end; end + +class BoardsControllerTest < Test::Unit::TestCase + fixtures :projects, :users, :members, :roles, :boards, :messages, :enabled_modules + + def setup + @controller = BoardsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + User.current = nil + end + + def test_index + get :index, :project_id => 1 + assert_response :success + assert_template 'index' + assert_not_nil assigns(:boards) + assert_not_nil assigns(:project) + end + + def test_show + get :show, :project_id => 1, :id => 1 + assert_response :success + assert_template 'show' + assert_not_nil assigns(:board) + assert_not_nil assigns(:project) + assert_not_nil assigns(:topics) + end +end diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb new file mode 100644 index 000000000..25fc1363e --- /dev/null +++ b/test/functional/messages_controller_test.rb @@ -0,0 +1,49 @@ +# 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' +require 'messages_controller' + +# Re-raise errors caught by the controller. +class MessagesController; def rescue_action(e) raise e end; end + +class MessagesControllerTest < Test::Unit::TestCase + fixtures :projects, :users, :members, :roles, :boards, :messages, :enabled_modules + + def setup + @controller = MessagesController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + User.current = nil + end + + def test_show + get :show, :board_id => 1, :id => 1 + assert_response :success + assert_template 'show' + assert_not_nil assigns(:board) + assert_not_nil assigns(:project) + assert_not_nil assigns(:topic) + end + + def test_reply + @request.session[:user_id] = 2 + post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' } + assert_redirected_to 'messages/show' + assert Message.find_by_subject('Test reply') + end +end diff --git a/test/unit/message_test.rb b/test/unit/message_test.rb index 6d8458bfc..82ed3fe13 100644 --- a/test/unit/message_test.rb +++ b/test/unit/message_test.rb @@ -41,4 +41,30 @@ class MessageTest < Test::Unit::TestCase assert_equal replies_count+1, @message[:replies_count] assert_equal reply, @message.last_reply end + + def test_destroy_topic + message = Message.find(1) + board = message.board + topics_count, messages_count = board.topics_count, board.messages_count + assert message.destroy + board.reload + + # Replies deleted + assert Message.find_all_by_parent_id(1).empty? + # Checks counters + assert_equal topics_count - 1, board.topics_count + assert_equal messages_count - 3, board.messages_count + end + + def test_destroy_reply + message = Message.find(5) + board = message.board + topics_count, messages_count = board.topics_count, board.messages_count + assert message.destroy + board.reload + + # Checks counters + assert_equal topics_count, board.topics_count + assert_equal messages_count - 1, board.messages_count + end end |