2018-09-19 13:54:49 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Ticket Article', type: :request do
|
|
|
|
|
|
|
|
let(:admin_user) do
|
|
|
|
create(:admin_user)
|
|
|
|
end
|
2019-02-04 09:42:06 +00:00
|
|
|
let!(:group) { create(:group) }
|
2019-02-04 06:56:18 +00:00
|
|
|
|
2018-09-19 13:54:49 +00:00
|
|
|
let(:agent_user) do
|
2019-02-04 09:42:06 +00:00
|
|
|
create(:agent_user, groups: Group.all)
|
2018-09-19 13:54:49 +00:00
|
|
|
end
|
|
|
|
let(:customer_user) do
|
|
|
|
create(:customer_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'request handling' do
|
|
|
|
|
|
|
|
it 'does ticket create with agent and articles' do
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'a new ticket #1',
|
|
|
|
group: 'Users',
|
2018-09-19 13:54:49 +00:00
|
|
|
customer_id: customer_user.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
article: {
|
2018-09-19 13:54:49 +00:00
|
|
|
body: 'some body',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
authenticated_as(agent_user)
|
|
|
|
post '/api/v1/tickets', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: json_response['id'],
|
2018-09-19 13:54:49 +00:00
|
|
|
content_type: 'text/plain', # or text/html
|
2018-12-19 17:31:51 +00:00
|
|
|
body: 'some body',
|
|
|
|
type: 'note',
|
2018-09-19 13:54:49 +00:00
|
|
|
}
|
|
|
|
post '/api/v1/ticket_articles', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['subject']).to be_nil
|
|
|
|
expect(json_response['body']).to eq('some body')
|
|
|
|
expect(json_response['content_type']).to eq('text/plain')
|
|
|
|
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
|
|
|
expect(json_response['created_by_id']).to eq(agent_user.id)
|
|
|
|
|
|
|
|
ticket = Ticket.find(json_response['ticket_id'])
|
|
|
|
expect(ticket.articles.count).to eq(2)
|
|
|
|
expect(ticket.articles[0].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[1].attachments.count).to eq(0)
|
|
|
|
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: json_response['ticket_id'],
|
2018-09-19 13:54:49 +00:00
|
|
|
content_type: 'text/html', # or text/html
|
2018-12-19 17:31:51 +00:00
|
|
|
body: 'some body <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
|
2018-09-19 13:54:49 +00:00
|
|
|
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
|
|
|
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />',
|
2018-12-19 17:31:51 +00:00
|
|
|
type: 'note',
|
2018-09-19 13:54:49 +00:00
|
|
|
}
|
|
|
|
post '/api/v1/ticket_articles', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['subject']).to be_nil
|
|
|
|
expect(json_response['body']).to_not match(/some body <img src="cid:.+?/)
|
|
|
|
expect(json_response['body']).to match(%r{some body <img src="/api/v1/ticket_attachment/.+?" alt="Red dot"})
|
|
|
|
expect(json_response['content_type']).to eq('text/html')
|
|
|
|
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
|
|
|
expect(json_response['created_by_id']).to eq(agent_user.id)
|
|
|
|
|
|
|
|
expect(ticket.articles.count).to eq(3)
|
|
|
|
expect(ticket.articles[0].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[1].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[2].attachments.count).to eq(1)
|
|
|
|
expect(ticket.articles[2].attachments[0]['id']).to be_truthy
|
|
|
|
expect(ticket.articles[2].attachments[0]['filename']).to eq('image1.png')
|
|
|
|
expect(ticket.articles[2].attachments[0]['size']).to eq('21')
|
|
|
|
expect(ticket.articles[2].attachments[0]['preferences']['Mime-Type']).to eq('image/png')
|
|
|
|
expect(ticket.articles[2].attachments[0]['preferences']['Content-Disposition']).to eq('inline')
|
|
|
|
expect(ticket.articles[2].attachments[0]['preferences']['Content-ID']).to match(/@zammad.example.com/)
|
|
|
|
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: json_response['ticket_id'],
|
2018-09-19 13:54:49 +00:00
|
|
|
content_type: 'text/html', # or text/html
|
2018-12-19 17:31:51 +00:00
|
|
|
body: 'some body',
|
|
|
|
type: 'note',
|
|
|
|
attachments: [
|
|
|
|
'filename' => 'some_file.txt',
|
|
|
|
'data' => 'dGVzdCAxMjM=',
|
2018-09-19 13:54:49 +00:00
|
|
|
'mime-type' => 'text/plain',
|
|
|
|
],
|
|
|
|
}
|
|
|
|
post '/api/v1/ticket_articles', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['subject']).to be_nil
|
|
|
|
expect(json_response['body']).to eq('some body')
|
|
|
|
expect(json_response['content_type']).to eq('text/html')
|
|
|
|
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
|
|
|
expect(json_response['created_by_id']).to eq(agent_user.id)
|
|
|
|
|
|
|
|
expect(ticket.articles.count).to eq(4)
|
|
|
|
expect(ticket.articles[0].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[1].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[2].attachments.count).to eq(1)
|
|
|
|
expect(ticket.articles[3].attachments.count).to eq(1)
|
|
|
|
|
|
|
|
get "/api/v1/ticket_articles/#{json_response['id']}?expand=true", params: {}, as: :json
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['attachments'].count).to eq(1)
|
|
|
|
expect(json_response['attachments'][0]['id']).to be_truthy
|
|
|
|
expect(json_response['attachments'][0]['filename']).to eq('some_file.txt')
|
|
|
|
expect(json_response['attachments'][0]['size']).to eq('8')
|
|
|
|
expect(json_response['attachments'][0]['preferences']['Mime-Type']).to eq('text/plain')
|
|
|
|
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: json_response['ticket_id'],
|
2018-09-19 13:54:49 +00:00
|
|
|
content_type: 'text/plain',
|
2018-12-19 17:31:51 +00:00
|
|
|
body: 'some body',
|
|
|
|
type: 'note',
|
|
|
|
preferences: {
|
2018-09-19 13:54:49 +00:00
|
|
|
some_key1: 123,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
post '/api/v1/ticket_articles', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['subject']).to be_nil
|
|
|
|
expect(json_response['body']).to eq('some body')
|
|
|
|
expect(json_response['content_type']).to eq('text/plain')
|
|
|
|
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
|
|
|
expect(json_response['created_by_id']).to eq(agent_user.id)
|
|
|
|
expect(json_response['preferences']['some_key1']).to eq(123)
|
|
|
|
expect(ticket.articles.count).to eq(5)
|
|
|
|
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
body: 'some body 2',
|
2018-09-19 13:54:49 +00:00
|
|
|
preferences: {
|
|
|
|
some_key2: 'abc',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
put "/api/v1/ticket_articles/#{json_response['id']}", params: params, as: :json
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['subject']).to be_nil
|
|
|
|
expect(json_response['body']).to eq('some body 2')
|
|
|
|
expect(json_response['content_type']).to eq('text/plain')
|
|
|
|
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
|
|
|
expect(json_response['created_by_id']).to eq(agent_user.id)
|
|
|
|
expect(json_response['preferences']['some_key1']).to eq(123)
|
|
|
|
expect(json_response['preferences']['some_key2']).to eq('abc')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does ticket create with customer and articles' do
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'a new ticket #2',
|
|
|
|
group: 'Users',
|
2018-09-19 13:54:49 +00:00
|
|
|
article: {
|
|
|
|
body: 'some body',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
authenticated_as(customer_user)
|
|
|
|
post '/api/v1/tickets', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: json_response['id'],
|
2018-09-19 13:54:49 +00:00
|
|
|
content_type: 'text/plain', # or text/html
|
2018-12-19 17:31:51 +00:00
|
|
|
body: 'some body',
|
|
|
|
type: 'note',
|
2018-09-19 13:54:49 +00:00
|
|
|
}
|
|
|
|
post '/api/v1/ticket_articles', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['subject']).to be_nil
|
|
|
|
expect(json_response['body']).to eq('some body')
|
|
|
|
expect(json_response['content_type']).to eq('text/plain')
|
|
|
|
expect(json_response['updated_by_id']).to eq(customer_user.id)
|
|
|
|
expect(json_response['created_by_id']).to eq(customer_user.id)
|
|
|
|
|
|
|
|
ticket = Ticket.find(json_response['ticket_id'])
|
|
|
|
expect(ticket.articles.count).to eq(2)
|
|
|
|
expect(ticket.articles[1].sender.name).to eq('Customer')
|
|
|
|
expect(ticket.articles[0].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[1].attachments.count).to eq(0)
|
|
|
|
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: json_response['ticket_id'],
|
2018-09-19 13:54:49 +00:00
|
|
|
content_type: 'text/plain', # or text/html
|
2018-12-19 17:31:51 +00:00
|
|
|
body: 'some body',
|
|
|
|
sender: 'Agent',
|
|
|
|
type: 'note',
|
2018-09-19 13:54:49 +00:00
|
|
|
}
|
|
|
|
post '/api/v1/ticket_articles', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['subject']).to be_nil
|
|
|
|
expect(json_response['body']).to eq('some body')
|
|
|
|
expect(json_response['content_type']).to eq('text/plain')
|
|
|
|
expect(json_response['updated_by_id']).to eq(customer_user.id)
|
|
|
|
expect(json_response['created_by_id']).to eq(customer_user.id)
|
|
|
|
|
|
|
|
ticket = Ticket.find(json_response['ticket_id'])
|
|
|
|
expect(ticket.articles.count).to eq(3)
|
|
|
|
expect(ticket.articles[2].sender.name).to eq('Customer')
|
|
|
|
expect(ticket.articles[2].internal).to eq(false)
|
|
|
|
expect(ticket.articles[0].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[1].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[2].attachments.count).to eq(0)
|
|
|
|
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: json_response['ticket_id'],
|
2018-09-19 13:54:49 +00:00
|
|
|
content_type: 'text/plain', # or text/html
|
2018-12-19 17:31:51 +00:00
|
|
|
body: 'some body 2',
|
|
|
|
sender: 'Agent',
|
|
|
|
type: 'note',
|
|
|
|
internal: true,
|
2018-09-19 13:54:49 +00:00
|
|
|
}
|
|
|
|
post '/api/v1/ticket_articles', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['subject']).to be_nil
|
|
|
|
expect(json_response['body']).to eq('some body 2')
|
|
|
|
expect(json_response['content_type']).to eq('text/plain')
|
|
|
|
expect(json_response['updated_by_id']).to eq(customer_user.id)
|
|
|
|
expect(json_response['created_by_id']).to eq(customer_user.id)
|
|
|
|
|
|
|
|
ticket = Ticket.find(json_response['ticket_id'])
|
|
|
|
expect(ticket.articles.count).to eq(4)
|
|
|
|
expect(ticket.articles[3].sender.name).to eq('Customer')
|
|
|
|
expect(ticket.articles[3].internal).to eq(false)
|
|
|
|
expect(ticket.articles[0].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[1].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[2].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[3].attachments.count).to eq(0)
|
|
|
|
|
|
|
|
# add internal article
|
|
|
|
article = create(
|
|
|
|
:ticket_article,
|
|
|
|
ticket_id: ticket.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
internal: true,
|
|
|
|
sender: Ticket::Article::Sender.find_by(name: 'Agent'),
|
|
|
|
type: Ticket::Article::Type.find_by(name: 'note'),
|
2018-09-19 13:54:49 +00:00
|
|
|
)
|
|
|
|
expect(ticket.articles.count).to eq(5)
|
|
|
|
expect(ticket.articles[4].sender.name).to eq('Agent')
|
|
|
|
expect(ticket.articles[4].updated_by_id).to eq(1)
|
|
|
|
expect(ticket.articles[4].created_by_id).to eq(1)
|
|
|
|
expect(ticket.articles[0].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[1].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[2].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[3].attachments.count).to eq(0)
|
|
|
|
expect(ticket.articles[4].attachments.count).to eq(0)
|
|
|
|
|
|
|
|
get "/api/v1/ticket_articles/#{article.id}", params: {}, as: :json
|
|
|
|
expect(response).to have_http_status(401)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['error']).to eq('Not authorized')
|
|
|
|
|
|
|
|
put "/api/v1/ticket_articles/#{article.id}", params: { internal: false }, as: :json
|
|
|
|
expect(response).to have_http_status(401)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['error']).to eq('Not authorized')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does create phone ticket for customer and expected origin_by_id' do
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'a new ticket #1',
|
|
|
|
group: 'Users',
|
2018-09-19 13:54:49 +00:00
|
|
|
customer_id: customer_user.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
article: {
|
|
|
|
body: 'some body',
|
2018-09-19 13:54:49 +00:00
|
|
|
sender: 'Customer',
|
2018-12-19 17:31:51 +00:00
|
|
|
type: 'phone',
|
2018-09-19 13:54:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
authenticated_as(agent_user)
|
|
|
|
post '/api/v1/tickets', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['title']).to eq('a new ticket #1')
|
|
|
|
|
|
|
|
article = Ticket::Article.find_by(ticket_id: json_response['id'])
|
|
|
|
expect(article.origin_by_id).to eq(customer_user.id)
|
|
|
|
expect(article.from).to eq("#{customer_user.firstname} #{customer_user.lastname} <#{customer_user.email}>")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does create phone ticket by customer and manipulate origin_by_id' do
|
|
|
|
params = {
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'a new ticket #1',
|
|
|
|
group: 'Users',
|
2018-09-19 13:54:49 +00:00
|
|
|
customer_id: customer_user.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
article: {
|
|
|
|
body: 'some body',
|
|
|
|
sender: 'Customer',
|
|
|
|
type: 'phone',
|
2018-09-19 13:54:49 +00:00
|
|
|
origin_by_id: 1,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
authenticated_as(customer_user)
|
|
|
|
post '/api/v1/tickets', params: params, as: :json
|
|
|
|
expect(response).to have_http_status(201)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
|
|
|
|
article = Ticket::Article.find_by(ticket_id: json_response['id'])
|
|
|
|
expect(article.origin_by_id).to eq(customer_user.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does ticket split with html - check attachments' do
|
2019-02-04 06:56:18 +00:00
|
|
|
ticket = create(:ticket, group: group)
|
2018-09-19 13:54:49 +00:00
|
|
|
article = create(
|
|
|
|
:ticket_article,
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket.id,
|
|
|
|
type: Ticket::Article::Type.lookup(name: 'note'),
|
|
|
|
sender: Ticket::Article::Sender.lookup(name: 'Customer'),
|
|
|
|
body: '<b>test</b> <img src="cid:15.274327094.140938@ZAMMAD.example.com"/> test <img src="cid:15.274327094.140938.3@ZAMMAD.example.com"/>',
|
2018-09-19 13:54:49 +00:00
|
|
|
content_type: 'text/html',
|
|
|
|
)
|
|
|
|
Store.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
object: 'Ticket::Article',
|
|
|
|
o_id: article.id,
|
|
|
|
data: 'content_file1_normally_should_be_an_image',
|
|
|
|
filename: 'some_file1.jpg',
|
|
|
|
preferences: {
|
2018-09-19 13:54:49 +00:00
|
|
|
'Content-Type' => 'image/jpeg',
|
|
|
|
'Mime-Type' => 'image/jpeg',
|
|
|
|
'Content-ID' => '15.274327094.140938@zammad.example.com',
|
|
|
|
'Content-Disposition' => 'inline',
|
|
|
|
},
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
Store.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
object: 'Ticket::Article',
|
|
|
|
o_id: article.id,
|
|
|
|
data: 'content_file2_normally_should_be_an_image',
|
|
|
|
filename: 'some_file2.jpg',
|
|
|
|
preferences: {
|
2018-09-19 13:54:49 +00:00
|
|
|
'Content-Type' => 'image/jpeg',
|
|
|
|
'Mime-Type' => 'image/jpeg',
|
|
|
|
'Content-ID' => '15.274327094.140938.2@zammad.example.com',
|
|
|
|
'Content-Disposition' => 'inline',
|
|
|
|
},
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
Store.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
object: 'Ticket::Article',
|
|
|
|
o_id: article.id,
|
|
|
|
data: 'content_file3_normally_should_be_an_image',
|
|
|
|
filename: 'some_file3.jpg',
|
|
|
|
preferences: {
|
|
|
|
'Content-Type' => 'image/jpeg',
|
|
|
|
'Mime-Type' => 'image/jpeg',
|
|
|
|
'Content-ID' => '15.274327094.140938.3@zammad.example.com',
|
2018-09-19 13:54:49 +00:00
|
|
|
},
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
Store.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
object: 'Ticket::Article',
|
|
|
|
o_id: article.id,
|
|
|
|
data: 'content_file4_normally_should_be_an_image',
|
|
|
|
filename: 'some_file4.jpg',
|
|
|
|
preferences: {
|
|
|
|
'Content-Type' => 'image/jpeg',
|
|
|
|
'Mime-Type' => 'image/jpeg',
|
|
|
|
'Content-ID' => '15.274327094.140938.4@zammad.example.com',
|
2018-09-19 13:54:49 +00:00
|
|
|
},
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
Store.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
object: 'Ticket::Article',
|
|
|
|
o_id: article.id,
|
|
|
|
data: 'content_file1_normally_should_be_an_pdf',
|
|
|
|
filename: 'Rechnung_RE-2018-200.pdf',
|
|
|
|
preferences: {
|
2018-09-19 13:54:49 +00:00
|
|
|
'Content-Type' => 'application/octet-stream; name="Rechnung_RE-2018-200.pdf"',
|
|
|
|
'Mime-Type' => 'application/octet-stream',
|
|
|
|
'Content-ID' => '8AB0BEC88984EE4EBEF643C79C8E0346@zammad.example.com',
|
|
|
|
'Content-Description' => 'Rechnung_RE-2018-200.pdf',
|
|
|
|
'Content-Disposition' => 'attachment',
|
|
|
|
},
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
params = {
|
|
|
|
form_id: 'new_form_id123',
|
|
|
|
}
|
|
|
|
authenticated_as(agent_user)
|
|
|
|
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article.id}", params: params, as: :json
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['attachments']).to be_truthy
|
|
|
|
expect(json_response['attachments'].count).to eq(3)
|
|
|
|
|
|
|
|
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article.id}", params: params, as: :json
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['attachments']).to be_truthy
|
|
|
|
expect(json_response['attachments'].count).to eq(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does ticket split with plain - check attachments' do
|
|
|
|
ticket = create(
|
|
|
|
:ticket,
|
2019-02-04 06:56:18 +00:00
|
|
|
group: group,
|
2018-09-19 13:54:49 +00:00
|
|
|
updated_by_id: agent_user.id,
|
|
|
|
created_by_id: agent_user.id,
|
|
|
|
)
|
|
|
|
article = create(
|
|
|
|
:ticket_article,
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket.id,
|
|
|
|
type: Ticket::Article::Type.lookup(name: 'note'),
|
|
|
|
sender: Ticket::Article::Sender.lookup(name: 'Customer'),
|
|
|
|
body: '<b>test</b> <img src="cid:15.274327094.140938@zammad.example.com"/>',
|
|
|
|
content_type: 'text/plain',
|
2018-09-19 13:54:49 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
Store.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
object: 'Ticket::Article',
|
|
|
|
o_id: article.id,
|
|
|
|
data: 'content_file1_normally_should_be_an_image',
|
|
|
|
filename: 'some_file1.jpg',
|
|
|
|
preferences: {
|
2018-09-19 13:54:49 +00:00
|
|
|
'Content-Type' => 'image/jpeg',
|
|
|
|
'Mime-Type' => 'image/jpeg',
|
|
|
|
'Content-ID' => '15.274327094.140938@zammad.example.com',
|
|
|
|
'Content-Disposition' => 'inline',
|
|
|
|
},
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
Store.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
object: 'Ticket::Article',
|
|
|
|
o_id: article.id,
|
|
|
|
data: 'content_file1_normally_should_be_an_image',
|
|
|
|
filename: 'some_file2.jpg',
|
|
|
|
preferences: {
|
2018-09-19 13:54:49 +00:00
|
|
|
'Content-Type' => 'image/jpeg',
|
|
|
|
'Mime-Type' => 'image/jpeg',
|
|
|
|
'Content-ID' => '15.274327094.140938.2@zammad.example.com',
|
|
|
|
'Content-Disposition' => 'inline',
|
|
|
|
},
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
Store.add(
|
2018-12-19 17:31:51 +00:00
|
|
|
object: 'Ticket::Article',
|
|
|
|
o_id: article.id,
|
|
|
|
data: 'content_file1_normally_should_be_an_pdf',
|
|
|
|
filename: 'Rechnung_RE-2018-200.pdf',
|
|
|
|
preferences: {
|
2018-09-19 13:54:49 +00:00
|
|
|
'Content-Type' => 'application/octet-stream; name="Rechnung_RE-2018-200.pdf"',
|
|
|
|
'Mime-Type' => 'application/octet-stream',
|
|
|
|
'Content-ID' => '8AB0BEC88984EE4EBEF643C79C8E0346@zammad.example.com',
|
|
|
|
'Content-Description' => 'Rechnung_RE-2018-200.pdf',
|
|
|
|
'Content-Disposition' => 'attachment',
|
|
|
|
},
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
params = {
|
|
|
|
form_id: 'new_form_id123',
|
|
|
|
}
|
|
|
|
authenticated_as(agent_user)
|
|
|
|
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article.id}", params: params, as: :json
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['attachments']).to be_truthy
|
|
|
|
expect(json_response['attachments'].count).to eq(3)
|
|
|
|
|
|
|
|
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article.id}", params: params, as: :json
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
|
expect(json_response['attachments']).to be_truthy
|
|
|
|
expect(json_response['attachments'].count).to eq(0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|