ticket.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. FactoryBot.define do
  3. factory :ticket do
  4. transient do
  5. state_name { 'new' }
  6. priority_name { '2 normal' }
  7. end
  8. group factory: :group, strategy: :create # or else build(:ticket).save fails
  9. customer
  10. title { 'Test Ticket' }
  11. state { Ticket::State.lookup(name: state_name) }
  12. priority { Ticket::Priority.lookup(name: priority_name) }
  13. updated_by_id { 1 }
  14. created_by_id { 1 }
  15. trait :with_channel do
  16. transient do
  17. channel_name { nil }
  18. channel { association(channel_name) }
  19. end
  20. preferences do
  21. {
  22. channel_id: channel.id,
  23. channel_area: channel.area,
  24. }
  25. end
  26. end
  27. factory :twitter_ticket do
  28. with_channel
  29. channel_name { :twitter_channel }
  30. preferences do
  31. {
  32. channel_id: channel.id,
  33. channel_screen_name: channel.options[:user][:screen_name]
  34. }
  35. end
  36. end
  37. factory :sms_ticket do
  38. with_channel
  39. channel_name { :sms_message_bird_channel }
  40. end
  41. factory :telegram_ticket do
  42. with_channel
  43. channel_name { :telegram_channel }
  44. end
  45. factory :whatsapp_ticket do
  46. with_channel
  47. channel_name { :whatsapp_channel }
  48. end
  49. factory :facebook_ticket do
  50. with_channel
  51. channel_name { :facebook_channel }
  52. end
  53. end
  54. end