2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2020-09-11 07:25:47 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2021-04-28 07:36:59 +00:00
|
|
|
RSpec.describe Ticket::Article::AddsMetadataGeneral do
|
2020-09-11 07:25:47 +00:00
|
|
|
let(:agent) { create(:agent) }
|
|
|
|
|
2021-04-28 07:36:59 +00:00
|
|
|
context 'when Agent creates Article' do
|
|
|
|
shared_examples 'not including email in from' do |factory|
|
2021-07-16 13:38:01 +00:00
|
|
|
subject(:article) { create(:ticket_article, factory, ticket: ticket, created_by_id: agent.id, updated_by_id: agent.id) }
|
2020-09-11 07:25:47 +00:00
|
|
|
|
2021-04-28 07:36:59 +00:00
|
|
|
let(:ticket) { create(:ticket) }
|
|
|
|
let!(:agent) { create(:agent, groups: [ticket.group]) }
|
2020-09-11 07:25:47 +00:00
|
|
|
|
2021-04-28 07:36:59 +00:00
|
|
|
it "doesn't include email in from" do
|
|
|
|
expect(article.from).not_to include agent.email
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'not including email in from', :outbound_phone
|
|
|
|
it_behaves_like 'not including email in from', :outbound_web
|
|
|
|
|
|
|
|
context 'when as Customer' do
|
|
|
|
subject(:article) { create(:ticket_article, :inbound_phone, ticket: ticket) }
|
|
|
|
|
|
|
|
let(:customer) { agent }
|
|
|
|
let(:ticket) { create(:ticket, customer_id: customer.id) }
|
|
|
|
|
|
|
|
it 'includes email in from' do
|
|
|
|
expect(article.from).not_to include agent.email
|
|
|
|
end
|
2020-09-11 07:25:47 +00:00
|
|
|
end
|
|
|
|
end
|
2021-11-15 14:26:25 +00:00
|
|
|
|
|
|
|
context 'when Agent-Customer in shared organization creates Article' do
|
|
|
|
let(:organization) { create(:organization, shared: true) }
|
|
|
|
let(:agent_a) { create(:agent_and_customer, organization: organization) }
|
|
|
|
let(:agent_b) { create(:agent_and_customer, organization: organization) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:ticket) { create(:ticket, group: group, owner: agent_a, customer: agent_b) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
[agent_a, agent_b].each do |elem|
|
|
|
|
elem.user_groups.create group: group, access: 'create'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it '#origin_by is set correctly', current_user_id: -> { agent_a.id } do
|
|
|
|
article = create(:ticket_article, :inbound_web, ticket: ticket)
|
|
|
|
|
|
|
|
expect(article.origin_by).to be_nil
|
|
|
|
end
|
|
|
|
end
|
2020-09-11 07:25:47 +00:00
|
|
|
end
|