mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
* FEATURE: Content custom summarization strategies. This PR establishes a pattern for plugins to register alternative ways of summarizing content by extending a class that defines an interface. Core controls which strategy we'll use and who has access to it through the `summarization_strategy` and `custom_summarization_allowed_groups`. It also defines the UI for summarizing topics. Other plugins can access this summarization mechanism and implement their features, removing cross-plugin customizations, as it currently happens between chat and the discourse-ai plugin. * Group membership validation and rate limiting * Work with objects instead of classes * Port summarization feature from discourse-ai to chat * Rename available summaries to 'Top Replies' and 'Summary'
33 lines
921 B
Ruby
33 lines
921 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Chat::Api::SummariesController do
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
fab!(:group) { Fabricate(:group) }
|
|
let(:plugin) { Plugin::Instance.new }
|
|
|
|
before do
|
|
group.add(current_user)
|
|
|
|
strategy = DummyCustomSummarization.new("dummy")
|
|
plugin.register_summarization_strategy(strategy)
|
|
SiteSetting.summarization_strategy = strategy.model
|
|
SiteSetting.custom_summarization_allowed_groups = group.id
|
|
|
|
SiteSetting.chat_enabled = true
|
|
SiteSetting.chat_allowed_groups = group.id
|
|
sign_in(current_user)
|
|
end
|
|
|
|
describe "#get_summary" do
|
|
context "when the user is not allowed to join the channel" do
|
|
fab!(:channel) { Fabricate(:private_category_channel) }
|
|
|
|
it "returns a 403" do
|
|
get "/chat/api/channels/#{channel.id}/summarize", params: { since: 6 }
|
|
|
|
expect(response.status).to eq(403)
|
|
end
|
|
end
|
|
end
|
|
end
|