Commit 6d2eb0485b77962dc1eec007b07b5e8696e64a18
Committed by
Antonio Terceiro
1 parent
487508e7
Exists in
master
and in
29 other branches
Fixes problem of downloading a file after press save button at article edition
(ActionItem1775)
Showing
2 changed files
with
30 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -94,7 +94,11 @@ class CmsController < MyProfileController |
94 | 94 | @article.last_changed_by = user |
95 | 95 | if @article.update_attributes(params[:article]) |
96 | 96 | if !continue |
97 | - redirect_to @article.view_url | |
97 | + if @article.content_type.nil? || @article.image? | |
98 | + redirect_to @article.view_url | |
99 | + else | |
100 | + redirect_to :action => (@article.parent ? 'view' : 'index'), :id => @article.parent | |
101 | + end | |
98 | 102 | end |
99 | 103 | end |
100 | 104 | end | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -1551,4 +1551,29 @@ class CmsControllerTest < Test::Unit::TestCase |
1551 | 1551 | assert_tag :a, :content => "An image" |
1552 | 1552 | end |
1553 | 1553 | |
1554 | + should 'update image and be redirect to view_page' do | |
1555 | + image = UploadedFile.create!(:profile => @profile, :uploaded_data => fixture_file_upload('files/rails.png', 'image/png')) | |
1556 | + post :edit, :profile => @profile.identifier, :id => image.id, :article => { } | |
1557 | + assert_redirected_to image.view_url | |
1558 | + end | |
1559 | + | |
1560 | + should 'update article and be redirect to view_page' do | |
1561 | + a = fast_create(TextileArticle, :profile_id => @profile.id) | |
1562 | + post :edit, :profile => @profile.identifier, :id => a.id, :article => { } | |
1563 | + assert_redirected_to a.view_url | |
1564 | + end | |
1565 | + | |
1566 | + should 'update file and be redirect to cms' do | |
1567 | + file = UploadedFile.create!(:profile => @profile, :uploaded_data => fixture_file_upload('files/test.txt', 'text/plain')) | |
1568 | + post :edit, :profile => @profile.identifier, :id => file.id, :article => { } | |
1569 | + assert_redirected_to :action => 'index' | |
1570 | + end | |
1571 | + | |
1572 | + should 'update file and be redirect to cms folder' do | |
1573 | + f = fast_create(Folder, :profile_id => @profile.id, :name => 'foldername') | |
1574 | + file = UploadedFile.create!(:profile => @profile, :uploaded_data => fixture_file_upload('files/test.txt', 'text/plain'), :parent_id => f.id) | |
1575 | + post :edit, :profile => @profile.identifier, :id => file.id, :article => { :title => 'text file' } | |
1576 | + assert_redirected_to :action => 'view', :id => f | |
1577 | + end | |
1578 | + | |
1554 | 1579 | end | ... | ... |