time_accounting_spec.rb 977 B

12345678910111213141516171819202122232425
  1. require 'rails_helper'
  2. RSpec.describe 'Time Accounting API endpoints', type: :request do
  3. let(:admin) { create(:admin_user) }
  4. let(:customer) { create(:customer_user) }
  5. let(:year) { Time.current.year }
  6. let(:month) { Time.current.month }
  7. describe '/api/v1/time_accounting/log/by_ticket' do
  8. context 'when requesting a JSON response' do
  9. # see https://github.com/zammad/zammad/pull/2243
  10. context 'and logs exist for work performed by an agent who is also the customer of the ticket (#2243)' do
  11. let(:ticket) { create(:ticket, customer: admin) }
  12. let!(:time_log) { create(:ticket_time_accounting, ticket: ticket, created_by_id: admin.id) }
  13. it 'responds with a non-nil value for each :agent key' do
  14. authenticated_as(admin)
  15. get "/api/v1/time_accounting/log/by_ticket/#{year}/#{month}", as: :json
  16. expect(json_response.first).not_to include('agent' => nil)
  17. end
  18. end
  19. end
  20. end
  21. end