mirror of
https://github.com/discourse/discourse-solved.git
synced 2026-11-01 01:48:36 -05:00
FEATURE: add new custom status filters (#286)
* FEATURE: add new custom status filters Those can be used in /filter route. Depends on https://github.com/discourse/discourse/pull/26770 Internal ref. /t/127278 * DEV: pin plugin for Discourse 3.3.0.beta2-dev
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
< 3.3.0.beta2-dev: a18ce6d712fafed286bcc99543dd173110c6dfb8
|
||||
< 3.3.0.beta1-dev: 526a44644a7b3f0c2a3ba4fc16e72f364e9fce6d
|
||||
< 3.2.0.beta2-dev: 9fbf43e2f077e86f0a1ff769af6036d4e78bfff1
|
||||
3.1.999: b5d487d6a5bfe2571d936eec5911d02a5f3fcc32
|
||||
|
||||
@@ -9,6 +9,68 @@ RSpec.describe "Managing Posts solved status" do
|
||||
|
||||
before { SiteSetting.allow_solved_on_all_topics = true }
|
||||
|
||||
describe "customer filters" do
|
||||
before do
|
||||
SiteSetting.allow_solved_on_all_topics = false
|
||||
SiteSetting.enable_solved_tags = solvable_tag.name
|
||||
end
|
||||
|
||||
fab!(:solvable_category) do
|
||||
category = Fabricate(:category)
|
||||
|
||||
CategoryCustomField.create(
|
||||
category_id: category.id,
|
||||
name: ::DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD,
|
||||
value: "true",
|
||||
)
|
||||
|
||||
category
|
||||
end
|
||||
|
||||
fab!(:solvable_tag) { Fabricate(:tag) }
|
||||
|
||||
fab!(:solved_in_category) do
|
||||
Fabricate(
|
||||
:custom_topic,
|
||||
category: solvable_category,
|
||||
custom_topic_name: ::DiscourseSolved::ACCEPTED_ANSWER_POST_ID_CUSTOM_FIELD,
|
||||
value: "42",
|
||||
)
|
||||
end
|
||||
|
||||
fab!(:solved_in_tag) do
|
||||
Fabricate(
|
||||
:custom_topic,
|
||||
tags: [solvable_tag],
|
||||
custom_topic_name: ::DiscourseSolved::ACCEPTED_ANSWER_POST_ID_CUSTOM_FIELD,
|
||||
value: "42",
|
||||
)
|
||||
end
|
||||
|
||||
fab!(:unsolved_in_category) { Fabricate(:topic, category: solvable_category) }
|
||||
fab!(:unsolved_in_tag) { Fabricate(:topic, tags: [solvable_tag]) }
|
||||
|
||||
fab!(:unsolved_topic) { Fabricate(:topic) }
|
||||
|
||||
it "can filter by solved status" do
|
||||
expect(
|
||||
TopicsFilter
|
||||
.new(guardian: Guardian.new)
|
||||
.filter_from_query_string("status:solved")
|
||||
.pluck(:id),
|
||||
).to contain_exactly(solved_in_category.id, solved_in_tag.id)
|
||||
end
|
||||
|
||||
it "can filter by unsolved status" do
|
||||
expect(
|
||||
TopicsFilter
|
||||
.new(guardian: Guardian.new)
|
||||
.filter_from_query_string("status:unsolved")
|
||||
.pluck(:id),
|
||||
).to contain_exactly(unsolved_in_category.id, unsolved_in_tag.id)
|
||||
end
|
||||
end
|
||||
|
||||
describe "search" do
|
||||
before { SearchIndexer.enable }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user