From 7810ead783c3058659fd5fe0867b85d62313f1ec Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 1 Feb 2015 13:08:11 +0100 Subject: [PATCH] Fixed ticket reload on server change. Moved to extra notify_clients_support method on models. --- app/models/application_model.rb | 18 ++++++++++++ app/models/job.rb | 10 +++---- app/models/organization.rb | 4 +-- app/models/template.rb | 6 ++-- app/models/text_module.rb | 6 ++-- app/models/ticket.rb | 5 ++-- app/models/ticket/article.rb | 4 +-- app/models/user.rb | 7 +++-- .../agent_ticket_actions_level1_test.rb | 28 +++++++++---------- 9 files changed, 48 insertions(+), 40 deletions(-) diff --git a/app/models/application_model.rb b/app/models/application_model.rb index d91a1b81a..f9e864009 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -14,6 +14,7 @@ class ApplicationModel < ActiveRecord::Base after_create :cache_delete after_update :cache_delete + after_touch :cache_delete after_destroy :cache_delete after_create :attachments_buffer_check @@ -418,6 +419,23 @@ returns =begin +activate client notify support on create, update, touch and destroy + +class Model < ApplicationModel + notify_clients_support +end + +=end + + def self.notify_clients_support + after_create :notify_clients_after_create + after_update :notify_clients_after_update + after_touch :notify_clients_after_update + after_destroy :notify_clients_after_destroy + end + +=begin + notify_clients_after_create after model got created used as callback in model file diff --git a/app/models/job.rb b/app/models/job.rb index 54d332317..30d473337 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -9,9 +9,7 @@ class Job < ApplicationModel before_create :updated_matching before_update :updated_matching - after_create :notify_clients_after_create - after_update :notify_clients_after_update - after_destroy :notify_clients_after_destroy + notify_clients_support def self.run time = Time.new @@ -27,12 +25,12 @@ class Job < ApplicationModel jobs = Job.where( :active => true ) jobs.each do |job| - # only execute jobs, older then 2 min, to give admin posibility to change - next if job.updated_at > Time.now - 2.minutes + # only execute jobs, older then 1 min, to give admin posibility to change + next if job.updated_at > Time.now - 1.minutes # check if jobs need to be executed # ignore if job was running within last 10 min. - next if job.last_run_at > Time.now - 10.minutes + next if job.last_run_at && job.last_run_at > Time.now - 10.minutes # check day next if !job.timeplan['days'].include?( day_map[time.wday] ) diff --git a/app/models/organization.rb b/app/models/organization.rb index 43890885b..a0d791fc4 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -11,11 +11,9 @@ class Organization < ApplicationModel has_many :members, :class_name => 'User' validates :name, :presence => true - after_create :notify_clients_after_create - after_update :notify_clients_after_update - activity_stream_support :role => 'Admin' history_support search_index_support + notify_clients_support end \ No newline at end of file diff --git a/app/models/template.rb b/app/models/template.rb index 001cdbcf4..0626f1c9c 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -3,7 +3,5 @@ class Template < ApplicationModel store :options validates :name, :presence => true - after_create :notify_clients_after_create - after_update :notify_clients_after_update - after_destroy :notify_clients_after_destroy -end + notify_clients_support +end \ No newline at end of file diff --git a/app/models/text_module.rb b/app/models/text_module.rb index 8f019b879..6e1df9944 100644 --- a/app/models/text_module.rb +++ b/app/models/text_module.rb @@ -3,7 +3,5 @@ class TextModule < ApplicationModel validates :name, :presence => true validates :content, :presence => true - after_create :notify_clients_after_create - after_update :notify_clients_after_update - after_destroy :notify_clients_after_destroy -end + notify_clients_support +end \ No newline at end of file diff --git a/app/models/ticket.rb b/app/models/ticket.rb index edba396ba..a0545c609 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -17,9 +17,8 @@ class Ticket < ApplicationModel before_create :check_generate, :check_defaults, :check_title before_update :check_defaults, :check_title before_destroy :destroy_dependencies - after_create :notify_clients_after_create - after_update :notify_clients_after_update - after_destroy :notify_clients_after_destroy + + notify_clients_support activity_stream_support :ignore_attributes => { :create_article_type_id => true, diff --git a/app/models/ticket/article.rb b/app/models/ticket/article.rb index f2e2c2050..91a1720fb 100644 --- a/app/models/ticket/article.rb +++ b/app/models/ticket/article.rb @@ -15,9 +15,7 @@ class Ticket::Article < ApplicationModel belongs_to :updated_by, :class_name => 'User' before_create :check_subject before_update :check_subject - after_create :notify_clients_after_create - after_update :notify_clients_after_update - after_destroy :notify_clients_after_destroy + notify_clients_support activity_stream_support :ignore_attributes => { :type_id => true, diff --git a/app/models/user.rb b/app/models/user.rb index 7f0b09320..adfe3e7ff 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -32,9 +32,10 @@ class User < ApplicationModel before_create :check_name, :check_email, :check_login, :check_password before_update :check_password, :check_email, :check_login - after_create :avatar_check, :notify_clients_after_create - after_update :avatar_check, :notify_clients_after_update - after_destroy :avatar_destroy, :notify_clients_after_destroy + after_create :avatar_check + after_update :avatar_check + after_destroy :avatar_destroy + notify_clients_support has_and_belongs_to_many :groups, :after_add => :cache_update, :after_remove => :cache_update has_and_belongs_to_many :roles, :after_add => :cache_update, :after_remove => :cache_update diff --git a/test/browser/agent_ticket_actions_level1_test.rb b/test/browser/agent_ticket_actions_level1_test.rb index 205c551d0..3832a9be9 100644 --- a/test/browser/agent_ticket_actions_level1_test.rb +++ b/test/browser/agent_ticket_actions_level1_test.rb @@ -16,14 +16,14 @@ class AgentTicketActionLevel1Test < TestCase :execute => 'create_ticket', :group => 'Users', :subject => 'some subject 123äöü', - :body => 'some body 123äöü', + :body => 'some body 123äöü - with closed tab', }, # check ticket { :execute => 'match', :css => '.content.active .ticket-article', - :value => 'some body 123äöü', + :value => 'some body 123äöü - with closed tab', :match_result => true, }, @@ -44,7 +44,7 @@ class AgentTicketActionLevel1Test < TestCase #}, { :execute => 'set_ticket_attributes', - :body => 'some body 1234 äöüß', + :body => 'some body 1234 äöüß - with closed tab', }, { :execute => 'click', @@ -57,7 +57,7 @@ class AgentTicketActionLevel1Test < TestCase { :execute => 'watch_for', :area => '.content.active .ticket-article', - :value => 'some body 1234 äöüß', + :value => 'some body 1234 äöüß - with closed tab', }, { :execute => 'close_all_tasks', @@ -74,14 +74,14 @@ class AgentTicketActionLevel1Test < TestCase :execute => 'create_ticket', :group => 'Users', :subject => 'test to merge', - :body => 'some body 123äöü 222 - test to merge', + :body => 'some body 123äöü 222 - test to merge - with closed tab', }, # check ticket { :execute => 'watch_for', :area => '.content.active .ticket-article', - :value => 'some body 123äöü 222 - test to merge', + :value => 'some body 123äöü 222 - test to merge - with closed tab', }, # update ticket @@ -92,7 +92,7 @@ class AgentTicketActionLevel1Test < TestCase #}, { :execute => 'set_ticket_attributes', - :body => 'some body 1234 äöüß 333', + :body => 'some body 1234 äöüß 333 - with closed tab', }, { :execute => 'click', @@ -105,7 +105,7 @@ class AgentTicketActionLevel1Test < TestCase { :execute => 'watch_for', :area => '.content.active .ticket-article', - :value => 'some body 1234 äöüß 333', + :value => 'some body 1234 äöüß 333 - with closed tab', }, # check if task is shown @@ -158,7 +158,7 @@ class AgentTicketActionLevel1Test < TestCase { :execute => 'match', :css => 'body', - :value => 'test to merge', + :value => 'test to merge - with closed tab', :match_result => true, }, @@ -186,14 +186,14 @@ class AgentTicketActionLevel1Test < TestCase :execute => 'create_ticket', :group => 'Users', :subject => 'some subject 123äöü', - :body => 'some body 123äöü', + :body => 'some body 123äöü - with open tab', }, # check ticket { :execute => 'match', :css => '.content.active .ticket-article', - :value => 'some body 123äöü', + :value => 'some body 123äöü - with open tab', :match_result => true, }, @@ -218,14 +218,14 @@ class AgentTicketActionLevel1Test < TestCase :execute => 'create_ticket', :group => 'Users', :subject => 'test to merge', - :body => 'some body 123äöü 222 - test to merge', + :body => 'some body 123äöü 222 - test to merge - with open tab', }, # check ticket { :execute => 'watch_for', :area => '.content.active .ticket-article', - :value => 'some body 123äöü 222 - test to merge', + :value => 'some body 123äöü 222 - test to merge - with open tab', }, # check if task is shown @@ -278,7 +278,7 @@ class AgentTicketActionLevel1Test < TestCase { :execute => 'match', :css => 'body', - :value => 'test to merge', + :value => 'test to merge - with open tab', :match_result => true, },