Commit 229bedeceae9dd30c418fd7fd2eb99980af49174
Committed by
Antonio Terceiro
1 parent
a27582e6
Exists in
master
and in
29 other branches
ActionItem970: displaying destination path when uploading files
Showing
3 changed files
with
16 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -135,6 +135,7 @@ class CmsController < MyProfileController | @@ -135,6 +135,7 @@ class CmsController < MyProfileController | ||
135 | def upload_files | 135 | def upload_files |
136 | @uploaded_files = [] | 136 | @uploaded_files = [] |
137 | @article = @parent = check_parent(params[:parent_id]) | 137 | @article = @parent = check_parent(params[:parent_id]) |
138 | + @target = @parent ? ('/%s/%s' % [profile.identifier, @parent.full_name]) : '/%s' % profile.identifier | ||
138 | record_coming_from_public_view if @article | 139 | record_coming_from_public_view if @article |
139 | if request.post? && params[:uploaded_files] | 140 | if request.post? && params[:uploaded_files] |
140 | params[:uploaded_files].each do |file| | 141 | params[:uploaded_files].each do |file| |
app/views/cms/upload_files.rhtml
@@ -10,7 +10,6 @@ | @@ -10,7 +10,6 @@ | ||
10 | <% end %> | 10 | <% end %> |
11 | </ul> | 11 | </ul> |
12 | </div> | 12 | </div> |
13 | - | ||
14 | <% end %> | 13 | <% end %> |
15 | 14 | ||
16 | <h2><%= _('Publish media') %></h2> | 15 | <h2><%= _('Publish media') %></h2> |
@@ -18,6 +17,8 @@ | @@ -18,6 +17,8 @@ | ||
18 | <h3><%= _("Select the files you want to upload (max size %s):") % UploadedFile.max_size.to_humanreadable %></h3> | 17 | <h3><%= _("Select the files you want to upload (max size %s):") % UploadedFile.max_size.to_humanreadable %></h3> |
19 | <h4><%= _('Documents, Images, Videos, Audio') %></h4> | 18 | <h4><%= _('Documents, Images, Videos, Audio') %></h4> |
20 | 19 | ||
20 | +<h5><%= _('Uploading files to %s') % content_tag('code', @target) %></h5> | ||
21 | + | ||
21 | <% form_for('uploaded_file', :url => { :action => 'upload_files' }, :html => {:multipart => true}) do |f| %> | 22 | <% form_for('uploaded_file', :url => { :action => 'upload_files' }, :html => {:multipart => true}) do |f| %> |
22 | 23 | ||
23 | <div id='uploaded_files'> | 24 | <div id='uploaded_files'> |
test/functional/cms_controller_test.rb
@@ -227,6 +227,19 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -227,6 +227,19 @@ class CmsControllerTest < Test::Unit::TestCase | ||
227 | assert_equal 'test.txt', f.children[0].name | 227 | assert_equal 'test.txt', f.children[0].name |
228 | end | 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 | should 'not crash on empty file' do | 243 | should 'not crash on empty file' do |
231 | assert_nothing_raised do | 244 | assert_nothing_raised do |
232 | post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain'), '' ] | 245 | post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain'), '' ] |