|
20 | 20 | it "does nothing when inferred_concepts_enabled is false" do |
21 | 21 | SiteSetting.inferred_concepts_enabled = false |
22 | 22 |
|
23 | | - expect(DiscourseAi::InferredConcepts::Manager).not_to receive(:find_candidate_topics) |
24 | | - expect(DiscourseAi::InferredConcepts::Manager).not_to receive(:find_candidate_posts) |
| 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) |
25 | 25 | expect(Jobs).not_to receive(:enqueue) |
26 | 26 |
|
27 | 27 | subject.execute({}) |
|
31 | 31 | candidate_topics = [topic] |
32 | 32 |
|
33 | 33 | freeze_time do |
34 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).with( |
| 34 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).with( |
35 | 35 | limit: 20, |
36 | 36 | min_posts: 5, |
37 | 37 | min_likes: 10, |
|
46 | 46 | batch_size: 10, |
47 | 47 | ) |
48 | 48 |
|
49 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
| 49 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
50 | 50 | [], |
51 | 51 | ) |
52 | 52 |
|
|
58 | 58 | candidate_posts = [post] |
59 | 59 |
|
60 | 60 | freeze_time do |
61 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive( |
| 61 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
62 | 62 | :find_candidate_topics, |
63 | 63 | ).and_return([]) |
64 | 64 |
|
65 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).with( |
| 65 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).with( |
66 | 66 | limit: 30, |
67 | 67 | min_likes: 5, |
68 | 68 | exclude_first_posts: true, |
|
86 | 86 | candidate_topics = [topic] |
87 | 87 | candidate_posts = [post] |
88 | 88 |
|
89 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).and_return( |
| 89 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).and_return( |
90 | 90 | candidate_topics, |
91 | 91 | ) |
92 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
| 92 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
93 | 93 | candidate_posts, |
94 | 94 | ) |
95 | 95 |
|
|
131 | 131 | end |
132 | 132 |
|
133 | 133 | it "does not schedule jobs when no candidates found" do |
134 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).and_return( |
| 134 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).and_return( |
135 | 135 | [], |
136 | 136 | ) |
137 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
| 137 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
138 | 138 | [], |
139 | 139 | ) |
140 | 140 |
|
|
152 | 152 | SiteSetting.inferred_concepts_lookback_days = 45 |
153 | 153 |
|
154 | 154 | freeze_time do |
155 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).with( |
| 155 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).with( |
156 | 156 | limit: 50, |
157 | 157 | min_posts: 8, |
158 | 158 | min_likes: 15, |
159 | 159 | min_views: 200, |
160 | 160 | created_after: 45.days.ago, |
161 | 161 | ).and_return([]) |
162 | 162 |
|
163 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
| 163 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
164 | 164 | [], |
165 | 165 | ) |
166 | 166 |
|
|
174 | 174 | SiteSetting.inferred_concepts_lookback_days = 45 |
175 | 175 |
|
176 | 176 | freeze_time do |
177 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive( |
| 177 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive( |
178 | 178 | :find_candidate_topics, |
179 | 179 | ).and_return([]) |
180 | 180 |
|
181 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).with( |
| 181 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).with( |
182 | 182 | limit: 40, |
183 | 183 | min_likes: 8, |
184 | 184 | exclude_first_posts: true, |
|
199 | 199 | # Keep lookback_days at default so .days.ago doesn't fail |
200 | 200 |
|
201 | 201 | freeze_time do |
202 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).with( |
| 202 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).with( |
203 | 203 | limit: 0, # nil becomes 0 |
204 | 204 | min_posts: 0, # nil becomes 0 |
205 | 205 | min_likes: 0, # nil becomes 0 |
206 | 206 | min_views: 0, # nil becomes 0 |
207 | 207 | created_after: 30.days.ago, # default from before block |
208 | 208 | ).and_return([]) |
209 | 209 |
|
210 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).with( |
| 210 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).with( |
211 | 211 | limit: 0, # nil becomes 0 |
212 | 212 | min_likes: 0, # nil becomes 0 |
213 | 213 | exclude_first_posts: true, |
|
222 | 222 | candidate_topics = [topic] |
223 | 223 | candidate_posts = [post] |
224 | 224 |
|
225 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).and_return( |
| 225 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_topics).and_return( |
226 | 226 | candidate_topics, |
227 | 227 | ) |
228 | | - expect(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
| 228 | + expect_any_instance_of(DiscourseAi::InferredConcepts::Manager).to receive(:find_candidate_posts).and_return( |
229 | 229 | candidate_posts, |
230 | 230 | ) |
231 | 231 |
|
|
0 commit comments