|
20 | 20 | it "does nothing when inferred_concepts_enabled is false" do |
21 | 21 | SiteSetting.inferred_concepts_enabled = false |
22 | 22 |
|
23 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).not_to receive(:find_candidate_topics) |
24 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).not_to receive(:find_candidate_posts) |
| 23 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).not_to receive( |
| 24 | + :find_candidate_topics, |
| 25 | + ) |
| 26 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).not_to receive( |
| 27 | + :find_candidate_posts, |
| 28 | + ) |
25 | 29 | expect(Jobs).not_to receive(:enqueue) |
26 | 30 |
|
27 | 31 | subject.execute({}) |
|
31 | 35 | candidate_topics = [topic] |
32 | 36 |
|
33 | 37 | freeze_time do |
34 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).with( |
| 38 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 39 | + :find_candidate_topics, |
| 40 | + ).with( |
35 | 41 | limit: 20, |
36 | 42 | min_posts: 5, |
37 | 43 | min_likes: 10, |
|
46 | 52 | batch_size: 10, |
47 | 53 | ) |
48 | 54 |
|
49 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
50 | | - [], |
51 | | - ) |
| 55 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 56 | + :find_candidate_posts, |
| 57 | + ).and_return([]) |
52 | 58 |
|
53 | 59 | subject.execute({}) |
54 | 60 | end |
|
62 | 68 | :find_candidate_topics, |
63 | 69 | ).and_return([]) |
64 | 70 |
|
65 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).with( |
| 71 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 72 | + :find_candidate_posts, |
| 73 | + ).with( |
66 | 74 | limit: 30, |
67 | 75 | min_likes: 5, |
68 | 76 | exclude_first_posts: true, |
|
86 | 94 | candidate_topics = [topic] |
87 | 95 | candidate_posts = [post] |
88 | 96 |
|
89 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).and_return( |
90 | | - candidate_topics, |
91 | | - ) |
92 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
93 | | - candidate_posts, |
94 | | - ) |
| 97 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 98 | + :find_candidate_topics, |
| 99 | + ).and_return(candidate_topics) |
| 100 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 101 | + :find_candidate_posts, |
| 102 | + ).and_return(candidate_posts) |
95 | 103 |
|
96 | 104 | # Expect generation jobs |
97 | 105 | expect(Jobs).to receive(:enqueue).with( |
|
131 | 139 | end |
132 | 140 |
|
133 | 141 | it "does not schedule jobs when no candidates found" do |
134 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).and_return( |
135 | | - [], |
136 | | - ) |
137 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
138 | | - [], |
139 | | - ) |
| 142 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 143 | + :find_candidate_topics, |
| 144 | + ).and_return([]) |
| 145 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 146 | + :find_candidate_posts, |
| 147 | + ).and_return([]) |
140 | 148 |
|
141 | 149 | expect(Jobs).not_to receive(:enqueue) |
142 | 150 | expect(Jobs).not_to receive(:enqueue_in) |
|
152 | 160 | SiteSetting.inferred_concepts_lookback_days = 45 |
153 | 161 |
|
154 | 162 | freeze_time do |
155 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).with( |
| 163 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 164 | + :find_candidate_topics, |
| 165 | + ).with( |
156 | 166 | limit: 50, |
157 | 167 | min_posts: 8, |
158 | 168 | min_likes: 15, |
159 | 169 | min_views: 200, |
160 | 170 | created_after: 45.days.ago, |
161 | 171 | ).and_return([]) |
162 | 172 |
|
163 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
164 | | - [], |
165 | | - ) |
| 173 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 174 | + :find_candidate_posts, |
| 175 | + ).and_return([]) |
166 | 176 |
|
167 | 177 | subject.execute({}) |
168 | 178 | end |
|
178 | 188 | :find_candidate_topics, |
179 | 189 | ).and_return([]) |
180 | 190 |
|
181 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).with( |
| 191 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 192 | + :find_candidate_posts, |
| 193 | + ).with( |
182 | 194 | limit: 40, |
183 | 195 | min_likes: 8, |
184 | 196 | exclude_first_posts: true, |
|
199 | 211 | # Keep lookback_days at default so .days.ago doesn't fail |
200 | 212 |
|
201 | 213 | freeze_time do |
202 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).with( |
| 214 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 215 | + :find_candidate_topics, |
| 216 | + ).with( |
203 | 217 | limit: 0, # nil becomes 0 |
204 | 218 | min_posts: 0, # nil becomes 0 |
205 | 219 | min_likes: 0, # nil becomes 0 |
206 | 220 | min_views: 0, # nil becomes 0 |
207 | 221 | created_after: 30.days.ago, # default from before block |
208 | 222 | ).and_return([]) |
209 | 223 |
|
210 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).with( |
| 224 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 225 | + :find_candidate_posts, |
| 226 | + ).with( |
211 | 227 | limit: 0, # nil becomes 0 |
212 | 228 | min_likes: 0, # nil becomes 0 |
213 | 229 | exclude_first_posts: true, |
|
222 | 238 | candidate_topics = [topic] |
223 | 239 | candidate_posts = [post] |
224 | 240 |
|
225 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).and_return( |
226 | | - candidate_topics, |
227 | | - ) |
228 | | - expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
229 | | - candidate_posts, |
230 | | - ) |
| 241 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 242 | + :find_candidate_topics, |
| 243 | + ).and_return(candidate_topics) |
| 244 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
| 245 | + :find_candidate_posts, |
| 246 | + ).and_return(candidate_posts) |
231 | 247 |
|
232 | 248 | expect(Jobs).to receive(:enqueue).twice |
233 | 249 |
|
|
0 commit comments