answer_attachments_cloning_spec.rb 734 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'KnowledgeBase answer attachments cloning', authenticated_as: :current_user, type: :request do
  4. include_context 'basic Knowledge Base' do
  5. before do
  6. published_answer
  7. end
  8. end
  9. let(:current_user) { create(:agent) }
  10. it 'copies to given UploadCache' do
  11. form_id = SecureRandom.uuid
  12. endpoint = "/api/v1/knowledge_bases/#{knowledge_base.id}/answers/#{published_answer.id}/attachments/clone_to_form"
  13. params = { form_id: form_id }
  14. expect { post endpoint, params: params }
  15. .to change { Store.list(object: 'UploadCache', o_id: form_id).count }
  16. .from(0)
  17. .to(1)
  18. end
  19. end