Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
175 lines
5.1 KiB
Ruby
175 lines
5.1 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Linear::ActivityMessageService, type: :service do
|
|
let(:account) { create(:account) }
|
|
let(:inbox) { create(:inbox, account: account) }
|
|
let(:conversation) { create(:conversation, account: account, inbox: inbox) }
|
|
let(:user) { create(:user, account: account) }
|
|
|
|
describe '#perform' do
|
|
context 'when action_type is issue_created' do
|
|
let(:service) do
|
|
described_class.new(
|
|
conversation: conversation,
|
|
action_type: :issue_created,
|
|
issue_data: { id: 'ENG-123' },
|
|
user: user
|
|
)
|
|
end
|
|
|
|
it 'enqueues an activity message job' do
|
|
expect do
|
|
service.perform
|
|
end.to have_enqueued_job(Conversations::ActivityMessageJob)
|
|
.with(conversation, {
|
|
account_id: conversation.account_id,
|
|
inbox_id: conversation.inbox_id,
|
|
message_type: :activity,
|
|
content: "Linear issue ENG-123 was created by #{user.name}"
|
|
})
|
|
end
|
|
|
|
it 'does not enqueue job when issue data lacks id' do
|
|
service = described_class.new(
|
|
conversation: conversation,
|
|
action_type: :issue_created,
|
|
issue_data: { title: 'Some issue' },
|
|
user: user
|
|
)
|
|
|
|
expect do
|
|
service.perform
|
|
end.not_to have_enqueued_job(Conversations::ActivityMessageJob)
|
|
end
|
|
|
|
it 'does not enqueue job when issue_data is empty' do
|
|
service = described_class.new(
|
|
conversation: conversation,
|
|
action_type: :issue_created,
|
|
issue_data: {},
|
|
user: user
|
|
)
|
|
|
|
expect do
|
|
service.perform
|
|
end.not_to have_enqueued_job(Conversations::ActivityMessageJob)
|
|
end
|
|
|
|
it 'does not enqueue job when conversation is nil' do
|
|
service = described_class.new(
|
|
conversation: nil,
|
|
action_type: :issue_created,
|
|
issue_data: { id: 'ENG-123' },
|
|
user: user
|
|
)
|
|
|
|
expect do
|
|
service.perform
|
|
end.not_to have_enqueued_job(Conversations::ActivityMessageJob)
|
|
end
|
|
|
|
it 'does not enqueue job when user is nil' do
|
|
service = described_class.new(
|
|
conversation: conversation,
|
|
action_type: :issue_created,
|
|
issue_data: { id: 'ENG-123' },
|
|
user: nil
|
|
)
|
|
|
|
expect do
|
|
service.perform
|
|
end.not_to have_enqueued_job(Conversations::ActivityMessageJob)
|
|
end
|
|
end
|
|
|
|
context 'when action_type is issue_linked' do
|
|
let(:service) do
|
|
described_class.new(
|
|
conversation: conversation,
|
|
action_type: :issue_linked,
|
|
issue_data: { id: 'ENG-456' },
|
|
user: user
|
|
)
|
|
end
|
|
|
|
it 'enqueues an activity message job' do
|
|
expect do
|
|
service.perform
|
|
end.to have_enqueued_job(Conversations::ActivityMessageJob)
|
|
.with(conversation, {
|
|
account_id: conversation.account_id,
|
|
inbox_id: conversation.inbox_id,
|
|
message_type: :activity,
|
|
content: "Linear issue ENG-456 was linked by #{user.name}"
|
|
})
|
|
end
|
|
|
|
it 'does not enqueue job when issue data lacks id' do
|
|
service = described_class.new(
|
|
conversation: conversation,
|
|
action_type: :issue_linked,
|
|
issue_data: { title: 'Some issue' },
|
|
user: user
|
|
)
|
|
|
|
expect do
|
|
service.perform
|
|
end.not_to have_enqueued_job(Conversations::ActivityMessageJob)
|
|
end
|
|
end
|
|
|
|
context 'when action_type is issue_unlinked' do
|
|
let(:service) do
|
|
described_class.new(
|
|
conversation: conversation,
|
|
action_type: :issue_unlinked,
|
|
issue_data: { id: 'ENG-789' },
|
|
user: user
|
|
)
|
|
end
|
|
|
|
it 'enqueues an activity message job' do
|
|
expect do
|
|
service.perform
|
|
end.to have_enqueued_job(Conversations::ActivityMessageJob)
|
|
.with(conversation, {
|
|
account_id: conversation.account_id,
|
|
inbox_id: conversation.inbox_id,
|
|
message_type: :activity,
|
|
content: "Linear issue ENG-789 was unlinked by #{user.name}"
|
|
})
|
|
end
|
|
|
|
it 'does not enqueue job when issue data lacks id' do
|
|
service = described_class.new(
|
|
conversation: conversation,
|
|
action_type: :issue_unlinked,
|
|
issue_data: { title: 'Some issue' },
|
|
user: user
|
|
)
|
|
|
|
expect do
|
|
service.perform
|
|
end.not_to have_enqueued_job(Conversations::ActivityMessageJob)
|
|
end
|
|
end
|
|
|
|
context 'when action_type is unknown' do
|
|
let(:service) do
|
|
described_class.new(
|
|
conversation: conversation,
|
|
action_type: :unknown_action,
|
|
issue_data: { id: 'ENG-999' },
|
|
user: user
|
|
)
|
|
end
|
|
|
|
it 'does not enqueue job for unknown action types' do
|
|
expect do
|
|
service.perform
|
|
end.not_to have_enqueued_job(Conversations::ActivityMessageJob)
|
|
end
|
|
end
|
|
end
|
|
end
|