Do not touch ticket on user or organization change.
This commit is contained in:
parent
258130d824
commit
679b90aaec
3 changed files with 2 additions and 31 deletions
|
@ -18,11 +18,6 @@ class Observer::User::RefObjectTouch < ActiveRecord::Observer
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
||||||
# touch customers tickets
|
|
||||||
Ticket.select('id').where( :customer_id => record.id ).each {|ticket|
|
|
||||||
ticket.touch
|
|
||||||
}
|
|
||||||
|
|
||||||
# touch old organization if changed
|
# touch old organization if changed
|
||||||
member_ids = []
|
member_ids = []
|
||||||
organization_id_changed = record.changes['organization_id']
|
organization_id_changed = record.changes['organization_id']
|
||||||
|
@ -31,11 +26,6 @@ class Observer::User::RefObjectTouch < ActiveRecord::Observer
|
||||||
organization = Organization.find( organization_id_changed[0] )
|
organization = Organization.find( organization_id_changed[0] )
|
||||||
organization.touch
|
organization.touch
|
||||||
member_ids = organization.member_ids
|
member_ids = organization.member_ids
|
||||||
|
|
||||||
# touch customers tickets
|
|
||||||
Ticket.select('id').where( :organization_id => organization.id ).each {|ticket|
|
|
||||||
ticket.touch
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,11 +33,6 @@ class Observer::User::RefObjectTouch < ActiveRecord::Observer
|
||||||
if record.organization
|
if record.organization
|
||||||
record.organization.touch
|
record.organization.touch
|
||||||
member_ids += record.organization.member_ids
|
member_ids += record.organization.member_ids
|
||||||
|
|
||||||
# touch customers tickets
|
|
||||||
Ticket.select('id').where( :organization_id => record.organization_id ).each {|ticket|
|
|
||||||
ticket.touch
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# touch old/current customer
|
# touch old/current customer
|
||||||
|
|
|
@ -100,7 +100,7 @@ class OrganizationRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
customer2.organization_id = organization1.id
|
customer2.organization_id = organization1.id
|
||||||
customer2.save
|
customer2.save
|
||||||
|
|
||||||
# check if customer1, ticket and organization has been touched
|
# check if customer1 and organization has been touched
|
||||||
customer1 = User.find(customer1.id)
|
customer1 = User.find(customer1.id)
|
||||||
if customer1.updated_at > 2.second.ago
|
if customer1.updated_at > 2.second.ago
|
||||||
assert( true, "customer1.updated_at has been updated" )
|
assert( true, "customer1.updated_at has been updated" )
|
||||||
|
@ -108,13 +108,6 @@ class OrganizationRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
assert( false, "customer1.updated_at has not been updated" )
|
assert( false, "customer1.updated_at has not been updated" )
|
||||||
end
|
end
|
||||||
|
|
||||||
ticket = Ticket.find(ticket.id)
|
|
||||||
if ticket.updated_at > 2.second.ago
|
|
||||||
assert( true, "ticket.updated_at has been updated" )
|
|
||||||
else
|
|
||||||
assert( false, "ticket.updated_at has not been updated" )
|
|
||||||
end
|
|
||||||
|
|
||||||
organization1 = Organization.find(organization1.id)
|
organization1 = Organization.find(organization1.id)
|
||||||
if organization1.updated_at > 2.second.ago
|
if organization1.updated_at > 2.second.ago
|
||||||
assert( true, "organization1.updated_at has been updated" )
|
assert( true, "organization1.updated_at has been updated" )
|
||||||
|
|
|
@ -74,14 +74,7 @@ class UserRefObjectTouchTest < ActiveSupport::TestCase
|
||||||
customer1.firstname = 'firstname customer1'
|
customer1.firstname = 'firstname customer1'
|
||||||
customer1.save
|
customer1.save
|
||||||
|
|
||||||
# check if ticket and organization has been touched
|
# check if organization has been touched
|
||||||
ticket = Ticket.find(ticket.id)
|
|
||||||
if ticket.updated_at > 2.second.ago
|
|
||||||
assert( true, "ticket.updated_at has been updated" )
|
|
||||||
else
|
|
||||||
assert( false, "ticket.updated_at has not been updated" )
|
|
||||||
end
|
|
||||||
|
|
||||||
organization1 = Organization.find(organization1.id)
|
organization1 = Organization.find(organization1.id)
|
||||||
if organization1.updated_at > 2.second.ago
|
if organization1.updated_at > 2.second.ago
|
||||||
assert( true, "organization1.updated_at has been updated" )
|
assert( true, "organization1.updated_at has been updated" )
|
||||||
|
|
Loading…
Reference in a new issue