Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 8355a23

Browse files
committed
tests
1 parent 491691f commit 8355a23

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

app/models/inferred_concept_post.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class InferredConceptPost < ActiveRecord::Base
1515
#
1616
# Table name: inferred_concepts_posts
1717
#
18-
# inferred_concept_id :bigint not null
19-
# post_id :bigint not null
18+
# inferred_concept_id :bigint
19+
# post_id :bigint
2020
# created_at :datetime not null
2121
# updated_at :datetime not null
2222
#
2323
# Indexes
2424
#
25-
# index_inferred_concepts_posts_uniqueness (post_id,inferred_concept_id) UNIQUE
2625
# index_inferred_concepts_posts_on_inferred_concept_id (inferred_concept_id)
26+
# index_inferred_concepts_posts_uniqueness (post_id,inferred_concept_id) UNIQUE
2727
#

app/models/inferred_concept_topic.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class InferredConceptTopic < ActiveRecord::Base
1515
#
1616
# Table name: inferred_concepts_topics
1717
#
18-
# inferred_concept_id :bigint not null
19-
# topic_id :bigint not null
18+
# inferred_concept_id :bigint
19+
# topic_id :bigint
2020
# created_at :datetime not null
2121
# updated_at :datetime not null
2222
#
2323
# Indexes
2424
#
25-
# index_inferred_concepts_topics_uniqueness (topic_id,inferred_concept_id) UNIQUE
2625
# index_inferred_concepts_topics_on_inferred_concept_id (inferred_concept_id)
26+
# index_inferred_concepts_topics_uniqueness (topic_id,inferred_concept_id) UNIQUE
2727
#

spec/lib/inferred_concepts/applier_spec.rb

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,13 @@
136136
# Mock the LLM interaction
137137
persona_double = instance_spy(AiPersona)
138138
bot_double = instance_spy(DiscourseAi::Personas::Bot)
139-
structured_output_double = instance_spy(Object)
140-
llm_class_double = instance_spy(Class)
139+
structured_output_double = double("StructuredOutput")
140+
llm_class_double = double("PersonaClass", default_llm_id: llm_model.id)
141141

142142
allow(AiPersona).to receive_message_chain(:all_personas, :find, :new).and_return(
143143
persona_double,
144144
)
145145
allow(persona_double).to receive(:class).and_return(llm_class_double)
146-
allow(llm_class_double).to receive(:default_llm_id).and_return(llm_model.id)
147146
allow(LlmModel).to receive(:find).and_return(llm_model)
148147
allow(DiscourseAi::Personas::Bot).to receive(:as).and_return(bot_double)
149148
allow(bot_double).to receive(:reply).and_yield(
@@ -186,14 +185,13 @@
186185
# Mock the LLM interaction
187186
persona_double = instance_spy(AiPersona)
188187
bot_double = instance_spy(DiscourseAi::Personas::Bot)
189-
structured_output_double = instance_spy(Object)
190-
llm_class_double = instance_spy(Class)
188+
structured_output_double = double("StructuredOutput")
189+
llm_class_double = double("PersonaClass", default_llm_id: llm_model.id)
191190

192191
allow(AiPersona).to receive_message_chain(:all_personas, :find, :new).and_return(
193192
persona_double,
194193
)
195194
allow(persona_double).to receive(:class).and_return(llm_class_double)
196-
allow(llm_class_double).to receive(:default_llm_id).and_return(llm_model.id)
197195
allow(LlmModel).to receive(:find).and_return(llm_model)
198196
allow(DiscourseAi::Personas::Bot).to receive(:as).and_return(bot_double)
199197
allow(bot_double).to receive(:reply).and_yield(
@@ -221,9 +219,9 @@
221219
it "uses ConceptMatcher persona to match concepts" do
222220
content = "This is about Ruby programming"
223221
concept_list = %w[programming testing ruby]
224-
structured_output_double = instance_spy(Object)
222+
structured_output_double = double("StructuredOutput")
225223

226-
persona_class_double = instance_spy(Class)
224+
persona_class_double = double("PersonaClass", default_llm_id: llm_model.id)
227225
persona_double = instance_spy(AiPersona)
228226
bot_double = instance_spy(DiscourseAi::Personas::Bot)
229227

@@ -232,7 +230,6 @@
232230
)
233231
allow(persona_class_double).to receive(:new).and_return(persona_double)
234232
allow(persona_double).to receive(:class).and_return(persona_class_double)
235-
allow(persona_class_double).to receive(:default_llm_id).and_return(llm_model.id)
236233
allow(LlmModel).to receive(:find).and_return(llm_model)
237234
allow(DiscourseAi::Personas::Bot).to receive(:as).and_return(bot_double)
238235
allow(bot_double).to receive(:reply).and_yield(
@@ -257,7 +254,7 @@
257254
content = "Test content"
258255
concept_list = ["concept1"]
259256

260-
persona_class_double = double("ConceptMatcherClass")
257+
persona_class_double = double("ConceptMatcherClass", default_llm_id: llm_model.id)
261258
persona_double = double("ConceptMatcher")
262259
bot_double = double("Bot")
263260

@@ -266,7 +263,6 @@
266263
)
267264
expect(persona_class_double).to receive(:new).and_return(persona_double)
268265
expect(persona_double).to receive(:class).and_return(persona_class_double)
269-
expect(persona_class_double).to receive(:default_llm_id).and_return(llm_model.id)
270266
expect(LlmModel).to receive(:find).and_return(llm_model)
271267
expect(DiscourseAi::Personas::Bot).to receive(:as).and_return(bot_double)
272268
expect(bot_double).to receive(:reply).and_yield(nil, nil, :text)
@@ -280,7 +276,7 @@
280276
concept_list = %w[programming testing]
281277
expected_response = [['{"matching_concepts": []}']]
282278

283-
persona_class_double = double("ConceptMatcherClass")
279+
persona_class_double = double("ConceptMatcherClass", default_llm_id: llm_model.id)
284280
persona_double = double("ConceptMatcher")
285281
bot_double = double("Bot")
286282

@@ -289,7 +285,6 @@
289285
)
290286
expect(persona_class_double).to receive(:new).and_return(persona_double)
291287
expect(persona_double).to receive(:class).and_return(persona_class_double)
292-
expect(persona_class_double).to receive(:default_llm_id).and_return(llm_model.id)
293288
expect(LlmModel).to receive(:find).and_return(llm_model)
294289
expect(DiscourseAi::Personas::Bot).to receive(:as).and_return(bot_double)
295290
expect(bot_double).to receive(:reply).and_return(expected_response)
@@ -303,7 +298,7 @@
303298
concept_list = ["concept1"]
304299
expected_response = [['{"other_key": ["value"]}']]
305300

306-
persona_class_double = double("ConceptMatcherClass")
301+
persona_class_double = double("ConceptMatcherClass", default_llm_id: llm_model.id)
307302
persona_double = double("ConceptMatcher")
308303
bot_double = double("Bot")
309304

@@ -312,7 +307,6 @@
312307
)
313308
expect(persona_class_double).to receive(:new).and_return(persona_double)
314309
expect(persona_double).to receive(:class).and_return(persona_class_double)
315-
expect(persona_class_double).to receive(:default_llm_id).and_return(llm_model.id)
316310
expect(LlmModel).to receive(:find).and_return(llm_model)
317311
expect(DiscourseAi::Personas::Bot).to receive(:as).and_return(bot_double)
318312
expect(bot_double).to receive(:reply).and_return(expected_response)

0 commit comments

Comments
 (0)