Added some functional tests and a CVS test repository.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@987 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2007-12-13 18:52:09 +00:00
parent 86d756d22d
commit 48949f979a
14 changed files with 406 additions and 4 deletions
@@ -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