diff --git a/app/controllers/admin/feedback_controller.rb b/app/controllers/admin/feedback_controller.rb
index 0dfc5600a6..2d53bb6d44 100644
--- a/app/controllers/admin/feedback_controller.rb
+++ b/app/controllers/admin/feedback_controller.rb
@@ -103,6 +103,18 @@ def update
end
end
+ def article
+ @article = Article.find(params[:id])
+ if params[:ham] && params[:spam].blank?
+ @feedback = @article.comments.ham
+ end
+ if params[:spam] && params[:ham].blank?
+ @feedback = @article.comments.spam
+ end
+ @feedback ||= @article.comments
+ end
+
+
def change_state
return unless request.xhr?
@@ -128,6 +140,7 @@ def change_state
def bulkops
ids = (params[:feedback_check]||{}).keys.map(&:to_i)
items = Feedback.find(ids)
+ @unexpired = true
bulkop = params[:bulkop_top].empty? ? params[:bulkop_bottom] : params[:bulkop_top]
case bulkop
@@ -177,12 +190,13 @@ def delete_all_spam
def update_feedback(items, method)
items.each do |value|
value.send(method)
- value.invalidates_cache? or next
+ @unexpired && value.invalidates_cache? or next
flush_cache
end
end
def flush_cache
+ @unexpired = false
PageCache.sweep_all
end
diff --git a/app/views/admin/feedback/index.html.erb b/app/views/admin/feedback/index.html.erb
index b3b5f27cef..1f47a52bbf 100644
--- a/app/views/admin/feedback/index.html.erb
+++ b/app/views/admin/feedback/index.html.erb
@@ -5,7 +5,7 @@
<%= link_to(_("All"), controller: 'admin/feedback', action: :index) %>
-
+
<%= link_to(_("Unapproved comments"), controller: 'admin/feedback', action: :index, confirmed: 'f') %>
@@ -21,40 +21,41 @@
<%= link_to(_("Presumed spam"), controller: 'admin/feedback', action: :index, published: 'f') %>
-
-
- <%= submit_tag(_("Search"), {:class => 'btn'}) %>
-
+
+
+ <%= submit_tag(_("Search"), {:class => 'btn'}) %>
+
<% end %>
-<%= form_tag({action: 'bulkops'}) do %>
- <%= render 'button', { position: 'top' } %>
- <%= hidden_field_tag "search", params[:search]%>
- <%= hidden_field_tag "page", params[:page]%>
+<%= form_tag({:action => 'bulkops'}) do %>
+<%= render 'button', { :position => 'top' } %>
-
+<%= render 'button', { :position => 'bottom' } %>
<% end %>
diff --git a/spec/controllers/admin/feedback_controller_spec.rb b/spec/controllers/admin/feedback_controller_spec.rb
index 0b6e30c124..5d34fdf153 100644
--- a/spec/controllers/admin/feedback_controller_spec.rb
+++ b/spec/controllers/admin/feedback_controller_spec.rb
@@ -135,6 +135,50 @@ def should_success_with_index(response)
get :index, :page => ''
should_success_with_index(response)
end
+
+ end
+
+ describe 'article action' do
+
+ def should_success_with_article_view(response)
+ response.should be_success
+ response.should render_template('article')
+ end
+
+ it 'should see all feedback on one article' do
+ article = FactoryGirl.create(:article)
+ FactoryGirl.create(:comment, :article => article)
+ FactoryGirl.create(:comment, :article => article)
+ get :article, :id => article.id
+ should_success_with_article_view(response)
+ assigns(:article).should == article
+ assigns(:feedback).size.should == 2
+ end
+
+ it 'should see only spam feedback on one article' do
+ article = FactoryGirl.create(:article)
+ FactoryGirl.create(:comment, :state => 'spam', :article => article)
+ get :article, :id => article.id, :spam => 'y'
+ should_success_with_article_view(response)
+ assigns(:article).should == article
+ assigns(:feedback).size.should == 1
+ end
+
+ it 'should see only ham feedback on one article' do
+ article = FactoryGirl.create(:article)
+ comment = FactoryGirl.create(:comment, :article => article)
+ get :article, :id => article.id, :ham => 'y'
+ should_success_with_article_view(response)
+ assigns(:article).should == article
+ assigns(:feedback).size.should == 1
+ end
+
+ it 'should redirect_to index if bad article id' do
+ lambda{
+ get :article, :id => 102302
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+
end
describe 'create action' do