template_migration_spec.rb 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe TemplateMigration, type: :db_migration do
  4. let(:expected) do
  5. {
  6. 'article.body' => 'twet 23123',
  7. 'ticket.formSenderType' => 'phone-in',
  8. 'article.form_id' => '19d8d2a2-8af3-4992-add0-353ee32bcb5f',
  9. 'ticket.title' => 'aaa',
  10. 'ticket.customer_id' => '2',
  11. 'ticket.customer_id_completion' => 'Nicole Braun <nicole.braun@example.com>',
  12. 'ticket.cc' => 'somebody2@example.com',
  13. 'ticket.group_id' => '1',
  14. 'ticket.owner_id' => '11',
  15. 'ticket.state_id' => '2',
  16. 'ticket.priority_id' => '2',
  17. 'ticket.a1' => 'a',
  18. 'ticket.a2' => %w[a b],
  19. 'ticket.b1' => 'a::c',
  20. 'ticket.b2' => ['b'],
  21. 'ticket.b2_completion' => '',
  22. 'ticket.category' => 'a::aa',
  23. 'ticket.tags' => 'aa, bb'
  24. }
  25. end
  26. let(:template) do
  27. # default format of 5.2 and earlier
  28. Template.create!(
  29. name: 'new',
  30. options:
  31. {
  32. 'body' => 'twet 23123',
  33. 'formSenderType' => 'phone-in',
  34. 'form_id' => '19d8d2a2-8af3-4992-add0-353ee32bcb5f',
  35. 'title' => 'aaa',
  36. 'customer_id' => '2',
  37. 'customer_id_completion' => 'Nicole Braun <nicole.braun@example.com>',
  38. 'cc' => 'somebody2@example.com',
  39. 'group_id' => '1',
  40. 'owner_id' => '11',
  41. 'state_id' => '2',
  42. 'priority_id' => '2',
  43. 'a1' => 'a',
  44. 'a2' => %w[a b],
  45. 'b1' => 'a::c',
  46. 'b2' => ['b'],
  47. 'b2_completion' => '',
  48. 'category' => 'a::aa',
  49. 'tags' => 'aa, bb'
  50. },
  51. updated_by_id: 1,
  52. created_by_id: 1,
  53. )
  54. end
  55. before do
  56. template
  57. end
  58. context 'when migrating' do
  59. it 'update options' do
  60. migrate
  61. expect(template.reload.options).to eq(expected)
  62. end
  63. end
  64. end