summaryrefslogtreecommitdiffstats
path: root/test/functional/messages_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-12-13 18:52:09 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-12-13 18:52:09 +0000
commit48949f979a7d132ccbbc2239cd9e4ecf35fdeef5 (patch)
treedddfe3ebc99f33c4165665239fda38ab8a5a0d46 /test/functional/messages_controller_test.rb
parent86d756d22d6c191920970165d2dc40d1e823351d (diff)
downloadredmine-48949f979a7d132ccbbc2239cd9e4ecf35fdeef5.tar.gz
redmine-48949f979a7d132ccbbc2239cd9e4ecf35fdeef5.zip
Added some functional tests and a CVS test repository.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@987 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/messages_controller_test.rb')
-rw-r--r--test/functional/messages_controller_test.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb
index 25fc1363e..dcfe0caa7 100644
--- a/test/functional/messages_controller_test.rb
+++ b/test/functional/messages_controller_test.rb
@@ -40,10 +40,60 @@ class MessagesControllerTest < Test::Unit::TestCase
assert_not_nil assigns(:topic)
end
+ def test_show_message_not_found
+ get :show, :board_id => 1, :id => 99999
+ assert_response 404
+ end
+
+ def test_get_new
+ @request.session[:user_id] = 2
+ get :new, :board_id => 1
+ assert_response :success
+ assert_template 'new'
+ end
+
+ def test_post_new
+ @request.session[:user_id] = 2
+ post :new, :board_id => 1,
+ :message => { :subject => 'Test created message',
+ :content => 'Message body'}
+ assert_redirected_to 'messages/show'
+ message = Message.find_by_subject('Test created message')
+ assert_not_nil message
+ assert_equal 'Message body', message.content
+ assert_equal 2, message.author_id
+ assert_equal 1, message.board_id
+ end
+
+ def test_get_edit
+ @request.session[:user_id] = 2
+ get :edit, :board_id => 1, :id => 1
+ assert_response :success
+ assert_template 'edit'
+ end
+
+ def test_post_edit
+ @request.session[:user_id] = 2
+ post :edit, :board_id => 1, :id => 1,
+ :message => { :subject => 'New subject',
+ :content => 'New body'}
+ assert_redirected_to 'messages/show'
+ message = Message.find(1)
+ assert_equal 'New subject', message.subject
+ assert_equal 'New body', message.content
+ 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
+
+ def test_destroy_topic
+ @request.session[:user_id] = 2
+ post :destroy, :board_id => 1, :id => 1
+ assert_redirected_to 'boards/show'
+ assert_nil Message.find_by_id(1)
+ end
end