Refactoring of NotificationFactory.
This commit is contained in:
parent
a71a87be60
commit
ed5b058d6e
11 changed files with 521 additions and 805 deletions
|
@ -175,7 +175,7 @@ class FirstStepsController < ApplicationController
|
||||||
customer = test_customer
|
customer = test_customer
|
||||||
from = "#{customer.fullname} <#{customer.email}>"
|
from = "#{customer.fullname} <#{customer.email}>"
|
||||||
original_user_id = UserInfo.current_user_id
|
original_user_id = UserInfo.current_user_id
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
template: 'test_ticket',
|
template: 'test_ticket',
|
||||||
locale: agent.preferences[:locale] || 'en-us',
|
locale: agent.preferences[:locale] || 'en-us',
|
||||||
objects: {
|
objects: {
|
||||||
|
|
|
@ -136,7 +136,7 @@ class UsersController < ApplicationController
|
||||||
# send inviteation if needed / only if session exists
|
# send inviteation if needed / only if session exists
|
||||||
if params[:invite] && current_user
|
if params[:invite] && current_user
|
||||||
token = Token.create(action: 'PasswordReset', user_id: user.id)
|
token = Token.create(action: 'PasswordReset', user_id: user.id)
|
||||||
NotificationFactory.notification(
|
NotificationFactory::Mailer.notification(
|
||||||
template: 'user_invite',
|
template: 'user_invite',
|
||||||
user: user,
|
user: user,
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -150,7 +150,7 @@ class UsersController < ApplicationController
|
||||||
# send email verify
|
# send email verify
|
||||||
if params[:signup] && !current_user
|
if params[:signup] && !current_user
|
||||||
token = Token.create(action: 'EmailVerify', user_id: user.id)
|
token = Token.create(action: 'EmailVerify', user_id: user.id)
|
||||||
NotificationFactory.notification(
|
NotificationFactory::Mailer.notification(
|
||||||
template: 'signup',
|
template: 'signup',
|
||||||
user: user,
|
user: user,
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -421,7 +421,7 @@ curl http://localhost/api/v1/users/password_reset.json -v -u #{login}:#{password
|
||||||
|
|
||||||
# send mail
|
# send mail
|
||||||
user = result[:user]
|
user = result[:user]
|
||||||
NotificationFactory.notification(
|
NotificationFactory::Mailer.notification(
|
||||||
template: 'password_reset',
|
template: 'password_reset',
|
||||||
user: user,
|
user: user,
|
||||||
objects: result
|
objects: result
|
||||||
|
@ -478,7 +478,7 @@ curl http://localhost/api/v1/users/password_reset_verify.json -v -u #{login}:#{p
|
||||||
|
|
||||||
# send mail
|
# send mail
|
||||||
if user
|
if user
|
||||||
NotificationFactory.notification(
|
NotificationFactory::Mailer.notification(
|
||||||
template: 'password_change',
|
template: 'password_change',
|
||||||
user: user,
|
user: user,
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -547,7 +547,7 @@ curl http://localhost/api/v1/users/password_change.json -v -u #{login}:#{passwor
|
||||||
|
|
||||||
user.update_attributes(password: params[:password_new])
|
user.update_attributes(password: params[:password_new])
|
||||||
|
|
||||||
NotificationFactory.notification(
|
NotificationFactory::Mailer.notification(
|
||||||
template: 'password_change',
|
template: 'password_change',
|
||||||
user: user,
|
user: user,
|
||||||
objects: {
|
objects: {
|
||||||
|
|
|
@ -59,7 +59,7 @@ class Observer::Ticket::Notification::BackgroundJob
|
||||||
end
|
end
|
||||||
already_checked_recipient_ids = {}
|
already_checked_recipient_ids = {}
|
||||||
possible_recipients.each {|user|
|
possible_recipients.each {|user|
|
||||||
result = NotificationFactory.notification_settings(user, ticket, @p[:type])
|
result = NotificationFactory::Mailer.notification_settings(user, ticket, @p[:type])
|
||||||
next if !result
|
next if !result
|
||||||
next if already_checked_recipient_ids[result[:user].id]
|
next if already_checked_recipient_ids[result[:user].id]
|
||||||
already_checked_recipient_ids[result[:user].id] = true
|
already_checked_recipient_ids[result[:user].id] = true
|
||||||
|
@ -165,7 +165,7 @@ class Observer::Ticket::Notification::BackgroundJob
|
||||||
raise "unknown type for notification #{@p[:type]}"
|
raise "unknown type for notification #{@p[:type]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
NotificationFactory.notification(
|
NotificationFactory::Mailer.notification(
|
||||||
template: template,
|
template: template,
|
||||||
user: user,
|
user: user,
|
||||||
objects: {
|
objects: {
|
||||||
|
|
|
@ -189,7 +189,7 @@ send user notification about new device or new location for device
|
||||||
def notification_send(template)
|
def notification_send(template)
|
||||||
user = User.find(user_id)
|
user = User.find(user_id)
|
||||||
|
|
||||||
NotificationFactory.notification(
|
NotificationFactory::Mailer.notification(
|
||||||
template: template,
|
template: template,
|
||||||
user: user,
|
user: user,
|
||||||
objects: {
|
objects: {
|
||||||
|
|
|
@ -30,13 +30,16 @@
|
||||||
color: #aaaaaa;
|
color: #aaaaaa;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<% if @objects[:standalone] != true %>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<%= c 'product_name' %> <%= t 'Notification' %>
|
<%= c 'product_name' %> <%= t 'Notification' %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%= d 'message', false %>
|
<%= d 'message', false %>
|
||||||
|
|
||||||
|
<% if @objects[:standalone] != true %>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<a href="<%= c 'http_type' %>://<%= c 'fqdn' %>/#profile/notifications"><%= t 'Manage your notifications settings' %></a> <% if !c('organization').empty? %>| <%= c 'organization' %><% end %>
|
<a href="<%= c 'http_type' %>://<%= c 'fqdn' %>/#profile/notifications"><%= t 'Manage your notifications settings' %></a> <% if !c('organization').empty? %>| <%= c 'organization' %><% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -2,330 +2,42 @@ module NotificationFactory
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
get notification settings for user and notification type
|
result = NotificationFactory.template_read(
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(user, ticket, type)
|
|
||||||
|
|
||||||
type: create | update | reminder_reached | pending
|
|
||||||
|
|
||||||
returns
|
|
||||||
|
|
||||||
{
|
|
||||||
user: user,
|
|
||||||
channels: {
|
|
||||||
online: true,
|
|
||||||
email: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
=end
|
|
||||||
|
|
||||||
def self.notification_settings(user, ticket, type)
|
|
||||||
return if !user.preferences
|
|
||||||
return if !user.preferences['notification_config']
|
|
||||||
matrix = user.preferences['notification_config']['matrix']
|
|
||||||
return if !matrix
|
|
||||||
|
|
||||||
# check if group is in selecd groups
|
|
||||||
if ticket.owner_id != user.id
|
|
||||||
selected_group_ids = user.preferences['notification_config']['group_ids']
|
|
||||||
if selected_group_ids
|
|
||||||
if selected_group_ids.class == Array
|
|
||||||
hit = nil
|
|
||||||
if selected_group_ids.empty?
|
|
||||||
hit = true
|
|
||||||
elsif selected_group_ids[0] == '-' && selected_group_ids.count == 1
|
|
||||||
hit = true
|
|
||||||
else
|
|
||||||
hit = false
|
|
||||||
selected_group_ids.each {|selected_group_id|
|
|
||||||
if selected_group_id.to_s == ticket.group_id.to_s
|
|
||||||
hit = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
return if !hit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return if !matrix[type]
|
|
||||||
data = matrix[type]
|
|
||||||
return if !data
|
|
||||||
return if !data['criteria']
|
|
||||||
channels = data['channel']
|
|
||||||
return if !channels
|
|
||||||
if data['criteria']['owned_by_me'] && ticket.owner_id == user.id
|
|
||||||
return {
|
|
||||||
user: user,
|
|
||||||
channels: channels
|
|
||||||
}
|
|
||||||
end
|
|
||||||
if data['criteria']['owned_by_nobody'] && ticket.owner_id == 1
|
|
||||||
return {
|
|
||||||
user: user,
|
|
||||||
channels: channels
|
|
||||||
}
|
|
||||||
end
|
|
||||||
return if !data['criteria']['no']
|
|
||||||
{
|
|
||||||
user: user,
|
|
||||||
channels: channels
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
=begin
|
|
||||||
|
|
||||||
# deprecated, will be removed with 2.0
|
|
||||||
|
|
||||||
result_string = NotificationFactory.build(
|
|
||||||
string: 'Hi #{recipient.firstname},',
|
|
||||||
objects: {
|
|
||||||
ticket : ticket,
|
|
||||||
recipient: User.find(2),
|
|
||||||
},
|
|
||||||
locale: 'en',
|
|
||||||
)
|
|
||||||
|
|
||||||
=end
|
|
||||||
|
|
||||||
def self.build(data)
|
|
||||||
|
|
||||||
data[:string].gsub!( / \#\{ \s* ( .+? ) \s* \} /xm ) { |placeholder|
|
|
||||||
|
|
||||||
# store possible callback to work with
|
|
||||||
# and check if it's valid for execution
|
|
||||||
original_string = $&
|
|
||||||
callback = $1
|
|
||||||
|
|
||||||
object_name = nil
|
|
||||||
object_method = nil
|
|
||||||
|
|
||||||
if callback =~ /\A ( [\w]+ )\.( [\w\.]+ ) \z/x
|
|
||||||
object_name = $1
|
|
||||||
object_method = $2
|
|
||||||
end
|
|
||||||
|
|
||||||
# do validaton, ignore some methodes
|
|
||||||
if callback =~ /(`|\.(|\s*)(save|destroy|delete|remove|drop|update\(|update_att|create\(|new|all|where|find))/i
|
|
||||||
placeholder = "#{original_string} (not allowed)"
|
|
||||||
|
|
||||||
# get value based on object_name and object_method
|
|
||||||
elsif object_name && object_method
|
|
||||||
|
|
||||||
# use config params
|
|
||||||
if object_name == 'config'
|
|
||||||
placeholder = Setting.get(object_method)
|
|
||||||
|
|
||||||
# if object_name dosn't exist
|
|
||||||
elsif !data[:objects][object_name.to_sym]
|
|
||||||
placeholder = "\#{#{object_name} / no such object}"
|
|
||||||
else
|
|
||||||
value = nil
|
|
||||||
object_refs = data[:objects][object_name.to_sym]
|
|
||||||
object_methods = object_method.split('.')
|
|
||||||
object_methods_s = ''
|
|
||||||
object_methods.each {|method|
|
|
||||||
if object_methods_s != ''
|
|
||||||
object_methods_s += '.'
|
|
||||||
end
|
|
||||||
object_methods_s += method
|
|
||||||
|
|
||||||
# if method exists
|
|
||||||
if !object_refs.respond_to?( method.to_sym )
|
|
||||||
value = "\#{#{object_name}.#{object_methods_s} / no such method}"
|
|
||||||
break
|
|
||||||
end
|
|
||||||
object_refs = object_refs.send( method.to_sym )
|
|
||||||
|
|
||||||
# add body quote
|
|
||||||
next if object_name != 'article'
|
|
||||||
next if method != 'body'
|
|
||||||
|
|
||||||
next if data[:objects][:article].content_type != 'text/html'
|
|
||||||
|
|
||||||
object_refs = object_refs.html2text.chomp
|
|
||||||
}
|
|
||||||
placeholder = if !value
|
|
||||||
object_refs
|
|
||||||
else
|
|
||||||
value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
placeholder
|
|
||||||
}
|
|
||||||
|
|
||||||
# translate
|
|
||||||
data[:string].gsub!( /i18n\((|.+?)\)/ ) {
|
|
||||||
string = $1
|
|
||||||
locale = data[:locale] || 'en'
|
|
||||||
|
|
||||||
Translation.translate( locale, string )
|
|
||||||
}
|
|
||||||
|
|
||||||
data[:string]
|
|
||||||
end
|
|
||||||
|
|
||||||
=begin
|
|
||||||
|
|
||||||
success = NotificationFactory.send(
|
|
||||||
recipient: User.find(123),
|
|
||||||
subject: 'sime subject',
|
|
||||||
body: 'some body',
|
|
||||||
content_type: '', # optional, e. g. 'text/html'
|
|
||||||
references: ['message-id123', 'message-id456'],
|
|
||||||
)
|
|
||||||
|
|
||||||
=end
|
|
||||||
|
|
||||||
def self.send(data)
|
|
||||||
sender = Setting.get('notification_sender')
|
|
||||||
Rails.logger.info "Send notification to: #{data[:recipient][:email]} (from #{sender})"
|
|
||||||
|
|
||||||
content_type = 'text/plain'
|
|
||||||
if data[:content_type]
|
|
||||||
content_type = data[:content_type]
|
|
||||||
end
|
|
||||||
|
|
||||||
# get active Email::Outbound Channel and send
|
|
||||||
channel = Channel.find_by(area: 'Email::Notification', active: true)
|
|
||||||
channel.deliver(
|
|
||||||
{
|
|
||||||
# in_reply_to: in_reply_to,
|
|
||||||
from: sender,
|
|
||||||
to: data[:recipient][:email],
|
|
||||||
subject: data[:subject],
|
|
||||||
references: data[:references],
|
|
||||||
body: data[:body],
|
|
||||||
content_type: content_type,
|
|
||||||
},
|
|
||||||
true
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
=begin
|
|
||||||
|
|
||||||
NotificationFactory.notification(
|
|
||||||
template: 'password_reset',
|
|
||||||
user: User.find(2),
|
|
||||||
objects: {
|
|
||||||
recipient: User.find(2),
|
|
||||||
},
|
|
||||||
main_object: ticket.find(123), # optional
|
|
||||||
references: ['message-id123', 'message-id456'],
|
|
||||||
)
|
|
||||||
|
|
||||||
=end
|
|
||||||
|
|
||||||
def self.notification(data)
|
|
||||||
|
|
||||||
# get subject
|
|
||||||
result = NotificationFactory.template(
|
|
||||||
template: data[:template],
|
|
||||||
locale: data[:user].preferences[:locale],
|
|
||||||
objects: data[:objects],
|
|
||||||
)
|
|
||||||
|
|
||||||
# rebuild subject
|
|
||||||
if data[:main_object] && data[:main_object].respond_to?(:subject_build)
|
|
||||||
result[:subject] = data[:main_object].subject_build(result[:subject])
|
|
||||||
end
|
|
||||||
|
|
||||||
NotificationFactory.send(
|
|
||||||
recipient: data[:user],
|
|
||||||
subject: result[:subject],
|
|
||||||
body: result[:body],
|
|
||||||
content_type: 'text/html',
|
|
||||||
references: data[:references],
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
=begin
|
|
||||||
|
|
||||||
get count of already sent notifications
|
|
||||||
|
|
||||||
count = NotificationFactory.already_sent?(ticket, recipient_user, type)
|
|
||||||
|
|
||||||
retunes
|
|
||||||
|
|
||||||
8
|
|
||||||
|
|
||||||
=end
|
|
||||||
|
|
||||||
def self.already_sent?(ticket, recipient, type)
|
|
||||||
result = ticket.history_get()
|
|
||||||
count = 0
|
|
||||||
result.each {|item|
|
|
||||||
next if item['type'] != 'notification'
|
|
||||||
next if item['object'] != 'Ticket'
|
|
||||||
next if item['value_to'] !~ /#{recipient.email}/i
|
|
||||||
next if item['value_to'] !~ /#{type}/i
|
|
||||||
count += 1
|
|
||||||
}
|
|
||||||
count
|
|
||||||
end
|
|
||||||
|
|
||||||
=begin
|
|
||||||
|
|
||||||
result = NotificationFactory.template(
|
|
||||||
template: 'password_reset',
|
template: 'password_reset',
|
||||||
locale: 'en-us',
|
locale: 'en-us',
|
||||||
objects: {
|
format: 'html', # md
|
||||||
recipient: User.find(2),
|
type: 'mailer', # slack
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
result = NotificationFactory.template(
|
|
||||||
templateInline: "Invitation to <%= c 'product_name' %> at <%= c 'fqdn' %>",
|
|
||||||
locale: 'en-us',
|
|
||||||
objects: {
|
|
||||||
recipient: User.find(2),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
only raw subject/body
|
|
||||||
|
|
||||||
result = NotificationFactory.template(
|
|
||||||
template: 'password_reset',
|
|
||||||
locale: 'en-us',
|
|
||||||
objects: {
|
|
||||||
recipient: User.find(2),
|
|
||||||
},
|
|
||||||
raw: true,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
|
||||||
{
|
{
|
||||||
subject: 'some sobject',
|
subject: 'some subject',
|
||||||
body: 'some body',
|
body: 'some body',
|
||||||
}
|
}
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.template(data)
|
def self.template_read(data)
|
||||||
|
|
||||||
if data[:templateInline]
|
|
||||||
return NotificationFactory::Template.new(data[:objects], data[:locale], data[:templateInline], false).render
|
|
||||||
end
|
|
||||||
|
|
||||||
template_subject = nil
|
template_subject = nil
|
||||||
template_body = ''
|
template_body = ''
|
||||||
locale = data[:locale] || 'en'
|
locale = data[:locale] || 'en'
|
||||||
template = data[:template]
|
template = data[:template]
|
||||||
|
format = data[:format]
|
||||||
|
type = data[:type]
|
||||||
root = Rails.root
|
root = Rails.root
|
||||||
location = "#{root}/app/views/mailer/#{template}/#{locale}.html.erb"
|
location = "#{root}/app/views/#{type}/#{template}/#{locale}.#{format}.erb"
|
||||||
|
|
||||||
# as fallback, use 2 char locale
|
# as fallback, use 2 char locale
|
||||||
if !File.exist?(location)
|
if !File.exist?(location)
|
||||||
locale = locale[0, 2]
|
locale = locale[0, 2]
|
||||||
location = "#{root}/app/views/mailer/#{template}/#{locale}.html.erb"
|
location = "#{root}/app/views/#{type}/#{template}/#{locale}.#{format}.erb"
|
||||||
end
|
end
|
||||||
|
|
||||||
# as fallback, use en
|
# as fallback, use en
|
||||||
if !File.exist?(location)
|
if !File.exist?(location)
|
||||||
location = "#{root}/app/views/mailer/#{template}/en.html.erb"
|
location = "#{root}/app/views/#{type}/#{template}/en.#{format}.erb"
|
||||||
end
|
end
|
||||||
|
|
||||||
File.open(location, 'r:UTF-8').each do |line|
|
File.open(location, 'r:UTF-8').each do |line|
|
||||||
|
@ -335,94 +47,34 @@ returns
|
||||||
end
|
end
|
||||||
template_body += line
|
template_body += line
|
||||||
end
|
end
|
||||||
|
|
||||||
message_subject = NotificationFactory::Template.new(data[:objects], data[:locale], template_subject, false).render
|
|
||||||
message_body = NotificationFactory::Template.new(data[:objects], data[:locale], template_body).render
|
|
||||||
|
|
||||||
if !data[:raw]
|
|
||||||
application_template = nil
|
|
||||||
File.open("#{root}/app/views/mailer/application.html.erb", 'r:UTF-8') do |file|
|
|
||||||
application_template = file.read
|
|
||||||
end
|
|
||||||
data[:objects][:message] = message_body
|
|
||||||
message_body = NotificationFactory::Template.new(data[:objects], data[:locale], application_template).render
|
|
||||||
end
|
|
||||||
{
|
{
|
||||||
subject: message_subject,
|
subject: template_subject,
|
||||||
body: message_body,
|
body: template_body,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
class Template
|
=begin
|
||||||
|
|
||||||
def initialize(objects, locale, template, escape = true)
|
string = NotificationFactory.application_template_read(
|
||||||
@objects = objects
|
format: 'html', # md
|
||||||
@locale = locale || 'en-us'
|
type: 'mailer', # slack
|
||||||
@template = template
|
)
|
||||||
@escape = escape
|
|
||||||
end
|
returns
|
||||||
|
|
||||||
def render
|
'some template'
|
||||||
ERB.new(@template).result(binding)
|
|
||||||
end
|
=end
|
||||||
|
|
||||||
def d(key, escape = nil)
|
def self.application_template_read(data)
|
||||||
|
format = data[:format]
|
||||||
# do validaton, ignore some methodes
|
type = data[:type]
|
||||||
if key =~ /(`|\.(|\s*)(save|destroy|delete|remove|drop|update\(|update_att|create\(|new|all|where|find))/i
|
root = Rails.root
|
||||||
return "#{key} (not allowed)"
|
application_template = nil
|
||||||
end
|
File.open("#{root}/app/views/#{type}/application.#{format}.erb", 'r:UTF-8') do |file|
|
||||||
|
application_template = file.read
|
||||||
value = nil
|
|
||||||
object_methods = key.split('.')
|
|
||||||
object_name = object_methods.shift.to_sym
|
|
||||||
object_refs = @objects[object_name]
|
|
||||||
object_methods_s = ''
|
|
||||||
object_methods.each {|method|
|
|
||||||
if object_methods_s != ''
|
|
||||||
object_methods_s += '.'
|
|
||||||
end
|
|
||||||
object_methods_s += method
|
|
||||||
|
|
||||||
# if method exists
|
|
||||||
if !object_refs.respond_to?( method.to_sym )
|
|
||||||
value = "\#{#{object_name}.#{object_methods_s} / no such method}"
|
|
||||||
break
|
|
||||||
end
|
|
||||||
object_refs = object_refs.send( method.to_sym )
|
|
||||||
}
|
|
||||||
placeholder = if !value
|
|
||||||
object_refs
|
|
||||||
else
|
|
||||||
value
|
|
||||||
end
|
|
||||||
return placeholder if escape == false || (escape.nil? && !@escape)
|
|
||||||
h placeholder
|
|
||||||
end
|
|
||||||
|
|
||||||
def c(key, escape = nil)
|
|
||||||
config = Setting.get(key)
|
|
||||||
return config if escape == false || (escape.nil? && !@escape)
|
|
||||||
h config
|
|
||||||
end
|
|
||||||
|
|
||||||
def t(key, escape = nil)
|
|
||||||
translation = Translation.translate(@locale, key)
|
|
||||||
return translation if escape == false || (escape.nil? && !@escape)
|
|
||||||
h translation
|
|
||||||
end
|
|
||||||
|
|
||||||
def a(article)
|
|
||||||
content_type = d "#{article}.content_type", false
|
|
||||||
if content_type =~ /html/
|
|
||||||
return d "#{article}.body", false
|
|
||||||
end
|
|
||||||
d("#{article}.body", false).text2html
|
|
||||||
end
|
|
||||||
|
|
||||||
def h(key)
|
|
||||||
return key if !key
|
|
||||||
CGI.escapeHTML(key.to_s)
|
|
||||||
end
|
end
|
||||||
|
application_template
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
248
lib/notification_factory/mailer.rb
Normal file
248
lib/notification_factory/mailer.rb
Normal file
|
@ -0,0 +1,248 @@
|
||||||
|
class NotificationFactory::Mailer
|
||||||
|
|
||||||
|
=begin
|
||||||
|
|
||||||
|
get notification settings for user and notification type
|
||||||
|
|
||||||
|
result = NotificationFactory::Mailer.notification_settings(user, ticket, type)
|
||||||
|
|
||||||
|
type: create | update | reminder_reached | pending
|
||||||
|
|
||||||
|
returns
|
||||||
|
|
||||||
|
{
|
||||||
|
user: user,
|
||||||
|
channels: {
|
||||||
|
online: true,
|
||||||
|
email: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def self.notification_settings(user, ticket, type)
|
||||||
|
return if !user.preferences
|
||||||
|
return if !user.preferences['notification_config']
|
||||||
|
matrix = user.preferences['notification_config']['matrix']
|
||||||
|
return if !matrix
|
||||||
|
|
||||||
|
# check if group is in selecd groups
|
||||||
|
if ticket.owner_id != user.id
|
||||||
|
selected_group_ids = user.preferences['notification_config']['group_ids']
|
||||||
|
if selected_group_ids
|
||||||
|
if selected_group_ids.class == Array
|
||||||
|
hit = nil
|
||||||
|
if selected_group_ids.empty?
|
||||||
|
hit = true
|
||||||
|
elsif selected_group_ids[0] == '-' && selected_group_ids.count == 1
|
||||||
|
hit = true
|
||||||
|
else
|
||||||
|
hit = false
|
||||||
|
selected_group_ids.each {|selected_group_id|
|
||||||
|
if selected_group_id.to_s == ticket.group_id.to_s
|
||||||
|
hit = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
return if !hit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return if !matrix[type]
|
||||||
|
data = matrix[type]
|
||||||
|
return if !data
|
||||||
|
return if !data['criteria']
|
||||||
|
channels = data['channel']
|
||||||
|
return if !channels
|
||||||
|
if data['criteria']['owned_by_me'] && ticket.owner_id == user.id
|
||||||
|
return {
|
||||||
|
user: user,
|
||||||
|
channels: channels
|
||||||
|
}
|
||||||
|
end
|
||||||
|
if data['criteria']['owned_by_nobody'] && ticket.owner_id == 1
|
||||||
|
return {
|
||||||
|
user: user,
|
||||||
|
channels: channels
|
||||||
|
}
|
||||||
|
end
|
||||||
|
return if !data['criteria']['no']
|
||||||
|
{
|
||||||
|
user: user,
|
||||||
|
channels: channels
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
|
||||||
|
success = NotificationFactory::Mailer.send(
|
||||||
|
recipient: User.find(123),
|
||||||
|
subject: 'sime subject',
|
||||||
|
body: 'some body',
|
||||||
|
content_type: '', # optional, e. g. 'text/html'
|
||||||
|
references: ['message-id123', 'message-id456'],
|
||||||
|
)
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def self.send(data)
|
||||||
|
sender = Setting.get('notification_sender')
|
||||||
|
Rails.logger.info "Send notification to: #{data[:recipient][:email]} (from #{sender})"
|
||||||
|
|
||||||
|
content_type = 'text/plain'
|
||||||
|
if data[:content_type]
|
||||||
|
content_type = data[:content_type]
|
||||||
|
end
|
||||||
|
|
||||||
|
# get active Email::Outbound Channel and send
|
||||||
|
channel = Channel.find_by(area: 'Email::Notification', active: true)
|
||||||
|
channel.deliver(
|
||||||
|
{
|
||||||
|
# in_reply_to: in_reply_to,
|
||||||
|
from: sender,
|
||||||
|
to: data[:recipient][:email],
|
||||||
|
subject: data[:subject],
|
||||||
|
references: data[:references],
|
||||||
|
body: data[:body],
|
||||||
|
content_type: content_type,
|
||||||
|
},
|
||||||
|
true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
|
||||||
|
NotificationFactory::Mailer.notification(
|
||||||
|
template: 'password_reset',
|
||||||
|
user: User.find(2),
|
||||||
|
objects: {
|
||||||
|
recipient: User.find(2),
|
||||||
|
},
|
||||||
|
main_object: ticket.find(123), # optional
|
||||||
|
references: ['message-id123', 'message-id456'],
|
||||||
|
standalone: true, # default: false - will send header & footer
|
||||||
|
)
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def self.notification(data)
|
||||||
|
|
||||||
|
# get subject
|
||||||
|
result = NotificationFactory::Mailer.template(
|
||||||
|
template: data[:template],
|
||||||
|
locale: data[:user][:preferences][:locale],
|
||||||
|
objects: data[:objects],
|
||||||
|
standalone: data[:standalone],
|
||||||
|
)
|
||||||
|
|
||||||
|
# rebuild subject
|
||||||
|
if data[:main_object] && data[:main_object].respond_to?(:subject_build)
|
||||||
|
result[:subject] = data[:main_object].subject_build(result[:subject])
|
||||||
|
end
|
||||||
|
|
||||||
|
NotificationFactory::Mailer.send(
|
||||||
|
recipient: data[:user],
|
||||||
|
subject: result[:subject],
|
||||||
|
body: result[:body],
|
||||||
|
content_type: 'text/html',
|
||||||
|
references: data[:references],
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
|
||||||
|
get count of already sent notifications
|
||||||
|
|
||||||
|
count = NotificationFactory::Mailer.already_sent?(ticket, recipient_user, type)
|
||||||
|
|
||||||
|
retunes
|
||||||
|
|
||||||
|
8
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def self.already_sent?(ticket, recipient, type)
|
||||||
|
result = ticket.history_get()
|
||||||
|
count = 0
|
||||||
|
result.each {|item|
|
||||||
|
next if item['type'] != 'notification'
|
||||||
|
next if item['object'] != 'Ticket'
|
||||||
|
next if item['value_to'] !~ /#{recipient.email}/i
|
||||||
|
next if item['value_to'] !~ /#{type}/i
|
||||||
|
count += 1
|
||||||
|
}
|
||||||
|
count
|
||||||
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
|
||||||
|
result = NotificationFactory::Mailer.template(
|
||||||
|
template: 'password_reset',
|
||||||
|
locale: 'en-us',
|
||||||
|
objects: {
|
||||||
|
recipient: User.find(2),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
result = NotificationFactory::Mailer.template(
|
||||||
|
templateInline: "Invitation to <%= c 'product_name' %> at <%= c 'fqdn' %>",
|
||||||
|
locale: 'en-us',
|
||||||
|
objects: {
|
||||||
|
recipient: User.find(2),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
only raw subject/body
|
||||||
|
|
||||||
|
result = NotificationFactory::Mailer.template(
|
||||||
|
template: 'password_reset',
|
||||||
|
locale: 'en-us',
|
||||||
|
objects: {
|
||||||
|
recipient: User.find(2),
|
||||||
|
},
|
||||||
|
raw: true, # will not add application template
|
||||||
|
standalone: true, # default: false - will send header & footer
|
||||||
|
)
|
||||||
|
|
||||||
|
returns
|
||||||
|
|
||||||
|
{
|
||||||
|
subject: 'some subject',
|
||||||
|
body: 'some body',
|
||||||
|
}
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def self.template(data)
|
||||||
|
|
||||||
|
if data[:templateInline]
|
||||||
|
return NotificationFactory::Template.new(data[:objects], data[:locale], data[:templateInline], false).render
|
||||||
|
end
|
||||||
|
|
||||||
|
template = NotificationFactory.template_read(
|
||||||
|
locale: data[:locale] || 'en',
|
||||||
|
template: data[:template],
|
||||||
|
format: 'html',
|
||||||
|
type: 'mailer',
|
||||||
|
)
|
||||||
|
|
||||||
|
message_subject = NotificationFactory::Template.new(data[:objects], data[:locale], template[:subject], false).render
|
||||||
|
message_body = NotificationFactory::Template.new(data[:objects], data[:locale], template[:body]).render
|
||||||
|
|
||||||
|
if !data[:raw]
|
||||||
|
application_template = NotificationFactory.application_template_read(
|
||||||
|
format: 'html',
|
||||||
|
type: 'mailer',
|
||||||
|
)
|
||||||
|
data[:objects][:message] = message_body
|
||||||
|
data[:objects][:standalone] = data[:standalone]
|
||||||
|
message_body = NotificationFactory::Template.new(data[:objects], data[:locale], application_template).render
|
||||||
|
end
|
||||||
|
{
|
||||||
|
subject: message_subject,
|
||||||
|
body: message_body,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
72
lib/notification_factory/template.rb
Normal file
72
lib/notification_factory/template.rb
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
class NotificationFactory::Template
|
||||||
|
|
||||||
|
def initialize(objects, locale, template, escape = true)
|
||||||
|
@objects = objects
|
||||||
|
@locale = locale || 'en-us'
|
||||||
|
@template = template
|
||||||
|
@escape = escape
|
||||||
|
end
|
||||||
|
|
||||||
|
def render
|
||||||
|
ERB.new(@template).result(binding)
|
||||||
|
end
|
||||||
|
|
||||||
|
def d(key, escape = nil)
|
||||||
|
|
||||||
|
# do validaton, ignore some methodes
|
||||||
|
if key =~ /(`|\.(|\s*)(save|destroy|delete|remove|drop|update\(|update_att|create\(|new|all|where|find))/i
|
||||||
|
return "#{key} (not allowed)"
|
||||||
|
end
|
||||||
|
|
||||||
|
value = nil
|
||||||
|
object_methods = key.split('.')
|
||||||
|
object_name = object_methods.shift.to_sym
|
||||||
|
object_refs = @objects[object_name]
|
||||||
|
object_methods_s = ''
|
||||||
|
object_methods.each {|method|
|
||||||
|
if object_methods_s != ''
|
||||||
|
object_methods_s += '.'
|
||||||
|
end
|
||||||
|
object_methods_s += method
|
||||||
|
|
||||||
|
# if method exists
|
||||||
|
if !object_refs.respond_to?( method.to_sym )
|
||||||
|
value = "\#{#{object_name}.#{object_methods_s} / no such method}"
|
||||||
|
break
|
||||||
|
end
|
||||||
|
object_refs = object_refs.send( method.to_sym )
|
||||||
|
}
|
||||||
|
placeholder = if !value
|
||||||
|
object_refs
|
||||||
|
else
|
||||||
|
value
|
||||||
|
end
|
||||||
|
return placeholder if escape == false || (escape.nil? && !@escape)
|
||||||
|
h placeholder
|
||||||
|
end
|
||||||
|
|
||||||
|
def c(key, escape = nil)
|
||||||
|
config = Setting.get(key)
|
||||||
|
return config if escape == false || (escape.nil? && !@escape)
|
||||||
|
h config
|
||||||
|
end
|
||||||
|
|
||||||
|
def t(key, escape = nil)
|
||||||
|
translation = Translation.translate(@locale, key)
|
||||||
|
return translation if escape == false || (escape.nil? && !@escape)
|
||||||
|
h translation
|
||||||
|
end
|
||||||
|
|
||||||
|
def a(article)
|
||||||
|
content_type = d "#{article}.content_type", false
|
||||||
|
if content_type =~ /html/
|
||||||
|
return d "#{article}.body", false
|
||||||
|
end
|
||||||
|
d("#{article}.body", false).text2html
|
||||||
|
end
|
||||||
|
|
||||||
|
def h(key)
|
||||||
|
return key if !key
|
||||||
|
CGI.escapeHTML(key.to_s)
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,12 +1,12 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class NotificationFactoryTest < ActiveSupport::TestCase
|
class NotificationFactoryMailerTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
Translation.load('de-de')
|
Translation.load('de-de')
|
||||||
|
|
||||||
test 'notifications send' do
|
test 'notifications send' do
|
||||||
result = NotificationFactory.send(
|
result = NotificationFactory::Mailer.send(
|
||||||
recipient: User.find(2),
|
recipient: User.find(2),
|
||||||
subject: 'sime subject',
|
subject: 'sime subject',
|
||||||
body: 'some body',
|
body: 'some body',
|
||||||
|
@ -16,7 +16,7 @@ class NotificationFactoryTest < ActiveSupport::TestCase
|
||||||
assert_match('text/plain', result.to_s)
|
assert_match('text/plain', result.to_s)
|
||||||
assert_no_match('text/html', result.to_s)
|
assert_no_match('text/html', result.to_s)
|
||||||
|
|
||||||
result = NotificationFactory.send(
|
result = NotificationFactory::Mailer.send(
|
||||||
recipient: User.find(2),
|
recipient: User.find(2),
|
||||||
subject: 'sime subject',
|
subject: 'sime subject',
|
||||||
body: 'some body',
|
body: 'some body',
|
||||||
|
@ -26,7 +26,7 @@ class NotificationFactoryTest < ActiveSupport::TestCase
|
||||||
assert_match('text/plain', result.to_s)
|
assert_match('text/plain', result.to_s)
|
||||||
assert_no_match('text/html', result.to_s)
|
assert_no_match('text/html', result.to_s)
|
||||||
|
|
||||||
result = NotificationFactory.send(
|
result = NotificationFactory::Mailer.send(
|
||||||
recipient: User.find(2),
|
recipient: User.find(2),
|
||||||
subject: 'sime subject',
|
subject: 'sime subject',
|
||||||
body: 'some <span>body</span>',
|
body: 'some <span>body</span>',
|
||||||
|
@ -38,265 +38,6 @@ class NotificationFactoryTest < ActiveSupport::TestCase
|
||||||
assert_match('text/html', result.to_s)
|
assert_match('text/html', result.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'notifications base' do
|
|
||||||
ticket = Ticket.create(
|
|
||||||
title: 'some title äöüß',
|
|
||||||
group: Group.lookup(name: 'Users'),
|
|
||||||
customer_id: 2,
|
|
||||||
state: Ticket::State.lookup(name: 'new'),
|
|
||||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
|
||||||
updated_by_id: 2,
|
|
||||||
created_by_id: 2,
|
|
||||||
)
|
|
||||||
article_plain = Ticket::Article.create(
|
|
||||||
ticket_id: ticket.id,
|
|
||||||
type_id: Ticket::Article::Type.where(name: 'phone').first.id,
|
|
||||||
sender_id: Ticket::Article::Sender.where(name: 'Customer').first.id,
|
|
||||||
from: 'Zammad Feedback <feedback@example.org>',
|
|
||||||
body: 'some text',
|
|
||||||
internal: false,
|
|
||||||
updated_by_id: 1,
|
|
||||||
created_by_id: 1,
|
|
||||||
)
|
|
||||||
tests = [
|
|
||||||
{
|
|
||||||
locale: 'en',
|
|
||||||
string: 'Hi #{recipient.firstname},',
|
|
||||||
result: 'Hi Nicole,',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'Hi #{recipient.firstname},',
|
|
||||||
result: 'Hi Nicole,',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'Hi #{recipient.firstname}, Group: #{ticket.group.name}',
|
|
||||||
result: 'Hi Nicole, Group: Users',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: '#{config.http_type} some text',
|
|
||||||
result: 'http some text',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'i18n(New) some text',
|
|
||||||
result: 'Neu some text',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: '\'i18n(#{ticket.state.name})\' ticket state',
|
|
||||||
result: '\'neu\' ticket state',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'a #{not_existing_object.test}',
|
|
||||||
result: 'a #{not_existing_object / no such object}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'a #{ticket.level1}',
|
|
||||||
result: 'a #{ticket.level1 / no such method}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'a #{ticket.level1.level2}',
|
|
||||||
result: 'a #{ticket.level1 / no such method}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'a #{ticket.title.level2}',
|
|
||||||
result: 'a #{ticket.title.level2 / no such method}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'by #{ticket.updated_by.fullname}',
|
|
||||||
result: 'by Nicole Braun',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'Subject #{article.from}, Group: #{ticket.group.name}',
|
|
||||||
result: 'Subject Zammad Feedback <feedback@example.org>, Group: Users',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'Body #{article.body}, Group: #{ticket.group.name}',
|
|
||||||
result: 'Body some text, Group: Users',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: '\#{puts `ls`}',
|
|
||||||
result: '\#{puts `ls`} (not allowed)',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'test i18n(new)',
|
|
||||||
result: 'test neu',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'test i18n()',
|
|
||||||
result: 'test ',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'test i18n(new) i18n(open)',
|
|
||||||
result: 'test neu offen',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
tests.each { |test|
|
|
||||||
result = NotificationFactory.build(
|
|
||||||
string: test[:string],
|
|
||||||
objects: {
|
|
||||||
ticket: ticket,
|
|
||||||
article: article_plain,
|
|
||||||
recipient: User.find(2),
|
|
||||||
},
|
|
||||||
locale: test[:locale]
|
|
||||||
)
|
|
||||||
assert_equal(test[:result], result, 'verify result')
|
|
||||||
}
|
|
||||||
|
|
||||||
ticket.destroy
|
|
||||||
end
|
|
||||||
|
|
||||||
test 'notifications html' do
|
|
||||||
ticket = Ticket.create(
|
|
||||||
title: 'some title <b>äöüß</b> 2',
|
|
||||||
group: Group.lookup(name: 'Users'),
|
|
||||||
customer_id: 2,
|
|
||||||
state: Ticket::State.lookup(name: 'new'),
|
|
||||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
|
||||||
updated_by_id: 1,
|
|
||||||
created_by_id: 1,
|
|
||||||
)
|
|
||||||
article_html = Ticket::Article.create(
|
|
||||||
ticket_id: ticket.id,
|
|
||||||
type_id: Ticket::Article::Type.where(name: 'phone').first.id,
|
|
||||||
sender_id: Ticket::Article::Sender.where(name: 'Customer').first.id,
|
|
||||||
from: 'Zammad Feedback <feedback@example.org>',
|
|
||||||
body: 'some <b>text</b><br>next line',
|
|
||||||
content_type: 'text/html',
|
|
||||||
internal: false,
|
|
||||||
updated_by_id: 1,
|
|
||||||
created_by_id: 1,
|
|
||||||
)
|
|
||||||
tests = [
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'Subject #{ticket.title}',
|
|
||||||
result: 'Subject some title <b>äöüß</b> 2',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'Subject #{article.from}, Group: #{ticket.group.name}',
|
|
||||||
result: 'Subject Zammad Feedback <feedback@example.org>, Group: Users',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'Body #{article.body}, Group: #{ticket.group.name}',
|
|
||||||
result: 'Body some text
|
|
||||||
next line, Group: Users',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
tests.each { |test|
|
|
||||||
result = NotificationFactory.build(
|
|
||||||
string: test[:string],
|
|
||||||
objects: {
|
|
||||||
ticket: ticket,
|
|
||||||
article: article_html,
|
|
||||||
recipient: User.find(2),
|
|
||||||
},
|
|
||||||
locale: test[:locale]
|
|
||||||
)
|
|
||||||
assert_equal(test[:result], result, 'verify result')
|
|
||||||
}
|
|
||||||
|
|
||||||
ticket.destroy
|
|
||||||
end
|
|
||||||
|
|
||||||
test 'notifications attack' do
|
|
||||||
ticket = Ticket.create(
|
|
||||||
title: 'some title <b>äöüß</b> 3',
|
|
||||||
group: Group.lookup(name: 'Users'),
|
|
||||||
customer_id: 2,
|
|
||||||
state: Ticket::State.lookup(name: 'new'),
|
|
||||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
|
||||||
updated_by_id: 1,
|
|
||||||
created_by_id: 1,
|
|
||||||
)
|
|
||||||
article_html = Ticket::Article.create(
|
|
||||||
ticket_id: ticket.id,
|
|
||||||
type_id: Ticket::Article::Type.where(name: 'phone').first.id,
|
|
||||||
sender_id: Ticket::Article::Sender.where(name: 'Customer').first.id,
|
|
||||||
from: 'Zammad Feedback <feedback@example.org>',
|
|
||||||
body: 'some <b>text</b><br>next line',
|
|
||||||
content_type: 'text/html',
|
|
||||||
internal: false,
|
|
||||||
updated_by_id: 1,
|
|
||||||
created_by_id: 1,
|
|
||||||
)
|
|
||||||
tests = [
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: '\#{puts `ls`}',
|
|
||||||
result: '\#{puts `ls`} (not allowed)',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'attack#1 #{article.destroy}',
|
|
||||||
result: 'attack#1 #{article.destroy} (not allowed)',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'attack#2 #{Article.where}',
|
|
||||||
result: 'attack#2 #{Article.where} (not allowed)',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'attack#1 #{article.
|
|
||||||
destroy}',
|
|
||||||
result: 'attack#1 #{article.
|
|
||||||
destroy} (not allowed)',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'attack#1 #{article.find}',
|
|
||||||
result: 'attack#1 #{article.find} (not allowed)',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'attack#1 #{article.update(:name => "test")}',
|
|
||||||
result: 'attack#1 #{article.update(:name => "test")} (not allowed)',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'attack#1 #{article.all}',
|
|
||||||
result: 'attack#1 #{article.all} (not allowed)',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
locale: 'de-de',
|
|
||||||
string: 'attack#1 #{article.delete}',
|
|
||||||
result: 'attack#1 #{article.delete} (not allowed)',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
tests.each { |test|
|
|
||||||
result = NotificationFactory.build(
|
|
||||||
string: test[:string],
|
|
||||||
objects: {
|
|
||||||
ticket: ticket,
|
|
||||||
article: article_html,
|
|
||||||
recipient: User.find(2),
|
|
||||||
},
|
|
||||||
locale: test[:locale]
|
|
||||||
)
|
|
||||||
assert_equal(test[:result], result, 'verify result')
|
|
||||||
}
|
|
||||||
|
|
||||||
ticket.destroy
|
|
||||||
end
|
|
||||||
|
|
||||||
test 'notifications template' do
|
test 'notifications template' do
|
||||||
groups = Group.where(name: 'Users')
|
groups = Group.where(name: 'Users')
|
||||||
roles = Role.where(name: 'Agent')
|
roles = Role.where(name: 'Agent')
|
||||||
|
@ -316,7 +57,7 @@ next line, Group: Users',
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
template: 'password_reset',
|
template: 'password_reset',
|
||||||
locale: 'de-de',
|
locale: 'de-de',
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -330,7 +71,7 @@ next line, Group: Users',
|
||||||
assert_match('Notification<b>xxx</b>', result[:body])
|
assert_match('Notification<b>xxx</b>', result[:body])
|
||||||
assert_no_match('Your', result[:body])
|
assert_no_match('Your', result[:body])
|
||||||
|
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
template: 'password_reset',
|
template: 'password_reset',
|
||||||
locale: 'de',
|
locale: 'de',
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -343,7 +84,7 @@ next line, Group: Users',
|
||||||
assert_match('Notification<b>xxx</b>', result[:body])
|
assert_match('Notification<b>xxx</b>', result[:body])
|
||||||
assert_no_match('Your', result[:body])
|
assert_no_match('Your', result[:body])
|
||||||
|
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
template: 'password_reset',
|
template: 'password_reset',
|
||||||
locale: 'es-us',
|
locale: 'es-us',
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -380,7 +121,7 @@ next line, Group: Users',
|
||||||
)
|
)
|
||||||
|
|
||||||
changes = {}
|
changes = {}
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
template: 'ticket_create',
|
template: 'ticket_create',
|
||||||
locale: 'es-us',
|
locale: 'es-us',
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -397,7 +138,7 @@ next line, Group: Users',
|
||||||
assert_match('Manage your notifications settings', result[:body])
|
assert_match('Manage your notifications settings', result[:body])
|
||||||
assert_no_match('Dein', result[:body])
|
assert_no_match('Dein', result[:body])
|
||||||
|
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
template: 'ticket_create',
|
template: 'ticket_create',
|
||||||
locale: 'de-de',
|
locale: 'de-de',
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -430,7 +171,7 @@ next line, Group: Users',
|
||||||
state: %w(aaa bbb),
|
state: %w(aaa bbb),
|
||||||
group: %w(xxx yyy),
|
group: %w(xxx yyy),
|
||||||
}
|
}
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
template: 'ticket_update',
|
template: 'ticket_update',
|
||||||
locale: 'es-us',
|
locale: 'es-us',
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -447,7 +188,7 @@ next line, Group: Users',
|
||||||
assert_match('Manage your notifications settings', result[:body])
|
assert_match('Manage your notifications settings', result[:body])
|
||||||
assert_no_match('Dein', result[:body])
|
assert_no_match('Dein', result[:body])
|
||||||
|
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
template: 'ticket_update',
|
template: 'ticket_update',
|
||||||
locale: 'de-de',
|
locale: 'de-de',
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -549,146 +290,146 @@ next line, Group: Users',
|
||||||
agent1.preferences[:notification_config][:group_ids] = nil
|
agent1.preferences[:notification_config][:group_ids] = nil
|
||||||
agent1.save
|
agent1.save
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket1, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket1, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket2, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket2, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket3, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket3, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket4, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket4, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
agent2.preferences[:notification_config][:group_ids] = nil
|
agent2.preferences[:notification_config][:group_ids] = nil
|
||||||
agent2.save
|
agent2.save
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket1, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket1, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket2, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket2, 'create')
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket3, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket3, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket4, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket4, 'create')
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
|
|
||||||
# no group selection
|
# no group selection
|
||||||
agent1.preferences[:notification_config][:group_ids] = []
|
agent1.preferences[:notification_config][:group_ids] = []
|
||||||
agent1.save
|
agent1.save
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket1, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket1, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket2, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket2, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket3, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket3, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket4, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket4, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
agent2.preferences[:notification_config][:group_ids] = []
|
agent2.preferences[:notification_config][:group_ids] = []
|
||||||
agent2.save
|
agent2.save
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket1, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket1, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket2, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket2, 'create')
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket3, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket3, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket4, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket4, 'create')
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
|
|
||||||
agent1.preferences[:notification_config][:group_ids] = ['-']
|
agent1.preferences[:notification_config][:group_ids] = ['-']
|
||||||
agent1.save
|
agent1.save
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket1, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket1, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket2, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket2, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket3, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket3, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket4, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket4, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
agent2.preferences[:notification_config][:group_ids] = ['-']
|
agent2.preferences[:notification_config][:group_ids] = ['-']
|
||||||
agent2.save
|
agent2.save
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket1, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket1, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket2, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket2, 'create')
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket3, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket3, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket4, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket4, 'create')
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
|
|
||||||
# dedecated group selection
|
# dedecated group selection
|
||||||
agent1.preferences[:notification_config][:group_ids] = [Group.lookup(name: 'Users').id]
|
agent1.preferences[:notification_config][:group_ids] = [Group.lookup(name: 'Users').id]
|
||||||
agent1.save
|
agent1.save
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket1, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket1, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket2, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket2, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket3, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket3, 'create')
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent1, ticket4, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent1, ticket4, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
agent2.preferences[:notification_config][:group_ids] = [Group.lookup(name: 'Users').id]
|
agent2.preferences[:notification_config][:group_ids] = [Group.lookup(name: 'Users').id]
|
||||||
agent2.save
|
agent2.save
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket1, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket1, 'create')
|
||||||
assert_equal(true, result[:channels][:online])
|
assert_equal(true, result[:channels][:online])
|
||||||
assert_equal(true, result[:channels][:email])
|
assert_equal(true, result[:channels][:email])
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket2, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket2, 'create')
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket3, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket3, 'create')
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
|
|
||||||
result = NotificationFactory.notification_settings(agent2, ticket4, 'create')
|
result = NotificationFactory::Mailer.notification_settings(agent2, ticket4, 'create')
|
||||||
assert_equal(nil, result)
|
assert_equal(nil, result)
|
||||||
|
|
||||||
end
|
end
|
|
@ -60,7 +60,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
tickets = []
|
tickets = []
|
||||||
tickets.push ticket1
|
tickets.push ticket1
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
@ -79,7 +79,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
updated_by_id: customer_user.id,
|
updated_by_id: customer_user.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
@ -117,7 +117,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
tickets = []
|
tickets = []
|
||||||
tickets.push ticket2
|
tickets.push ticket2
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
@ -136,7 +136,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
updated_by_id: customer_user.id,
|
updated_by_id: customer_user.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
@ -173,7 +173,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
# remember ticket
|
# remember ticket
|
||||||
tickets.push ticket3
|
tickets.push ticket3
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
@ -192,15 +192,15 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
updated_by_id: customer_user.id,
|
updated_by_id: customer_user.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# because it's already closed
|
# because it's already closed
|
||||||
assert(OnlineNotification.all_seen?('Ticket', ticket3.id))
|
assert(OnlineNotification.all_seen?('Ticket', ticket3.id))
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket3, agent_user1, 'update'))
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket3, agent_user1, 'update'))
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket3, agent_user2, 'update'))
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket3, agent_user2, 'update'))
|
||||||
assert(!OnlineNotification.exists?(agent_user1, 'Ticket', ticket3.id, 'update', customer_user, false))
|
assert(!OnlineNotification.exists?(agent_user1, 'Ticket', ticket3.id, 'update', customer_user, false))
|
||||||
assert(OnlineNotification.exists?(agent_user1, 'Ticket', ticket3.id, 'update', customer_user, true))
|
assert(OnlineNotification.exists?(agent_user1, 'Ticket', ticket3.id, 'update', customer_user, true))
|
||||||
assert(!OnlineNotification.exists?(agent_user2, 'Ticket', ticket3.id, 'update', customer_user, false))
|
assert(!OnlineNotification.exists?(agent_user2, 'Ticket', ticket3.id, 'update', customer_user, false))
|
||||||
|
@ -217,7 +217,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
internal: false
|
internal: false
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
@ -228,8 +228,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
assert(OnlineNotification.exists?(agent_user1, 'Ticket', ticket3.id, 'update', customer_user, true))
|
assert(OnlineNotification.exists?(agent_user1, 'Ticket', ticket3.id, 'update', customer_user, true))
|
||||||
assert(OnlineNotification.exists?(agent_user2, 'Ticket', ticket3.id, 'update', customer_user, false))
|
assert(OnlineNotification.exists?(agent_user2, 'Ticket', ticket3.id, 'update', customer_user, false))
|
||||||
assert(OnlineNotification.exists?(agent_user2, 'Ticket', ticket3.id, 'update', customer_user, true))
|
assert(OnlineNotification.exists?(agent_user2, 'Ticket', ticket3.id, 'update', customer_user, true))
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket3, agent_user1, 'update'))
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket3, agent_user1, 'update'))
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket3, agent_user2, 'update'))
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket3, agent_user2, 'update'))
|
||||||
|
|
||||||
# case #4
|
# case #4
|
||||||
ticket4 = Ticket.create(
|
ticket4 = Ticket.create(
|
||||||
|
@ -256,7 +256,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
# remember ticket
|
# remember ticket
|
||||||
tickets.push ticket4
|
tickets.push ticket4
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
@ -275,7 +275,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
updated_by_id: customer_user.id,
|
updated_by_id: customer_user.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
@ -312,7 +312,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
# remember ticket
|
# remember ticket
|
||||||
tickets.push ticket5
|
tickets.push ticket5
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
@ -331,7 +331,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
updated_by_id: customer_user.id,
|
updated_by_id: customer_user.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
|
@ -85,15 +85,15 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
assert(ticket1)
|
assert(ticket1)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Rails.configuration.webserver_is_active = nil
|
Rails.configuration.webserver_is_active = nil
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
||||||
|
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket1 = Ticket.create(
|
ticket1 = Ticket.create(
|
||||||
|
@ -120,15 +120,15 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
assert(ticket1)
|
assert(ticket1)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Rails.configuration.webserver_is_active = true
|
Rails.configuration.webserver_is_active = true
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'ticket notification - simple' do
|
test 'ticket notification - simple' do
|
||||||
|
@ -158,29 +158,29 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
assert( ticket1, 'ticket created - ticket notification simple' )
|
assert( ticket1, 'ticket created - ticket notification simple' )
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Rails.configuration.webserver_is_active = true
|
Rails.configuration.webserver_is_active = true
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
||||||
|
|
||||||
# update ticket attributes
|
# update ticket attributes
|
||||||
ticket1.title = "#{ticket1.title} - #2"
|
ticket1.title = "#{ticket1.title} - #2"
|
||||||
ticket1.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket1.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket1.save
|
ticket1.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
||||||
|
|
||||||
# add article to ticket
|
# add article to ticket
|
||||||
Ticket::Article.create(
|
Ticket::Article.create(
|
||||||
|
@ -195,14 +195,14 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: agent1.id,
|
created_by_id: agent1.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to not to agent1 but to agent2
|
# verify notifications to not to agent1 but to agent2
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
||||||
assert_equal(3, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
assert_equal(3, NotificationFactory::Mailer.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
||||||
|
|
||||||
# update ticket by user
|
# update ticket by user
|
||||||
ticket1.owner_id = agent1.id
|
ticket1.owner_id = agent1.id
|
||||||
|
@ -220,14 +220,14 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: agent1.id,
|
created_by_id: agent1.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to not to agent1 but to agent2
|
# verify notifications to not to agent1 but to agent2
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
||||||
assert_equal(3, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
assert_equal(3, NotificationFactory::Mailer.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
||||||
|
|
||||||
# create ticket with agent1 as owner
|
# create ticket with agent1 as owner
|
||||||
ticket2 = Ticket.create(
|
ticket2 = Ticket.create(
|
||||||
|
@ -254,15 +254,15 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: agent1.id,
|
created_by_id: agent1.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
assert(ticket2, 'ticket created')
|
assert(ticket2, 'ticket created')
|
||||||
|
|
||||||
# verify notifications to no one
|
# verify notifications to no one
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket2, agent1, 'email'), ticket2.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, agent1, 'email'), ticket2.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket2, agent2, 'email'), ticket2.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, agent2, 'email'), ticket2.id)
|
||||||
|
|
||||||
# update ticket
|
# update ticket
|
||||||
ticket2.title = "#{ticket2.title} - #2"
|
ticket2.title = "#{ticket2.title} - #2"
|
||||||
|
@ -270,14 +270,14 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
ticket2.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket2.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket2.save
|
ticket2.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to no one
|
# verify notifications to no one
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket2, agent1, 'email'), ticket2.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, agent1, 'email'), ticket2.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket2, agent2, 'email'), ticket2.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, agent2, 'email'), ticket2.id)
|
||||||
|
|
||||||
# update ticket
|
# update ticket
|
||||||
ticket2.title = "#{ticket2.title} - #3"
|
ticket2.title = "#{ticket2.title} - #3"
|
||||||
|
@ -285,14 +285,14 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
ticket2.priority = Ticket::Priority.lookup(name: '2 normal')
|
ticket2.priority = Ticket::Priority.lookup(name: '2 normal')
|
||||||
ticket2.save
|
ticket2.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 and not to agent2
|
# verify notifications to agent1 and not to agent2
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket2, agent1, 'email'), ticket2.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket2, agent1, 'email'), ticket2.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket2, agent2, 'email'), ticket2.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, agent2, 'email'), ticket2.id)
|
||||||
|
|
||||||
# create ticket with agent2 and agent1 as owner
|
# create ticket with agent2 and agent1 as owner
|
||||||
ticket3 = Ticket.create(
|
ticket3 = Ticket.create(
|
||||||
|
@ -319,15 +319,15 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: agent2.id,
|
created_by_id: agent2.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
assert(ticket3, 'ticket created')
|
assert(ticket3, 'ticket created')
|
||||||
|
|
||||||
# verify notifications to agent1 and not to agent2
|
# verify notifications to agent1 and not to agent2
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
||||||
|
|
||||||
# update ticket
|
# update ticket
|
||||||
ticket3.title = "#{ticket3.title} - #2"
|
ticket3.title = "#{ticket3.title} - #2"
|
||||||
|
@ -335,14 +335,14 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
ticket3.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket3.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket3.save
|
ticket3.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to no one
|
# verify notifications to no one
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
||||||
|
|
||||||
# update ticket
|
# update ticket
|
||||||
ticket3.title = "#{ticket3.title} - #3"
|
ticket3.title = "#{ticket3.title} - #3"
|
||||||
|
@ -350,27 +350,27 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
ticket3.priority = Ticket::Priority.lookup(name: '2 normal')
|
ticket3.priority = Ticket::Priority.lookup(name: '2 normal')
|
||||||
ticket3.save
|
ticket3.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 and not to agent2
|
# verify notifications to agent1 and not to agent2
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
||||||
|
|
||||||
# update article / not notification should be sent
|
# update article / not notification should be sent
|
||||||
article_inbound.internal = true
|
article_inbound.internal = true
|
||||||
article_inbound.save
|
article_inbound.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications not to agent1 and not to agent2
|
# verify notifications not to agent1 and not to agent2
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
||||||
|
|
||||||
delete = ticket1.destroy
|
delete = ticket1.destroy
|
||||||
assert(delete, 'ticket1 destroy')
|
assert(delete, 'ticket1 destroy')
|
||||||
|
@ -425,29 +425,29 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: customer.id,
|
created_by_id: customer.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Rails.configuration.webserver_is_active = false
|
Rails.configuration.webserver_is_active = false
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
||||||
|
|
||||||
# update ticket attributes
|
# update ticket attributes
|
||||||
ticket1.title = "#{ticket1.title} - #2"
|
ticket1.title = "#{ticket1.title} - #2"
|
||||||
ticket1.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket1.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket1.save
|
ticket1.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, agent1, 'email'), ticket1.id)
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket1, agent2, 'email'), ticket1.id)
|
||||||
|
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket2 = Ticket.create(
|
ticket2 = Ticket.create(
|
||||||
|
@ -474,28 +474,28 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: customer.id,
|
created_by_id: customer.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket2, agent1, 'email'), ticket2.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket2, agent1, 'email'), ticket2.id)
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket2, agent2, 'email'), ticket2.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket2, agent2, 'email'), ticket2.id)
|
||||||
|
|
||||||
# update ticket attributes
|
# update ticket attributes
|
||||||
ticket2.title = "#{ticket2.title} - #2"
|
ticket2.title = "#{ticket2.title} - #2"
|
||||||
ticket2.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket2.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket2.save
|
ticket2.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket2, agent1, 'email'), ticket2.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket2, agent1, 'email'), ticket2.id)
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket2, agent2, 'email'), ticket2.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket2, agent2, 'email'), ticket2.id)
|
||||||
|
|
||||||
# create ticket in group
|
# create ticket in group
|
||||||
ticket3 = Ticket.create(
|
ticket3 = Ticket.create(
|
||||||
|
@ -522,28 +522,28 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: customer.id,
|
created_by_id: customer.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
||||||
|
|
||||||
# update ticket attributes
|
# update ticket attributes
|
||||||
ticket3.title = "#{ticket3.title} - #2"
|
ticket3.title = "#{ticket3.title} - #2"
|
||||||
ticket3.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket3.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket3.save
|
ticket3.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, agent1, 'email'), ticket3.id)
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket3, agent2, 'email'), ticket3.id)
|
||||||
|
|
||||||
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
||||||
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
||||||
|
@ -587,29 +587,29 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: customer.id,
|
created_by_id: customer.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Rails.configuration.webserver_is_active = false
|
Rails.configuration.webserver_is_active = false
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket4, agent1, 'email'), ticket4.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket4, agent1, 'email'), ticket4.id)
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket4, agent2, 'email'), ticket4.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket4, agent2, 'email'), ticket4.id)
|
||||||
|
|
||||||
# update ticket attributes
|
# update ticket attributes
|
||||||
ticket4.title = "#{ticket4.title} - #2"
|
ticket4.title = "#{ticket4.title} - #2"
|
||||||
ticket4.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket4.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket4.save
|
ticket4.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket4, agent1, 'email'), ticket4.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket4, agent1, 'email'), ticket4.id)
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket4, agent2, 'email'), ticket4.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket4, agent2, 'email'), ticket4.id)
|
||||||
|
|
||||||
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
||||||
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
||||||
|
@ -653,29 +653,29 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: customer.id,
|
created_by_id: customer.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Rails.configuration.webserver_is_active = false
|
Rails.configuration.webserver_is_active = false
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket5, agent1, 'email'), ticket5.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket5, agent1, 'email'), ticket5.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket5, agent2, 'email'), ticket5.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket5, agent2, 'email'), ticket5.id)
|
||||||
|
|
||||||
# update ticket attributes
|
# update ticket attributes
|
||||||
ticket5.title = "#{ticket5.title} - #2"
|
ticket5.title = "#{ticket5.title} - #2"
|
||||||
ticket5.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket5.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket5.save
|
ticket5.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket5, agent1, 'email'), ticket5.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket5, agent1, 'email'), ticket5.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket5, agent2, 'email'), ticket5.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket5, agent2, 'email'), ticket5.id)
|
||||||
|
|
||||||
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
||||||
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
||||||
|
@ -720,33 +720,33 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: customer.id,
|
created_by_id: customer.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Rails.configuration.webserver_is_active = false
|
Rails.configuration.webserver_is_active = false
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket6, agent1, 'email'), ticket6.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket6, agent1, 'email'), ticket6.id)
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket6, agent1, 'online'), ticket6.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket6, agent1, 'online'), ticket6.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket6, agent2, 'email'), ticket6.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket6, agent2, 'email'), ticket6.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket6, agent2, 'online'), ticket6.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket6, agent2, 'online'), ticket6.id)
|
||||||
|
|
||||||
# update ticket attributes
|
# update ticket attributes
|
||||||
ticket6.title = "#{ticket6.title} - #2"
|
ticket6.title = "#{ticket6.title} - #2"
|
||||||
ticket6.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket6.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket6.save
|
ticket6.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket6, agent1, 'email'), ticket6.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket6, agent1, 'email'), ticket6.id)
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket6, agent1, 'online'), ticket6.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket6, agent1, 'online'), ticket6.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket6, agent2, 'email'), ticket6.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket6, agent2, 'email'), ticket6.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket6, agent2, 'online'), ticket6.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket6, agent2, 'online'), ticket6.id)
|
||||||
|
|
||||||
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
||||||
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
||||||
|
@ -799,33 +799,33 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: customer.id,
|
created_by_id: customer.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Rails.configuration.webserver_is_active = false
|
Rails.configuration.webserver_is_active = false
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket7, agent1, 'email'), ticket7.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, agent1, 'email'), ticket7.id)
|
||||||
assert_equal(1, NotificationFactory.already_sent?(ticket7, agent1, 'online'), ticket7.id)
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket7, agent1, 'online'), ticket7.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket7, agent2, 'email'), ticket7.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, agent2, 'email'), ticket7.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket7, agent2, 'online'), ticket7.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, agent2, 'online'), ticket7.id)
|
||||||
|
|
||||||
# update ticket attributes
|
# update ticket attributes
|
||||||
ticket7.title = "#{ticket7.title} - #2"
|
ticket7.title = "#{ticket7.title} - #2"
|
||||||
ticket7.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket7.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket7.save
|
ticket7.save
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
#puts Delayed::Job.all.inspect
|
#puts Delayed::Job.all.inspect
|
||||||
Delayed::Worker.new.work_off
|
Delayed::Worker.new.work_off
|
||||||
|
|
||||||
# verify notifications to agent1 + agent2
|
# verify notifications to agent1 + agent2
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket7, agent1, 'email'), ticket7.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, agent1, 'email'), ticket7.id)
|
||||||
assert_equal(2, NotificationFactory.already_sent?(ticket7, agent1, 'online'), ticket7.id)
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket7, agent1, 'online'), ticket7.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket7, agent2, 'email'), ticket7.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, agent2, 'email'), ticket7.id)
|
||||||
assert_equal(0, NotificationFactory.already_sent?(ticket7, agent2, 'online'), ticket7.id)
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, agent2, 'online'), ticket7.id)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -856,7 +856,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
assert(ticket1, 'ticket created')
|
assert(ticket1, 'ticket created')
|
||||||
|
|
||||||
# execute ticket events
|
# execute ticket transaction
|
||||||
Observer::Ticket::Notification.transaction
|
Observer::Ticket::Notification.transaction
|
||||||
|
|
||||||
# update ticket attributes
|
# update ticket attributes
|
||||||
|
@ -864,7 +864,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
ticket1.priority = Ticket::Priority.lookup(name: '3 high')
|
ticket1.priority = Ticket::Priority.lookup(name: '3 high')
|
||||||
ticket1.save
|
ticket1.save
|
||||||
|
|
||||||
list = EventBuffer.list
|
list = EventBuffer.list('notification')
|
||||||
list_objects = Observer::Ticket::Notification.get_uniq_changes(list)
|
list_objects = Observer::Ticket::Notification.get_uniq_changes(list)
|
||||||
|
|
||||||
assert_equal('some notification event test 1', list_objects[ticket1.id][:changes]['title'][0])
|
assert_equal('some notification event test 1', list_objects[ticket1.id][:changes]['title'][0])
|
||||||
|
@ -878,7 +878,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
ticket1.priority = Ticket::Priority.lookup(name: '1 low')
|
ticket1.priority = Ticket::Priority.lookup(name: '1 low')
|
||||||
ticket1.save
|
ticket1.save
|
||||||
|
|
||||||
list = EventBuffer.list
|
list = EventBuffer.list('notification')
|
||||||
list_objects = Observer::Ticket::Notification.get_uniq_changes(list)
|
list_objects = Observer::Ticket::Notification.get_uniq_changes(list)
|
||||||
|
|
||||||
assert_equal('some notification event test 1', list_objects[ticket1.id][:changes]['title'][0])
|
assert_equal('some notification event test 1', list_objects[ticket1.id][:changes]['title'][0])
|
||||||
|
@ -939,7 +939,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
assert_not( human_changes['pending_till'] )
|
assert_not( human_changes['pending_till'] )
|
||||||
|
|
||||||
# en notification
|
# en notification
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
locale: agent2.preferences[:locale],
|
locale: agent2.preferences[:locale],
|
||||||
template: 'ticket_update',
|
template: 'ticket_update',
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -971,7 +971,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
assert_not( human_changes['pending_till'] )
|
assert_not( human_changes['pending_till'] )
|
||||||
|
|
||||||
# de notification
|
# de notification
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
locale: agent1.preferences[:locale],
|
locale: agent1.preferences[:locale],
|
||||||
template: 'ticket_update',
|
template: 'ticket_update',
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -1015,7 +1015,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
assert_not(human_changes['pending_till'])
|
assert_not(human_changes['pending_till'])
|
||||||
|
|
||||||
# de notification
|
# de notification
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
locale: agent1.preferences[:locale],
|
locale: agent1.preferences[:locale],
|
||||||
template: 'ticket_update',
|
template: 'ticket_update',
|
||||||
objects: {
|
objects: {
|
||||||
|
@ -1040,7 +1040,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
human_changes = bg.human_changes(agent2, ticket1)
|
human_changes = bg.human_changes(agent2, ticket1)
|
||||||
|
|
||||||
# en notification
|
# en notification
|
||||||
result = NotificationFactory.template(
|
result = NotificationFactory::Mailer.template(
|
||||||
locale: agent2.preferences[:locale],
|
locale: agent2.preferences[:locale],
|
||||||
template: 'ticket_update',
|
template: 'ticket_update',
|
||||||
objects: {
|
objects: {
|
||||||
|
|
Loading…
Reference in a new issue