ticket.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright (C) 2012-2023 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. association :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 { create(channel_name) }
  19. end
  20. preferences do
  21. {
  22. channel_id: channel.id,
  23. }
  24. end
  25. end
  26. factory :twitter_ticket do
  27. with_channel
  28. channel_name { :twitter_channel }
  29. preferences do
  30. {
  31. channel_id: channel.id,
  32. channel_screen_name: channel.options[:user][:screen_name]
  33. }
  34. end
  35. end
  36. factory :sms_ticket do
  37. with_channel
  38. channel_name { :sms_message_bird_channel }
  39. end
  40. factory :telegram_ticket do
  41. with_channel
  42. channel_name { :telegram_channel }
  43. end
  44. factory :facebook_ticket do
  45. with_channel
  46. channel_name { :facebook_channel }
  47. end
  48. end
  49. end