# frozen_string_literal: true
require "rails_helper"
RSpec.describe SharedAiConversation, type: :model do
fab!(:claude_2) { Fabricate(:llm_model, name: "claude-2") }
before do
SiteSetting.discourse_ai_enabled = true
SiteSetting.ai_bot_enabled = true
toggle_enabled_bots(bots: [claude_2])
end
fab!(:user)
let(:raw_with_details) { <<~HTML }
GitHub pull request diff
This is some other text
HTML let(:bot_user) { claude_2.reload.user } let!(:topic) { Fabricate(:private_message_topic, recipient: bot_user) } let!(:post1) { Fabricate(:post, topic: topic, post_number: 1) } let!(:post2) { Fabricate(:post, topic: topic, post_number: 2, raw: raw_with_details) } describe ".share_conversation" do it "creates a new conversation if one does not exist" do expect { described_class.share_conversation(user, topic) }.to change { described_class.count }.by(1) end it "generates a good onebox" do conversation = described_class.share_conversation(user, topic) onebox = conversation.onebox expect(onebox).not_to include("GitHub pull request diff") expect(onebox).not_to include("