diff --git a/lib/octobox/notifications/exclusive_scope.rb b/lib/octobox/notifications/exclusive_scope.rb index 12017eb0..e1399597 100644 --- a/lib/octobox/notifications/exclusive_scope.rb +++ b/lib/octobox/notifications/exclusive_scope.rb @@ -6,7 +6,7 @@ module Octobox included do scope :unmuted, -> { where("muted_at IS NULL") } scope :exclude_type, ->(subject_type) { where.not(subject_type: subject_type) } - scope :exclude_status, ->(status) { joins(:subject).where("subjects.status is NULL or subjects.status != ?", status) } + scope :exclude_status, ->(status) { joins(:subject).where("subjects.status is NULL or subjects.status not in (?)", Array(status)) } scope :exclude_reason, ->(reason) { where.not(reason: reason) } scope :not_locked, -> { joins(:subject).where(subjects: { locked: false }) } scope :without_subject, -> { includes(:subject).where(subjects: { url: nil }) } diff --git a/test/models/search_test.rb b/test/models/search_test.rb index b1b6abfb..3c79ec9e 100644 --- a/test/models/search_test.rb +++ b/test/models/search_test.rb @@ -60,4 +60,9 @@ class SearchTest < ActiveSupport::TestCase search = Search.new(query: 'type:release archived:true', scope: Notification.all, params: {}) assert_equal search.to_query, 'type:release archived:true' end + + test 'Allow rejecting multiple statuses' do + search = Search.new(query: '-status:merged -status:closed', scope: Notification.all, params: {}) + assert_equal search.results.length, 0 + end end