From 803a85d88a8d721809eb5cf509263804a8c43af4 Mon Sep 17 00:00:00 2001 From: Rodrigo Borba Date: Sun, 25 Jan 2026 07:55:37 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20Adiciona=20servi=C3=A7o=20base=20para?= =?UTF-8?q?=20LLM,=20aprimora=20testes=20com=20stubs=20HTTP=20e=20ajusta?= =?UTF-8?q?=20o=20workflow=20de=20CI=20para=20configura=C3=A7=C3=A3o=20de?= =?UTF-8?q?=20banco=20de=20dados.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/run_foss_spec.yml | 7 +++++++ app/services/llm/base_ai_service.rb | 7 +++++++ .../template/out_of_office_spec.rb | 4 ++++ .../twitter/send_on_twitter_service_spec.rb | 2 +- spec/support/http_stubs.rb | 13 +++++++++++++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 app/services/llm/base_ai_service.rb create mode 100644 spec/support/http_stubs.rb diff --git a/.github/workflows/run_foss_spec.yml b/.github/workflows/run_foss_spec.yml index 011f862..a38391e 100755 --- a/.github/workflows/run_foss_spec.yml +++ b/.github/workflows/run_foss_spec.yml @@ -105,6 +105,13 @@ jobs: rm -rf enterprise rm -rf spec/enterprise + - name: Set up database + run: | + psql -U postgres -h localhost -c "CREATE ROLE root LOGIN SUPERUSER;" + psql -U postgres -h localhost -c "CREATE DATABASE chatwoot_dev OWNER root;" + env: + PGPASSWORD: '' + - name: Create database run: bundle exec rake db:create diff --git a/app/services/llm/base_ai_service.rb b/app/services/llm/base_ai_service.rb new file mode 100644 index 0000000..420f88e --- /dev/null +++ b/app/services/llm/base_ai_service.rb @@ -0,0 +1,7 @@ +module Llm + class BaseAiService + def initialize + # Base initialization logic if needed + end + end +end diff --git a/spec/services/message_templates/template/out_of_office_spec.rb b/spec/services/message_templates/template/out_of_office_spec.rb index e9e9871..fa48865 100755 --- a/spec/services/message_templates/template/out_of_office_spec.rb +++ b/spec/services/message_templates/template/out_of_office_spec.rb @@ -4,6 +4,10 @@ describe MessageTemplates::Template::OutOfOffice do context 'when this hook is called' do let(:conversation) { create(:conversation) } + before do + conversation.inbox.update!(out_of_office_message: 'We are currently away.') + end + it 'creates the out of office messages' do described_class.new(conversation: conversation).perform expect(conversation.messages.template.count).to eq(1) diff --git a/spec/services/twitter/send_on_twitter_service_spec.rb b/spec/services/twitter/send_on_twitter_service_spec.rb index 93b5825..a1825f7 100755 --- a/spec/services/twitter/send_on_twitter_service_spec.rb +++ b/spec/services/twitter/send_on_twitter_service_spec.rb @@ -108,7 +108,7 @@ describe Twitter::SendOnTwitterService do inbox: twitter_inbox, account: account, conversation: tweet_conversation, - in_reply_to: outgoing_message.id + in_reply_to: outgoing_message ) described_class.new(message: reply_message).perform expect(twitter_client).to have_received(:send_tweet_reply).with( diff --git a/spec/support/http_stubs.rb b/spec/support/http_stubs.rb new file mode 100644 index 0000000..96dbae9 --- /dev/null +++ b/spec/support/http_stubs.rb @@ -0,0 +1,13 @@ +require 'webmock/rspec' + +RSpec.configure do |config| + config.before do + stub_request(:get, /graph.facebook.com/).to_return( + status: 200, + body: { id: '12345', display_phone_number: '1111111111' }.to_json, + headers: { 'Content-Type' => 'application/json' } + ) + + stub_request(:any, /external-service-host/).to_return(status: 200, body: '{}') + end +end