|
63 | 63 | category_custom_field.save
|
64 | 64 | category
|
65 | 65 | end
|
| 66 | + fab!(:tag) |
66 | 67 | fab!(:topic_unsolved) do
|
67 | 68 | Fabricate(
|
68 | 69 | :custom_topic,
|
|
71 | 72 | custom_topic_name: ::DiscourseSolved::ACCEPTED_ANSWER_POST_ID_CUSTOM_FIELD,
|
72 | 73 | )
|
73 | 74 | end
|
| 75 | + fab!(:topic_unsolved_2) { Fabricate(:topic, user: user, tags: [tag]) } |
74 | 76 | fab!(:topic_solved) do
|
75 | 77 | Fabricate(
|
76 | 78 | :custom_topic,
|
|
96 | 98 | )
|
97 | 99 | end
|
98 | 100 | fab!(:post_unsolved) { Fabricate(:post, topic: topic_unsolved) }
|
| 101 | + fab!(:post_unsolved_2) { Fabricate(:post, topic: topic_unsolved_2) } |
99 | 102 | fab!(:post_solved) do
|
100 | 103 | post = Fabricate(:post, topic: topic_solved)
|
101 | 104 | DiscourseSolved.accept_answer!(post, Discourse.system_user)
|
|
105 | 108 | fab!(:post_disabled_2) { Fabricate(:post, topic: topic_disabled_2) }
|
106 | 109 |
|
107 | 110 | before do
|
| 111 | + SiteSetting.enable_solved_tags = tag.name |
108 | 112 | SearchIndexer.enable
|
109 | 113 | Jobs.run_immediately!
|
110 | 114 |
|
111 | 115 | SearchIndexer.index(topic_unsolved, force: true)
|
| 116 | + SearchIndexer.index(topic_unsolved_2, force: true) |
112 | 117 | SearchIndexer.index(topic_solved, force: true)
|
113 | 118 | SearchIndexer.index(topic_disabled_1, force: true)
|
114 | 119 | SearchIndexer.index(topic_disabled_2, force: true)
|
|
120 | 125 | describe "when allow solved on all topics is disabled" do
|
121 | 126 | before { SiteSetting.allow_solved_on_all_topics = false }
|
122 | 127 |
|
123 |
| - it "only returns posts where 'Allow topic owner and staff to mark a reply as the solution' is enabled and post is not solved" do |
| 128 | + it "only returns unsolved posts from categories and tags where solving is enabled" do |
124 | 129 | result = Search.execute("status:unsolved")
|
125 |
| - expect(result.posts.pluck(:id)).to match_array([post_unsolved.id]) |
| 130 | + expect(result.posts.pluck(:id)).to match_array([post_unsolved.id, post_unsolved_2.id]) |
| 131 | + end |
| 132 | + |
| 133 | + it "returns the filtered results when combining search with a tag" do |
| 134 | + result = Search.execute("status:unsolved tag:#{tag.name}") |
| 135 | + expect(result.posts.pluck(:id)).to match_array([post_unsolved_2.id]) |
126 | 136 | end
|
127 | 137 | end
|
| 138 | + |
128 | 139 | describe "when allow solved on all topics is enabled" do
|
129 | 140 | before { SiteSetting.allow_solved_on_all_topics = true }
|
130 | 141 | it "only returns posts where the post is not solved" do
|
131 | 142 | result = Search.execute("status:unsolved")
|
132 | 143 | expect(result.posts.pluck(:id)).to match_array(
|
133 |
| - [post_unsolved.id, post_disabled_1.id, post_disabled_2.id], |
| 144 | + [post_unsolved.id, post_unsolved_2.id, post_disabled_1.id, post_disabled_2.id], |
134 | 145 | )
|
135 | 146 | end
|
136 | 147 | end
|
|
0 commit comments