change_manager 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fd44f858a21ebcaebde6626363c013b5528853e
|
4
|
+
data.tar.gz: 49e0c7558d83ef0887740b830b1991a4dca0654a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d2a9c2987747c450a177c4b2b1fa323d250aefebfdcdbec54c1a66251003c4d6a3a56109010424d9c91d5ea3ac024f59fbced5f3328e3d6fc66253688b22d8b
|
7
|
+
data.tar.gz: 5024082c31b67fa5b6ad1d6e266ac3f73a3cdaa1a4b3dcfe2412875e4b03cbf56024d4601021e7e7ff3ac72a26e9112ba731002ccbf7d35f6bd64745b516a100
|
@@ -10,12 +10,16 @@ module ChangeManager
|
|
10
10
|
puts 'notify method called'
|
11
11
|
unless Change.find(change_id).cancelled?
|
12
12
|
change = Change.find(change_id)
|
13
|
-
verified_changes =
|
14
|
-
|
15
|
-
puts 'email sent' if mailer.send_email(mailer.construct_email(verified_changes))
|
13
|
+
verified_changes = process_changes(change)
|
14
|
+
notify_users(verified_changes) unless verified_changes.empty?
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
18
|
+
private
|
19
|
+
def self.process_changes(change)
|
20
|
+
cancel_all_changes(group_similar_changes(change.owner, change.target))
|
21
|
+
end
|
22
|
+
|
19
23
|
def self.group_similar_changes(owner, target)
|
20
24
|
similar_changes = Change.where(owner: owner, target: target, cancelled: false)
|
21
25
|
if similar_changes.length > 1
|
@@ -44,5 +48,10 @@ module ChangeManager
|
|
44
48
|
verified_changes
|
45
49
|
end
|
46
50
|
|
51
|
+
def self.notify_users(changes)
|
52
|
+
mailer = ChangeManager::NotificationMailer
|
53
|
+
mailer.send_email(mailer.construct_email(changes))
|
54
|
+
end
|
55
|
+
|
47
56
|
end
|
48
57
|
end
|