Update returns to index.

DeLynn Berry committed Apr 02, 2011
commit 9bc208daa5a6c87621561d3f502c0f78a180d96e
Showing 2 changed files with 16 additions and 2 deletions
app/controllers/cms_admin/layouts_controller.rb +1 -1
@@ @@ -28,7 +28,7 @@ class CmsAdmin::LayoutsController < CmsAdmin::BaseController
def update
@cms_layout.update_attributes!(params[:cms_layout])
flash[:notice] = 'Layout updated'
- redirect_to :action => :edit, :id => @cms_layout
+ redirect_to (params[:commit] ? {:action => :index} : {:action => :edit, :id => @cms_layout})
rescue ActiveRecord::RecordInvalid
flash.now[:error] = 'Failed to update layout'
render :action => :edit
test/functional/cms_admin/layouts_controller_test.rb +15 -1
@@ @@ -80,7 +80,21 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase
end
end
- def test_update
+ def test_update_with_update
+ layout = cms_layouts(:default)
+ put :update, :id => layout, :cms_layout => {
+ :label => 'New Label',
+ :content => 'New {{cms:page:content}}'
+ }, :commit => 'Update Layout'
+ assert_response :redirect
+ assert_redirected_to :action => :index
+ assert_equal 'Layout updated', flash[:notice]
+ layout.reload
+ assert_equal 'New Label', layout.label
+ assert_equal 'New {{cms:page:content}}', layout.content
+ end
+
+ def test_update_without_update
layout = cms_layouts(:default)
put :update, :id => layout, :cms_layout => {
:label => 'New Label',