@@ -51,6 +51,24 class DocumentsControllerTest < ActionController::TestCase | |||
|
51 | 51 | :parent => {:tag => 'select', :attributes => {:id => 'document_category_id'} } |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | def test_index_grouped_by_date | |
|
55 | get :index, :project_id => 'ecookbook', :sort_by => 'date' | |
|
56 | assert_response :success | |
|
57 | assert_tag 'h3', :content => '2007-02-12' | |
|
58 | end | |
|
59 | ||
|
60 | def test_index_grouped_by_title | |
|
61 | get :index, :project_id => 'ecookbook', :sort_by => 'title' | |
|
62 | assert_response :success | |
|
63 | assert_tag 'h3', :content => 'T' | |
|
64 | end | |
|
65 | ||
|
66 | def test_index_grouped_by_author | |
|
67 | get :index, :project_id => 'ecookbook', :sort_by => 'author' | |
|
68 | assert_response :success | |
|
69 | assert_tag 'h3', :content => 'John Smith' | |
|
70 | end | |
|
71 | ||
|
54 | 72 | def test_index_with_long_description |
|
55 | 73 | # adds a long description to the first document |
|
56 | 74 | doc = documents(:documents_001) |
@@ -69,6 +87,12 LOREM | |||
|
69 | 87 | assert_select '.wiki p', :text => Regexp.new(Regexp.escape("EndOfLineHere...")) |
|
70 | 88 | end |
|
71 | 89 | |
|
90 | def test_show | |
|
91 | get :show, :id => 1 | |
|
92 | assert_response :success | |
|
93 | assert_template 'show' | |
|
94 | end | |
|
95 | ||
|
72 | 96 | def test_new_with_one_attachment |
|
73 | 97 | ActionMailer::Base.deliveries.clear |
|
74 | 98 | Setting.notified_events << 'document_added' |
@@ -91,10 +115,37 LOREM | |||
|
91 | 115 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
92 | 116 | end |
|
93 | 117 | |
|
118 | def test_edit | |
|
119 | @request.session[:user_id] = 2 | |
|
120 | get :edit, :id => 1 | |
|
121 | assert_response :success | |
|
122 | assert_template 'edit' | |
|
123 | end | |
|
124 | ||
|
125 | def test_update | |
|
126 | @request.session[:user_id] = 2 | |
|
127 | post :edit, :id => 1, :document => {:title => 'test_update'} | |
|
128 | assert_redirected_to '/documents/1' | |
|
129 | document = Document.find(1) | |
|
130 | assert_equal 'test_update', document.title | |
|
131 | end | |
|
132 | ||
|
94 | 133 | def test_destroy |
|
95 | 134 | @request.session[:user_id] = 2 |
|
96 | post :destroy, :id => 1 | |
|
135 | assert_difference 'Document.count', -1 do | |
|
136 | post :destroy, :id => 1 | |
|
137 | end | |
|
97 | 138 | assert_redirected_to '/projects/ecookbook/documents' |
|
98 | 139 | assert_nil Document.find_by_id(1) |
|
99 | 140 | end |
|
141 | ||
|
142 | def test_add_attachment | |
|
143 | @request.session[:user_id] = 2 | |
|
144 | assert_difference 'Attachment.count' do | |
|
145 | post :add_attachment, :id => 1, | |
|
146 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
|
147 | end | |
|
148 | attachment = Attachment.first(:order => 'id DESC') | |
|
149 | assert_equal Document.find(1), attachment.container | |
|
150 | end | |
|
100 | 151 | end |
General Comments 0
You need to be logged in to leave comments.
Login now