app/services/change_manager/manager.rb in change_manager-0.0.2 vs app/services/change_manager/manager.rb in change_manager-0.0.3

- old
+ new

@@ -8,13 +8,13 @@ def self.notify(change_id) puts 'notify method called' unless Change.find(change_id).cancelled? change = Change.find(change_id) - similar_changes = group_similar_changes(change.owner, change.target) + verified_changes = cancel_all_changes(group_similar_changes(change.owner, change.target)) mailer = ChangeManager::NotificationMailer - puts 'email sent' if mailer.send_email(mailer.construct_email(similar_changes)) + puts 'email sent' if mailer.send_email(mailer.construct_email(verified_changes)) end end def self.group_similar_changes(owner, target) similar_changes = Change.where(owner: owner, target: target, cancelled: false) @@ -34,7 +34,15 @@ end end end return similar_changes end + + def self.cancel_all_changes(verified_changes) + verified_changes.each do |change| + change.cancel + end + verified_changes + end + end end