item_spec.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Service::Ticket::ExternalReferences::IssueTracker::Item, integration: true, required_envs: %w[GITHUB_ENDPOINT GITHUB_ISSUE_LINK GITHUB_APITOKEN] do
  4. subject(:service) { described_class.new(issue_link:, type:) }
  5. context 'when GitHub is used' do
  6. let(:type) { 'github' }
  7. let(:issue_link) { ENV['GITHUB_ISSUE_LINK'] }
  8. describe '#execute' do
  9. context 'when github integration is active' do
  10. let(:expected_issue) do
  11. {
  12. id: '1575',
  13. title: 'GitHub integration',
  14. url: ENV['GITHUB_ISSUE_LINK'],
  15. icon_state: 'closed',
  16. milestone: '4.0',
  17. assignees: ['Thorsten'],
  18. labels: [
  19. {
  20. color: '#84b6eb',
  21. text_color: '#000000',
  22. title: 'enhancement'
  23. },
  24. {
  25. color: '#bfdadc',
  26. text_color: '#000000',
  27. title: 'integration'
  28. }
  29. ],
  30. }
  31. end
  32. before do
  33. Setting.set('github_integration', true)
  34. Setting.set('github_config', { 'endpoint' => ENV['GITHUB_ENDPOINT'], 'api_token' => ENV['GITHUB_APITOKEN'] })
  35. end
  36. it 'returns a list of issues' do
  37. expect(service.execute).to eq(expected_issue)
  38. end
  39. end
  40. end
  41. end
  42. end