diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb
index e52e358..c57e326 100644
--- a/app/controllers/public/content_viewer_controller.rb
+++ b/app/controllers/public/content_viewer_controller.rb
@@ -76,7 +76,7 @@ class ContentViewerController < PublicController
@comment.destroy
flash[:notice] = _('Comment succesfully deleted')
end
- redirect_to :action => 'view_page'
+ redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path
end
end
diff --git a/app/views/content_viewer/_comment.rhtml b/app/views/content_viewer/_comment.rhtml
index efe0c36..a981791 100644
--- a/app/views/content_viewer/_comment.rhtml
+++ b/app/views/content_viewer/_comment.rhtml
@@ -2,7 +2,7 @@
<% if logged_in? && (user == @page.profile || user == comment.author || user.has_permission?(:moderate_comments, @page.profile)) %>
<% button_bar(:style => 'float: right; margin-top: 0;') do %>
- <%= icon_button(:delete, _('Remove'), { :remove_comment => comment.id }, :method => :post, :confirm => _('Are you sure you want to remove this comment?')) %>
+ <%= icon_button(:delete, _('Remove'), { :profile => params[:profile], :remove_comment => comment.id }, :method => :post, :confirm => _('Are you sure you want to remove this comment?')) %>
<% end %>
<% end %>
diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb
index 1f6f507..5ecd448 100644
--- a/test/functional/content_viewer_controller_test.rb
+++ b/test/functional/content_viewer_controller_test.rb
@@ -114,6 +114,30 @@ class ContentViewerControllerTest < Test::Unit::TestCase
assert_equal feed.data, @response.body
end
+ should 'display remove comment button' do
+ profile = create_user('testuser').person
+ article = profile.articles.build(:name => 'test')
+ article.save!
+ comment = article.comments.build(:author => profile, :title => 'a comment', :body => 'lalala')
+ comment.save!
+
+ login_as 'testuser'
+ get :view_page, :profile => 'testuser', :page => [ 'test' ]
+ assert_tag :tag => 'a', :attributes => { :href => '/testuser/test?remove_comment=' + comment.id.to_s }
+ end
+
+ should 'not add unneeded params for remove comment button' do
+ profile = create_user('testuser').person
+ article = profile.articles.build(:name => 'test')
+ article.save!
+ comment = article.comments.build(:author => profile, :title => 'a comment', :body => 'lalala')
+ comment.save!
+
+ login_as 'testuser'
+ get :view_page, :profile => 'testuser', :page => [ 'test' ], :random_param => 'bli' # <<<<<<<<<<<<<<<
+ assert_tag :tag => 'a', :attributes => { :href => '/testuser/test?remove_comment=' + comment.id.to_s }
+ end
+
should 'be able to remove comment' do
profile = create_user('testuser').person
article = profile.articles.build(:name => 'test')
@@ -124,7 +148,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase
login_as 'testuser'
assert_difference Comment, :count, -1 do
post :view_page, :profile => profile.identifier, :page => [ 'test' ], :remove_comment => comment.id
- assert_response :redirect
+ assert_redirected_to :profile => 'testuser', :action => 'view_page', :page => [ 'test' ]
end
end
--
libgit2 0.21.2