time_accounting_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe(FormUpdater::Updater::Ticket::TimeAccounting) do
  4. subject(:resolved_result) do
  5. described_class.new(
  6. context: context,
  7. relation_fields: [],
  8. meta: meta,
  9. data: data,
  10. id: nil
  11. )
  12. end
  13. let(:user) { create(:agent) }
  14. let(:context) { { current_user: user } }
  15. let(:meta) { { initial: true, form_id: SecureRandom.uuid } }
  16. let(:data) { {} }
  17. let!(:accounted_time_types) { create_list(:ticket_time_accounting_type, 2) }
  18. let(:expected_result) do
  19. {
  20. options: [
  21. { label: accounted_time_types.first.name, value: accounted_time_types.first.id },
  22. { label: accounted_time_types.second.name, value: accounted_time_types.second.id },
  23. ]
  24. }
  25. end
  26. context 'when resolving' do
  27. it 'provides accounting types with value + label' do
  28. expect(resolved_result.resolve[:fields]).to include(
  29. 'accounted_time_type_id' => include(expected_result),
  30. )
  31. end
  32. end
  33. end