diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 84630e9..39163e0 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -206,6 +206,7 @@ class CmsController < MyProfileController @article = profile.articles.find(params[:id]) if request.post? @article.destroy + session[:notice] = _("\"#{@article.name}\" was removed.") redirect_to :action => (@article.parent ? 'view' : 'index'), :id => @article.parent end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5fde5ba..992b9b9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1327,4 +1327,11 @@ module ApplicationHelper end end + def delete_article_message(article) + if article.folder? + _("Are you sure that you want to remove the folder \"#{article.name}\"? Note that all the items inside it will also be removed!") + else + _("Are you sure that you want to remove the item \"#{article.name}\"?") + end + end end diff --git a/app/helpers/cms_helper.rb b/app/helpers/cms_helper.rb index a205c3c..942f7f1 100644 --- a/app/helpers/cms_helper.rb +++ b/app/helpers/cms_helper.rb @@ -49,12 +49,6 @@ module CmsHelper end def display_delete_button(article) - confirm_message = if article.folder? - _('Are you sure that you want to remove this folder? Note that all the items inside it will also be removed!') - else - _('Are you sure that you want to remove this item?') - end - - button_without_text :delete, _('Delete'), { :action => 'destroy', :id => article.id }, :method => :post, :confirm => confirm_message + button_without_text :delete, _('Delete'), { :action => 'destroy', :id => article.id }, :method => :post, :confirm => delete_article_message(article) end end diff --git a/app/views/content_viewer/_article_toolbar.rhtml b/app/views/content_viewer/_article_toolbar.rhtml index 1b0eb54..0f20098 100644 --- a/app/views/content_viewer/_article_toolbar.rhtml +++ b/app/views/content_viewer/_article_toolbar.rhtml @@ -8,8 +8,10 @@ <% if !(profile.kind_of?(Enterprise) && environment.enabled?('disable_cms')) %> <% if @page != profile.home_page && !@page.has_posts? %> <%= link_to content_tag( 'span', _('Delete') ), - profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page }), - :class => 'button with-text icon-delete' %> + profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page}), + :method => :post, + :class => 'button with-text icon-delete', + :confirm => delete_article_message(@page) %> <% end %> <% if !environment.enabled?('disable_cms') && !@page.folder? %> <% if profile.kind_of?(Person) %> diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 186b156..e25f2e7 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -902,9 +902,8 @@ class CmsControllerTest < Test::Unit::TestCase should 'offer confirmation to remove article' do a = profile.articles.create!(:name => 'my-article') - get :destroy, :profile => profile.identifier, :id => a.id - assert_response :success - assert_tag :tag => 'input', :attributes => {:type => 'submit', :value => 'Yes, I want.' } + post :destroy, :profile => profile.identifier, :id => a.id + assert_response :redirect end should 'display notify comments option' do diff --git a/test/unit/cms_helper_test.rb b/test/unit/cms_helper_test.rb index 118e77c..d5f2675 100644 --- a/test/unit/cms_helper_test.rb +++ b/test/unit/cms_helper_test.rb @@ -82,8 +82,9 @@ class CmsHelperTest < Test::Unit::TestCase should 'display delete_button to folder' do profile = fast_create(Profile) - folder = fast_create(Folder, :name => 'My folder', :profile_id => profile.id) - confirm_message = 'Are you sure that you want to remove this folder? Note that all the items inside it will also be removed!' + name = 'My folder' + folder = fast_create(Folder, :name => name, :profile_id => profile.id) + confirm_message = "Are you sure that you want to remove the folder \"#{name}\"? Note that all the items inside it will also be removed!" expects(:button_without_text).with(:delete, 'Delete', {:action => 'destroy', :id => folder.id}, :method => :post, :confirm => confirm_message) result = display_delete_button(folder) @@ -91,8 +92,9 @@ class CmsHelperTest < Test::Unit::TestCase should 'display delete_button to article' do profile = fast_create(Profile) - article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) - confirm_message = 'Are you sure that you want to remove this item?' + name = 'My article' + article = fast_create(TinyMceArticle, :name => name, :profile_id => profile.id) + confirm_message = "Are you sure that you want to remove the item \"#{name}\"?" expects(:button_without_text).with(:delete, 'Delete', {:action => 'destroy', :id => article.id}, :method => :post, :confirm => confirm_message) result = display_delete_button(article) -- libgit2 0.21.2