FIX: support case insensitive setting lookup (#795)

This commit is contained in:
Sam 2024-09-10 15:21:03 +10:00 committed by GitHub
parent a5b5c3bebe
commit 36ce88f356
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -44,7 +44,7 @@ module DiscourseAi
end end
def setting_name def setting_name
parameters[:setting_name] @setting_name ||= parameters[:setting_name].to_s.downcase.gsub(" ", "_")
end end
def invoke def invoke

View File

@ -30,6 +30,15 @@ RSpec.describe DiscourseAi::AiBot::Tools::SettingContext, if: has_rg? do
expect(result[:context]).to include("moderators_view_emails") expect(result[:context]).to include("moderators_view_emails")
end end
it "supports spaces and case insensitive setting name" do
result = setting_context("moderaTors View Emails").invoke
expect(result[:setting_name]).to eq("moderators_view_emails")
expect(result[:context]).to include("site_settings.yml")
expect(result[:context]).to include("moderators_view_emails")
end
it "returns the context for plugin setting" do it "returns the context for plugin setting" do
result = setting_context("ai_bot_enabled").invoke result = setting_context("ai_bot_enabled").invoke