|
@@ -208,28 +208,39 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|
|
end
|
|
|
|
|
|
describe 'delete article', authenticated_as: :user do
|
|
|
- let(:admin) { create :admin, groups: [Group.first] }
|
|
|
- let(:agent) { create :agent, groups: [Group.first] }
|
|
|
- let(:customer) { create :customer }
|
|
|
- let(:ticket) { create :ticket, group: agent.groups.first, customer: customer }
|
|
|
- let(:article) { send(item) }
|
|
|
+ let(:admin) { create :admin, groups: [Group.first] }
|
|
|
+ let(:agent) { create :agent, groups: [Group.first] }
|
|
|
+ let(:other_agent) { create :agent, groups: [Group.first] }
|
|
|
+ let(:customer) { create :customer }
|
|
|
+ let(:ticket) { create :ticket, group: agent.groups.first, customer: customer }
|
|
|
+ let(:article) { send(item) }
|
|
|
|
|
|
def article_communication
|
|
|
create_ticket_article(sender_name: 'Agent', internal: false, type_name: 'email', updated_by: customer)
|
|
|
end
|
|
|
|
|
|
- def article_note
|
|
|
- create_ticket_article(sender_name: 'Agent', internal: true, type_name: 'note', updated_by: agent)
|
|
|
+ def article_note_self
|
|
|
+ create_ticket_article(sender_name: 'Agent', internal: true, type_name: 'note', updated_by: user)
|
|
|
+ end
|
|
|
+
|
|
|
+ def article_note_other
|
|
|
+ create_ticket_article(sender_name: 'Agent', internal: true, type_name: 'note', updated_by: other_agent)
|
|
|
end
|
|
|
|
|
|
def article_note_customer
|
|
|
create_ticket_article(sender_name: 'Customer', internal: false, type_name: 'note', updated_by: customer)
|
|
|
end
|
|
|
|
|
|
- def article_note_communication
|
|
|
+ def article_note_communication_self
|
|
|
+ create(:ticket_article_type, name: 'note_communication', communication: true)
|
|
|
+
|
|
|
+ create_ticket_article(sender_name: 'Agent', internal: true, type_name: 'note_communication', updated_by: user)
|
|
|
+ end
|
|
|
+
|
|
|
+ def article_note_communication_other
|
|
|
create(:ticket_article_type, name: 'note_communication', communication: true)
|
|
|
|
|
|
- create_ticket_article(sender_name: 'Agent', internal: true, type_name: 'note_communication', updated_by: agent)
|
|
|
+ create_ticket_article(sender_name: 'Agent', internal: true, type_name: 'note_communication', updated_by: other_agent)
|
|
|
end
|
|
|
|
|
|
def create_ticket_article(sender_name:, internal:, type_name:, updated_by:)
|
|
@@ -243,7 +254,7 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|
|
context 'going through full stack' do
|
|
|
context 'as admin' do
|
|
|
let(:user) { admin }
|
|
|
- let(:item) { 'article_communication' }
|
|
|
+ let(:item) { 'article_note_self' }
|
|
|
let(:offset) { 0.minutes }
|
|
|
|
|
|
it 'succeeds' do
|
|
@@ -298,19 +309,27 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|
|
|
|
|
include_examples 'deleting ticket article',
|
|
|
item: 'article_communication',
|
|
|
- now: true, later: true, much_later: true
|
|
|
+ now: false, later: false, much_later: false
|
|
|
+
|
|
|
+ include_examples 'deleting ticket article',
|
|
|
+ item: 'article_note_self',
|
|
|
+ now: true, later: true, much_later: false
|
|
|
|
|
|
include_examples 'deleting ticket article',
|
|
|
- item: 'article_note',
|
|
|
- now: true, later: true, much_later: true
|
|
|
+ item: 'article_note_other',
|
|
|
+ now: false, later: false, much_later: false
|
|
|
|
|
|
include_examples 'deleting ticket article',
|
|
|
item: 'article_note_customer',
|
|
|
- now: true, later: true, much_later: true
|
|
|
+ now: false, later: false, much_later: false
|
|
|
|
|
|
include_examples 'deleting ticket article',
|
|
|
- item: 'article_note_communication',
|
|
|
- now: true, later: true, much_later: true
|
|
|
+ item: 'article_note_communication_self',
|
|
|
+ now: false, later: false, much_later: false
|
|
|
+
|
|
|
+ include_examples 'deleting ticket article',
|
|
|
+ item: 'article_note_communication_other',
|
|
|
+ now: false, later: false, much_later: false
|
|
|
end
|
|
|
|
|
|
context 'as agent' do
|
|
@@ -321,16 +340,24 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|
|
now: false, later: false, much_later: false
|
|
|
|
|
|
include_examples 'deleting ticket article',
|
|
|
- item: 'article_note',
|
|
|
+ item: 'article_note_self',
|
|
|
now: true, later: true, much_later: false
|
|
|
|
|
|
+ include_examples 'deleting ticket article',
|
|
|
+ item: 'article_note_other',
|
|
|
+ now: false, later: false, much_later: false
|
|
|
+
|
|
|
include_examples 'deleting ticket article',
|
|
|
item: 'article_note_customer',
|
|
|
now: false, later: false, much_later: false
|
|
|
|
|
|
include_examples 'deleting ticket article',
|
|
|
- item: 'article_note_communication',
|
|
|
- now: true, later: true, much_later: false
|
|
|
+ item: 'article_note_communication_self',
|
|
|
+ now: false, later: false, much_later: false
|
|
|
+
|
|
|
+ include_examples 'deleting ticket article',
|
|
|
+ item: 'article_note_communication_other',
|
|
|
+ now: false, later: false, much_later: false
|
|
|
end
|
|
|
|
|
|
context 'as customer' do
|
|
@@ -352,14 +379,15 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|
|
context 'as admin' do
|
|
|
let(:user) { admin }
|
|
|
|
|
|
- include_examples 'according to permission matrix', item: 'article_note', expects_visible: true, offset: 8000.seconds, description: 'outside of delete timeframe'
|
|
|
+ include_examples 'according to permission matrix', item: 'article_note_self', expects_visible: true, offset: 5000.seconds, description: 'outside of delete timeframe'
|
|
|
+ include_examples 'according to permission matrix', item: 'article_note_self', expects_visible: false, offset: 8000.seconds, description: 'outside of delete timeframe'
|
|
|
end
|
|
|
|
|
|
context 'as agent' do
|
|
|
let(:user) { agent }
|
|
|
|
|
|
- include_examples 'according to permission matrix', item: 'article_note', expects_visible: true, offset: 5000.seconds, description: 'outside of delete timeframe'
|
|
|
- include_examples 'according to permission matrix', item: 'article_note', expects_visible: false, offset: 8000.seconds, description: 'outside of delete timeframe'
|
|
|
+ include_examples 'according to permission matrix', item: 'article_note_self', expects_visible: true, offset: 5000.seconds, description: 'outside of delete timeframe'
|
|
|
+ include_examples 'according to permission matrix', item: 'article_note_self', expects_visible: false, offset: 8000.seconds, description: 'outside of delete timeframe'
|
|
|
end
|
|
|
end
|
|
|
|
|
@@ -369,7 +397,7 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|
|
context 'as agent' do
|
|
|
let(:user) { agent }
|
|
|
|
|
|
- include_examples 'according to permission matrix', item: 'article_note', expects_visible: true, offset: 99.days, description: 'long after'
|
|
|
+ include_examples 'according to permission matrix', item: 'article_note_self', expects_visible: true, offset: 99.days, description: 'long after'
|
|
|
end
|
|
|
end
|
|
|
end
|
|
@@ -378,7 +406,7 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|
|
before { Setting.set 'ui_ticket_zoom_article_delete_timeframe', 5 }
|
|
|
|
|
|
let(:user) { agent }
|
|
|
- let(:item) { 'article_note' }
|
|
|
+ let(:item) { 'article_note_self' }
|
|
|
let!(:article) { send(item) }
|
|
|
let(:offset) { 0.seconds }
|
|
|
|