From 1135e00c837a05aef3865b3753ad792281ccc80f Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 6 Dec 2016 08:49:29 +1100 Subject: [PATCH] FIX: regression unable to dismiss unread --- app/controllers/topics_controller.rb | 2 +- spec/controllers/topics_controller_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 4961793ffa9..ef0cd8ba69d 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -574,7 +574,7 @@ class TopicsController < ApplicationController topic_ids = params[:topic_ids].map {|t| t.to_i} elsif params[:filter] == 'unread' tq = TopicQuery.new(current_user) - topics = TopicQuery.unread_filter(tq.joined_topic_user).listable_topics + topics = TopicQuery.unread_filter(tq.joined_topic_user, staff: guardian.is_staff?).listable_topics topics = topics.where('category_id = ?', params[:category_id]) if params[:category_id] topic_ids = topics.pluck(:id) else diff --git a/spec/controllers/topics_controller_spec.rb b/spec/controllers/topics_controller_spec.rb index 05a7b504778..452470abdae 100644 --- a/spec/controllers/topics_controller_spec.rb +++ b/spec/controllers/topics_controller_spec.rb @@ -1224,6 +1224,12 @@ describe TopicsController do expect { xhr :put, :bulk, topic_ids: topic_ids, operation: {}}.to raise_error(ActionController::ParameterMissing) end + it "can find unread" do + # mark all unread muted + xhr :put, :bulk, filter: 'unread', operation: {type: :change_notification_level, notification_level_id: 0} + expect(response.status).to eq(200) + end + it "delegates work to `TopicsBulkAction`" do topics_bulk_action = mock TopicsBulkAction.expects(:new).with(user, topic_ids, operation, group: nil).returns(topics_bulk_action)