Permalink
Browse files

Fixed a crash where GroupRule recalculations assumed a Person object …

…in some cases
  • Loading branch information...
1 parent dbc55de commit a69b064ee09c3664278289091cf72e7abb2b4f0d @cthielen cthielen committed Feb 26, 2014
Showing with 14 additions and 10 deletions.
  1. +13 −9 app/models/group_rule.rb
  2. +1 −1 config/initializers/last_updated.rb
View
@@ -91,16 +91,20 @@ def GroupRule.resolve_target!(column, entity_id)
end
end
when :ou
- entity.groups.ous.each do |ou|
- GroupRule.where(:column => "ou").each do |rule|
- if rule.condition == "is"
- if rule.value == ou.name
- logger.info "Matched 'ou is' rule. Recording result."
- rule.results << GroupRuleResult.new(:entity_id => entity_id)
- touched_group_ids << rule.group.id
+ if entity.type == 'Group'
+ logger.warn "Targetted entity for 'Department is' rule is a group #{entity.log_identifier}. Skipping ..."
+ else
+ entity.groups.ous.each do |ou|
+ GroupRule.where(:column => "ou").each do |rule|
+ if rule.condition == "is"
+ if rule.value == ou.name
+ logger.info "Matched 'ou is' rule. Recording result."
+ rule.results << GroupRuleResult.new(:entity_id => entity_id)
+ touched_group_ids << rule.group.id
+ end
+ elsif rule.condition == "is not"
+ logger.warn "Cannot GroupRule.resolve_target! for 'ou is not'. Unimplemented behavior."
end
- elsif rule.condition == "is not"
- logger.warn "Cannot GroupRule.resolve_target! for 'ou is not'. Unimplemented behavior."
end
end
end
@@ -1 +1 @@
-LAST_UPDATED = 'Tue Feb 25 14:55:09 PST 2014'
+LAST_UPDATED = 'Tue Feb 25 16:36:25 PST 2014'

0 comments on commit a69b064

Please sign in to comment.