Commit 9c58ba961a4f878c61e497ac768f4385a70d9a4b
1 parent
aa1425d7
Exists in
master
and in
28 other branches
Allowing upload out of a folder
(ActionItem2521)
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| @@ -18,7 +18,7 @@ class CmsController < MyProfileController | @@ -18,7 +18,7 @@ class CmsController < MyProfileController | ||
| 18 | 18 | ||
| 19 | protect_if :only => :upload_files do |c, user, profile| | 19 | protect_if :only => :upload_files do |c, user, profile| |
| 20 | article_id = c.params[:parent_id] | 20 | article_id = c.params[:parent_id] |
| 21 | - (article_id && profile.articles.find(article_id).allow_create?(user)) || | 21 | + (!article_id.blank? && profile.articles.find(article_id).allow_create?(user)) || |
| 22 | (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))) | 22 | (user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))) |
| 23 | end | 23 | end |
| 24 | 24 |
test/functional/cms_controller_test.rb
| @@ -296,6 +296,13 @@ class CmsControllerTest < ActionController::TestCase | @@ -296,6 +296,13 @@ class CmsControllerTest < ActionController::TestCase | ||
| 296 | assert_not_nil profile.articles.find_by_path('test.txt') | 296 | assert_not_nil profile.articles.find_by_path('test.txt') |
| 297 | end | 297 | end |
| 298 | 298 | ||
| 299 | + should 'not crash when parent_id is blank' do | ||
| 300 | + assert_nothing_raised do | ||
| 301 | + post :upload_files, :profile => profile.identifier, :parent_id => '', :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain'), '' ] | ||
| 302 | + end | ||
| 303 | + assert_not_nil profile.articles.find_by_path('test.txt') | ||
| 304 | + end | ||
| 305 | + | ||
| 299 | should 'redirect to cms after uploading files' do | 306 | should 'redirect to cms after uploading files' do |
| 300 | post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain')] | 307 | post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain')] |
| 301 | assert_redirected_to :action => 'index' | 308 | assert_redirected_to :action => 'index' |