@@ -51,6 +51,24 class DocumentsControllerTest < ActionController::TestCase | |||||
51 | :parent => {:tag => 'select', :attributes => {:id => 'document_category_id'} } |
|
51 | :parent => {:tag => 'select', :attributes => {:id => 'document_category_id'} } | |
52 | end |
|
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 | def test_index_with_long_description |
|
72 | def test_index_with_long_description | |
55 | # adds a long description to the first document |
|
73 | # adds a long description to the first document | |
56 | doc = documents(:documents_001) |
|
74 | doc = documents(:documents_001) | |
@@ -69,6 +87,12 LOREM | |||||
69 | assert_select '.wiki p', :text => Regexp.new(Regexp.escape("EndOfLineHere...")) |
|
87 | assert_select '.wiki p', :text => Regexp.new(Regexp.escape("EndOfLineHere...")) | |
70 | end |
|
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 | def test_new_with_one_attachment |
|
96 | def test_new_with_one_attachment | |
73 | ActionMailer::Base.deliveries.clear |
|
97 | ActionMailer::Base.deliveries.clear | |
74 | Setting.notified_events << 'document_added' |
|
98 | Setting.notified_events << 'document_added' | |
@@ -91,10 +115,37 LOREM | |||||
91 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
115 | assert_equal 1, ActionMailer::Base.deliveries.size | |
92 | end |
|
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 | def test_destroy |
|
133 | def test_destroy | |
95 | @request.session[:user_id] = 2 |
|
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 | assert_redirected_to '/projects/ecookbook/documents' |
|
138 | assert_redirected_to '/projects/ecookbook/documents' | |
98 | assert_nil Document.find_by_id(1) |
|
139 | assert_nil Document.find_by_id(1) | |
99 | end |
|
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 | end |
|
151 | end |
General Comments 0
You need to be logged in to leave comments.
Login now