git_integration_base_examples.rb 956 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.shared_examples 'Git Integration Base' do |issue_type:|
  3. describe '#fix_urls_for_ticket' do
  4. let(:bad_issue_url) { 'https://git.example.com/owner/repo/issues/1' }
  5. let(:url_replacements) { { bad_issue_url => 'https://git.example.com/owner/repo/issues/2' } }
  6. it 'does update the ticket if an issue link has to be replaced' do # rubocop:disable RSpec/MultipleExpectations
  7. ticket = create(:ticket, group: Group.first, preferences: {
  8. issue_type => {
  9. issue_links: [bad_issue_url]
  10. }
  11. })
  12. expect(ticket.reload.preferences[issue_type][:issue_links]).to eq([bad_issue_url])
  13. instance.fix_urls_for_ticket(ticket, url_replacements)
  14. expect(ticket.reload.preferences[issue_type][:issue_links]).to eq([url_replacements[bad_issue_url]])
  15. end
  16. end
  17. end