Allow rejecting multiple statuses

This commit is contained in:
Andrew Nesbitt 2022-06-06 10:49:31 +01:00
Родитель 276b8439c0
Коммит c062031072
2 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -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 }) }

Просмотреть файл

@ -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