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

Commit ca1f0a0

Browse files
committed
fix tests, rename setting
1 parent 4aee428 commit ca1f0a0

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

app/jobs/regular/fast_track_topic_gist.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ def execute(args)
1414

1515
summarizer = DiscourseAi::Summarization.topic_gist(topic)
1616
gist = summarizer.existing_summary
17-
return if gist.blank?
18-
return if !gist.outdated
17+
return if gist.present? && !gist.outdated
1918

2019
summarizer.force_summarize(Discourse.system_user)
2120
end

spec/jobs/regular/update_hot_topic_gist_spec.rb renamed to spec/jobs/regular/fast_track_topic_gist_spec.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe Jobs::UpdateHotTopicGist do
3+
RSpec.describe Jobs::FastTrackTopicGist do
44
describe "#execute" do
55
fab!(:topic_1) { Fabricate(:topic) }
66
fab!(:post_1) { Fabricate(:post, topic: topic_1, post_number: 1) }
@@ -12,8 +12,7 @@
1212
SiteSetting.ai_summarize_max_hot_topics_gists_per_batch = 100
1313
end
1414

15-
context "when the hot topic has a gist" do
16-
before { TopicHotScore.create!(topic_id: topic_1.id, score: 0.1) }
15+
context "when the topic has a gist" do
1716
fab!(:ai_gist) do
1817
Fabricate(:topic_ai_gist, target: topic_1, original_content_sha: AiSummary.build_sha("12"))
1918
end
@@ -48,22 +47,22 @@
4847
end
4948

5049
context "when the topic doesn't have a hot topic score" do
51-
it "does nothing" do
52-
subject.execute({})
50+
it "creates gist" do
51+
subject.execute(topic_id: topic_1.id)
5352

5453
gist = AiSummary.gist.find_by(target: topic_1)
55-
expect(gist).to be_nil
54+
expect(gist).to be_present
5655
end
5756
end
5857

5958
context "when the topic has a hot topic score but no gist" do
6059
before { TopicHotScore.create!(topic_id: topic_1.id, score: 0.1) }
6160

62-
it "does nothing" do
63-
subject.execute({})
61+
it "creates gist" do
62+
subject.execute(topic_id: topic_1.id)
6463

6564
gist = AiSummary.gist.find_by(target: topic_1)
66-
expect(gist).to be_nil
65+
expect(gist).to be_present
6766
end
6867
end
6968
end

0 commit comments

Comments
 (0)