Commit 229bedeceae9dd30c418fd7fd2eb99980af49174

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent a27582e6

ActionItem970: displaying destination path when uploading files

app/controllers/my_profile/cms_controller.rb
... ... @@ -135,6 +135,7 @@ class CmsController < MyProfileController
135 135 def upload_files
136 136 @uploaded_files = []
137 137 @article = @parent = check_parent(params[:parent_id])
  138 + @target = @parent ? ('/%s/%s' % [profile.identifier, @parent.full_name]) : '/%s' % profile.identifier
138 139 record_coming_from_public_view if @article
139 140 if request.post? && params[:uploaded_files]
140 141 params[:uploaded_files].each do |file|
... ...
app/views/cms/upload_files.rhtml
... ... @@ -10,7 +10,6 @@
10 10 <% end %>
11 11 </ul>
12 12 </div>
13   -
14 13 <% end %>
15 14  
16 15 <h2><%= _('Publish media') %></h2>
... ... @@ -18,6 +17,8 @@
18 17 <h3><%= _("Select the files you want to upload (max size %s):") % UploadedFile.max_size.to_humanreadable %></h3>
19 18 <h4><%= _('Documents, Images, Videos, Audio') %></h4>
20 19  
  20 +<h5><%= _('Uploading files to %s') % content_tag('code', @target) %></h5>
  21 +
21 22 <% form_for('uploaded_file', :url => { :action => 'upload_files' }, :html => {:multipart => true}) do |f| %>
22 23  
23 24 <div id='uploaded_files'>
... ...
test/functional/cms_controller_test.rb
... ... @@ -227,6 +227,19 @@ class CmsControllerTest &lt; Test::Unit::TestCase
227 227 assert_equal 'test.txt', f.children[0].name
228 228 end
229 229  
  230 + should 'display destination folder of files when uploading file in root folder' do
  231 + get :upload_files, :profile => profile.identifier
  232 +
  233 + assert_tag :tag => 'h5', :descendant => { :tag => 'code', :content => /\/#{profile.identifier}/ }
  234 + end
  235 +
  236 + should 'display destination folder of files when uploading file' do
  237 + f = Folder.new(:name => 'f'); profile.articles << f; f.save!
  238 + get :upload_files, :profile => profile.identifier, :parent_id => f.id
  239 +
  240 + assert_tag :tag => 'h5', :descendant => { :tag => 'code', :content => /\/#{profile.identifier}\/#{f.full_name}/}
  241 + end
  242 +
230 243 should 'not crash on empty file' do
231 244 assert_nothing_raised do
232 245 post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain'), '' ]
... ...