diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-30 18:59:06 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-30 18:59:06 +0000 |
commit | afb84b682313914d7dd275e825fdd847552fc4a1 (patch) | |
tree | 2176e706897180fc1aeffed367a6fe1f79be2772 /test/functional/documents_controller_test.rb | |
parent | f20212bc0461e8bcc59b2fc830f44fab59dbd255 (diff) | |
download | redmine-afb84b682313914d7dd275e825fdd847552fc4a1.tar.gz redmine-afb84b682313914d7dd275e825fdd847552fc4a1.zip |
Adds functional tests for DocumentsController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8005 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/documents_controller_test.rb')
-rw-r--r-- | test/functional/documents_controller_test.rb | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/test/functional/documents_controller_test.rb b/test/functional/documents_controller_test.rb index 423faf6c9..77abc7efd 100644 --- a/test/functional/documents_controller_test.rb +++ b/test/functional/documents_controller_test.rb @@ -51,6 +51,24 @@ class DocumentsControllerTest < ActionController::TestCase :parent => {:tag => 'select', :attributes => {:id => 'document_category_id'} } end + def test_index_grouped_by_date + get :index, :project_id => 'ecookbook', :sort_by => 'date' + assert_response :success + assert_tag 'h3', :content => '2007-02-12' + end + + def test_index_grouped_by_title + get :index, :project_id => 'ecookbook', :sort_by => 'title' + assert_response :success + assert_tag 'h3', :content => 'T' + end + + def test_index_grouped_by_author + get :index, :project_id => 'ecookbook', :sort_by => 'author' + assert_response :success + assert_tag 'h3', :content => 'John Smith' + end + def test_index_with_long_description # adds a long description to the first document doc = documents(:documents_001) @@ -69,6 +87,12 @@ LOREM assert_select '.wiki p', :text => Regexp.new(Regexp.escape("EndOfLineHere...")) end + def test_show + get :show, :id => 1 + assert_response :success + assert_template 'show' + end + def test_new_with_one_attachment ActionMailer::Base.deliveries.clear Setting.notified_events << 'document_added' @@ -91,10 +115,37 @@ LOREM assert_equal 1, ActionMailer::Base.deliveries.size end + def test_edit + @request.session[:user_id] = 2 + get :edit, :id => 1 + assert_response :success + assert_template 'edit' + end + + def test_update + @request.session[:user_id] = 2 + post :edit, :id => 1, :document => {:title => 'test_update'} + assert_redirected_to '/documents/1' + document = Document.find(1) + assert_equal 'test_update', document.title + end + def test_destroy @request.session[:user_id] = 2 - post :destroy, :id => 1 + assert_difference 'Document.count', -1 do + post :destroy, :id => 1 + end assert_redirected_to '/projects/ecookbook/documents' assert_nil Document.find_by_id(1) end + + def test_add_attachment + @request.session[:user_id] = 2 + assert_difference 'Attachment.count' do + post :add_attachment, :id => 1, + :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} + end + attachment = Attachment.first(:order => 'id DESC') + assert_equal Document.find(1), attachment.container + end end |