2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2020-04-20 09:47:45 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2020-06-18 11:51:25 +00:00
|
|
|
RSpec.describe 'KnowledgeBase answer attachments cloning', type: :request, authenticated_as: :current_user do
|
2020-04-20 09:47:45 +00:00
|
|
|
include_context 'basic Knowledge Base' do
|
|
|
|
before do
|
|
|
|
published_answer
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-18 11:51:25 +00:00
|
|
|
let(:current_user) { create(:agent) }
|
|
|
|
|
2020-04-20 09:47:45 +00:00
|
|
|
it 'copies to given UploadCache' do
|
2021-09-20 10:47:05 +00:00
|
|
|
form_id = SecureRandom.uuid
|
2020-04-20 09:47:45 +00:00
|
|
|
endpoint = "/api/v1/knowledge_bases/#{knowledge_base.id}/answers/#{published_answer.id}/attachments/clone_to_form"
|
|
|
|
params = { form_id: form_id }
|
|
|
|
|
|
|
|
expect { post endpoint, params: params }
|
|
|
|
.to change { Store.list(object: 'UploadCache', o_id: form_id).count }
|
|
|
|
.from(0)
|
|
|
|
.to(1)
|
|
|
|
end
|
|
|
|
end
|