Adds functional tests for DocumentsController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8005 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f20212bc04
commit
afb84b6823
@ -51,6 +51,24 @@ class DocumentsControllerTest < ActionController::TestCase
|
|||||||
:parent => {:tag => 'select', :attributes => {:id => 'document_category_id'} }
|
:parent => {:tag => 'select', :attributes => {:id => 'document_category_id'} }
|
||||||
end
|
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
|
def test_index_with_long_description
|
||||||
# adds a long description to the first document
|
# adds a long description to the first document
|
||||||
doc = documents(:documents_001)
|
doc = documents(:documents_001)
|
||||||
@ -69,6 +87,12 @@ LOREM
|
|||||||
assert_select '.wiki p', :text => Regexp.new(Regexp.escape("EndOfLineHere..."))
|
assert_select '.wiki p', :text => Regexp.new(Regexp.escape("EndOfLineHere..."))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_show
|
||||||
|
get :show, :id => 1
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'show'
|
||||||
|
end
|
||||||
|
|
||||||
def test_new_with_one_attachment
|
def test_new_with_one_attachment
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
Setting.notified_events << 'document_added'
|
Setting.notified_events << 'document_added'
|
||||||
@ -91,10 +115,37 @@ LOREM
|
|||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
end
|
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
|
def test_destroy
|
||||||
@request.session[:user_id] = 2
|
@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_redirected_to '/projects/ecookbook/documents'
|
||||||
assert_nil Document.find_by_id(1)
|
assert_nil Document.find_by_id(1)
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user