preferences_spec.rb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Service::User::CalendarSubscription::Preferences do
  4. let(:user) { create(:user) }
  5. let(:service) { described_class.new(user) }
  6. context 'when user has no preferences' do
  7. it 'returns default ticket preferences' do
  8. expect(service.execute).to include(
  9. tickets: include(
  10. alarm: false,
  11. new_open: include(own: true, not_assigned: false),
  12. pending: include(own: true, not_assigned: false),
  13. escalation: include(own: true, not_assigned: false),
  14. )
  15. )
  16. end
  17. end
  18. context 'when user has custom preferences' do
  19. before do
  20. Service::User::CalendarSubscription::Update
  21. .new(user, input: {
  22. alarm: true,
  23. new_open: { own: false, not_assigned: true },
  24. pending: { own: true, not_assigned: true },
  25. escalation: { own: false, not_assigned: false },
  26. }).execute
  27. end
  28. it 'returns custom preferences' do
  29. expect(service.execute).to include(
  30. tickets: include(
  31. alarm: true,
  32. new_open: include(own: false, not_assigned: true),
  33. pending: include(own: true, not_assigned: true),
  34. escalation: include(own: false, not_assigned: false),
  35. )
  36. )
  37. end
  38. end
  39. end