summaryrefslogtreecommitdiffstats
path: root/test/functional/documents_controller_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/documents_controller_test.rb')
-rw-r--r--test/functional/documents_controller_test.rb99
1 files changed, 75 insertions, 24 deletions
diff --git a/test/functional/documents_controller_test.rb b/test/functional/documents_controller_test.rb
index ad1e6b567..21c7c4f72 100644
--- a/test/functional/documents_controller_test.rb
+++ b/test/functional/documents_controller_test.rb
@@ -31,7 +31,9 @@ class DocumentsControllerTest < Redmine::ControllerTest
e = Enumeration.find_by_name('Technical documentation')
e.update_attributes(:is_default => true)
- get :index, :project_id => 'ecookbook'
+ get :index, :params => {
+ :project_id => 'ecookbook'
+ }
assert_response :success
# Default category selected in the new document form
@@ -44,19 +46,28 @@ class DocumentsControllerTest < Redmine::ControllerTest
end
def test_index_grouped_by_date
- get :index, :project_id => 'ecookbook', :sort_by => 'date'
+ get :index, :params => {
+ :project_id => 'ecookbook',
+ :sort_by => 'date'
+ }
assert_response :success
assert_select 'h3', :text => '2007-02-12'
end
def test_index_grouped_by_title
- get :index, :project_id => 'ecookbook', :sort_by => 'title'
+ get :index, :params => {
+ :project_id => 'ecookbook',
+ :sort_by => 'title'
+ }
assert_response :success
assert_select 'h3', :text => 'T'
end
def test_index_grouped_by_author
- get :index, :project_id => 'ecookbook', :sort_by => 'author'
+ get :index, :params => {
+ :project_id => 'ecookbook',
+ :sort_by => 'author'
+ }
assert_response :success
assert_select 'h3', :text => 'John Smith'
end
@@ -70,7 +81,9 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut egestas, mi vehicula
Vestibulum non velit mi. Aliquam scelerisque libero ut nulla fringilla a sollicitudin magna rhoncus. Praesent a nunc lorem, ac porttitor eros. Sed ac diam nec neque interdum adipiscing quis quis justo. Donec arcu nunc, fringilla eu dictum at, venenatis ac sem. Vestibulum quis elit urna, ac mattis sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
LOREM
- get :index, :project_id => 'ecookbook'
+ get :index, :params => {
+ :project_id => 'ecookbook'
+ }
assert_response :success
# should only truncate on new lines to avoid breaking wiki formatting
@@ -79,13 +92,17 @@ LOREM
end
def test_show
- get :show, :id => 1
+ get :show, :params => {
+ :id => 1
+ }
assert_response :success
end
def test_new
@request.session[:user_id] = 2
- get :new, :project_id => 1
+ get :new, :params => {
+ :project_id => 1
+ }
assert_response :success
end
@@ -95,11 +112,18 @@ LOREM
set_tmp_attachments_directory
with_settings :notified_events => %w(document_added) do
- post :create, :project_id => 'ecookbook',
- :document => { :title => 'DocumentsControllerTest#test_post_new',
- :description => 'This is a new document',
- :category_id => 2},
- :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
+ post :create, :params => {
+ :project_id => 'ecookbook',
+ :document => {
+ :title => 'DocumentsControllerTest#test_post_new',
+ :description => 'This is a new document',
+ :category_id => 2
+ },
+ :attachments => {
+ '1' => {
+ 'file' => uploaded_test_file('testfile.txt', 'text/plain')}
+ }
+ }
end
assert_redirected_to '/projects/ecookbook/documents'
@@ -114,7 +138,12 @@ LOREM
def test_create_with_failure
@request.session[:user_id] = 2
assert_no_difference 'Document.count' do
- post :create, :project_id => 'ecookbook', :document => { :title => ''}
+ post :create, :params => {
+ :project_id => 'ecookbook',
+ :document => {
+ :title => ''
+ }
+ }
end
assert_response :success
assert_select_error /title cannot be blank/i
@@ -125,11 +154,14 @@ LOREM
category2 = Enumeration.find_by_name('User documentation')
category2.update_attributes(:is_default => true)
category1 = Enumeration.find_by_name('Uncategorized')
- post :create,
- :project_id => 'ecookbook',
- :document => { :title => 'no default',
- :description => 'This is a new document',
- :category_id => category1.id }
+ post :create, :params => {
+ :project_id => 'ecookbook',
+ :document => {
+ :title => 'no default',
+ :description => 'This is a new document',
+ :category_id => category1.id
+ }
+ }
assert_redirected_to '/projects/ecookbook/documents'
doc = Document.find_by_title('no default')
assert_not_nil doc
@@ -139,13 +171,20 @@ LOREM
def test_edit
@request.session[:user_id] = 2
- get :edit, :id => 1
+ get :edit, :params => {
+ :id => 1
+ }
assert_response :success
end
def test_update
@request.session[:user_id] = 2
- put :update, :id => 1, :document => {:title => 'test_update'}
+ put :update, :params => {
+ :id => 1,
+ :document => {
+ :title => 'test_update'
+ }
+ }
assert_redirected_to '/documents/1'
document = Document.find(1)
assert_equal 'test_update', document.title
@@ -153,7 +192,12 @@ LOREM
def test_update_with_failure
@request.session[:user_id] = 2
- put :update, :id => 1, :document => {:title => ''}
+ put :update, :params => {
+ :id => 1,
+ :document => {
+ :title => ''
+ }
+ }
assert_response :success
assert_select_error /title cannot be blank/i
end
@@ -161,7 +205,9 @@ LOREM
def test_destroy
@request.session[:user_id] = 2
assert_difference 'Document.count', -1 do
- delete :destroy, :id => 1
+ delete :destroy, :params => {
+ :id => 1
+ }
end
assert_redirected_to '/projects/ecookbook/documents'
assert_nil Document.find_by_id(1)
@@ -170,8 +216,13 @@ LOREM
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')}}
+ post :add_attachment, :params => {
+ :id => 1,
+ :attachments => {
+ '1' => {
+ 'file' => uploaded_test_file('testfile.txt', 'text/plain')}
+ }
+ }
end
attachment = Attachment.order('id DESC').first
assert_equal Document.find(1), attachment.container