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

Commit b0204df

Browse files
committed
fix researcher specs
1 parent dfe7bdf commit b0204df

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lib/personas/tools/researcher.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def invoke(&blk)
5656
goals = parameters[:goals] || ""
5757
dry_run = parameters[:dry_run].nil? ? false : parameters[:dry_run]
5858

59+
return { error: "No goals provided" } if goals.blank?
60+
return { error: "No filter provided" } if @last_filter.blank?
61+
5962
filter = DiscourseAi::Utils::Research::Filter.new(@last_filter)
6063

6164
@result_count = filter.search.count

spec/lib/personas/tools/researcher_spec.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
it "returns filter information and result count" do
2525
researcher =
2626
described_class.new(
27-
{ filter: "tag:research after:2023", goal: "analyze post patterns" },
27+
{ filter: "tag:research after:2023", goals: "analyze post patterns", dry_run: true },
2828
bot_user: bot_user,
2929
llm: llm,
30-
context: DiscourseAi::Personas::BotContext.new(user: user),
30+
context: DiscourseAi::Personas::BotContext.new(user: user, post: post),
3131
)
3232

3333
results = researcher.invoke(&progress_blk)
3434

3535
expect(results[:filter]).to eq("tag:research after:2023")
36-
expect(results[:goal]).to eq("analyze post patterns")
36+
expect(results[:goals]).to eq("analyze post patterns")
3737
expect(results[:dry_run]).to eq(true)
3838
expect(results[:number_of_results]).to be > 0
3939
expect(researcher.last_filter).to eq("tag:research after:2023")
@@ -42,13 +42,11 @@
4242

4343
it "handles empty filters" do
4444
researcher =
45-
described_class.new({ goal: "analyze all content" }, bot_user: bot_user, llm: llm)
45+
described_class.new({ goals: "analyze all content" }, bot_user: bot_user, llm: llm)
4646

4747
results = researcher.invoke(&progress_blk)
4848

49-
expect(results[:filter]).to eq("")
50-
expect(results[:goal]).to eq("analyze all content")
51-
expect(researcher.last_filter).to eq("")
49+
expect(results[:error]).to eq("No filter provided")
5250
end
5351

5452
it "accepts max_results option" do
@@ -80,7 +78,7 @@
8078
described_class.new(
8179
{
8280
filter: "category:research-category @#{user.username}",
83-
goal: "find relevant content",
81+
goals: "find relevant content",
8482
dry_run: false,
8583
},
8684
bot_user: bot_user,
@@ -97,7 +95,7 @@
9795
end
9896

9997
expect(results[:dry_run]).to eq(false)
100-
expect(results[:goal]).to eq("find relevant content")
98+
expect(results[:goals]).to eq("find relevant content")
10199
expect(results[:filter]).to eq("category:research-category @#{user.username}")
102100
expect(results[:results].first).to include("Found: Relevant content 1")
103101
end

0 commit comments

Comments
 (0)