Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/ai_helper/assistant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,8 @@ def location_map(name)
%w[post]
when "illustrate_post"
%w[composer]
when "detect_text_locale"
%w[]
else
%w[composer post]
%w[]
end
end

Expand Down
25 changes: 25 additions & 0 deletions spec/lib/modules/ai_helper/assistant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@
)
end

it "returns all prompts to be shown in the composer" do
prompts = subject.available_prompts(user)
filtered_prompts = prompts.select { |prompt| prompt[:location].include?("composer") }
expect(filtered_prompts.length).to eq(5)
expect(filtered_prompts.map { |p| p[:name] }).to contain_exactly(
"translate",
"generate_titles",
"proofread",
"markdown_table",
"custom_prompt",
)
end

it "returns all prompts to be shown in the post menu" do
prompts = subject.available_prompts(user)
filtered_prompts = prompts.select { |prompt| prompt[:location].include?("post") }
expect(filtered_prompts.length).to eq(4)
expect(filtered_prompts.map { |p| p[:name] }).to contain_exactly(
"translate",
"explain",
"proofread",
"custom_prompt",
)
end

it "does not raise an error when effective_locale does not exactly match keys in LocaleSiteSetting" do
SiteSetting.default_locale = "zh_CN"
expect { subject.available_prompts(user) }.not_to raise_error
Expand Down