|
3 | 3 | RSpec.describe DiscourseAi::Summarization::FoldContent do |
4 | 4 | subject(:summarizer) { DiscourseAi::Summarization.topic_summary(topic) } |
5 | 5 |
|
6 | | - describe "#summarize" do |
7 | | - let!(:llm_model) { assign_fake_provider_to(:ai_summarization_model) } |
| 6 | + let!(:llm_model) { assign_fake_provider_to(:ai_summarization_model) } |
8 | 7 |
|
9 | | - fab!(:topic) { Fabricate(:topic, highest_post_number: 2) } |
10 | | - fab!(:post_1) { Fabricate(:post, topic: topic, post_number: 1, raw: "This is a text") } |
| 8 | + fab!(:topic) { Fabricate(:topic, highest_post_number: 2) } |
| 9 | + fab!(:post_1) { Fabricate(:post, topic: topic, post_number: 1, raw: "This is a text") } |
11 | 10 |
|
12 | | - before do |
13 | | - SiteSetting.ai_summarization_enabled = true |
| 11 | + before { SiteSetting.ai_summarization_enabled = true } |
14 | 12 |
|
| 13 | + describe "#summarize" do |
| 14 | + before do |
15 | 15 | # Make sure each content fits in a single chunk. |
16 | 16 | # 700 is the number of tokens reserved for the prompt. |
17 | 17 | model_tokens = |
|
52 | 52 | end |
53 | 53 | end |
54 | 54 | end |
| 55 | + |
| 56 | + describe "#existing_summary" do |
| 57 | + context "when a summary already exists" do |
| 58 | + fab!(:ai_summary) do |
| 59 | + Fabricate( |
| 60 | + :ai_summary, |
| 61 | + target: topic, |
| 62 | + highest_target_number: topic.highest_post_number, |
| 63 | + original_content_sha: AiSummary.build_sha("1"), |
| 64 | + ) |
| 65 | + end |
| 66 | + |
| 67 | + it "doesn't mark it as outdated" do |
| 68 | + expect(summarizer.existing_summary.outdated).to eq(false) |
| 69 | + end |
| 70 | + |
| 71 | + context "when it's outdated because there are new targets" do |
| 72 | + before { Fabricate(:post, topic: topic, post_number: 2, raw: "This is a text") } |
| 73 | + |
| 74 | + it "marks it as outdated" do |
| 75 | + expect(summarizer.existing_summary.outdated).to eq(true) |
| 76 | + end |
| 77 | + end |
| 78 | + |
| 79 | + context "when it's outdated because existing content changes" do |
| 80 | + it "marks it as outdated" do |
| 81 | + ai_summary.update!(updated_at: 20.minutes.ago) |
| 82 | + post_1.update!(last_version_at: 5.minutes.ago) |
| 83 | + |
| 84 | + expect(summarizer.existing_summary.outdated).to eq(true) |
| 85 | + end |
| 86 | + end |
| 87 | + end |
| 88 | + end |
55 | 89 | end |
0 commit comments