Commit 4b4ea91d885318d8991148344ec288a664a7747c
1 parent
1581240e
Exists in
master
and in
1 other branch
Fix badge rules grant initializer
Showing
1 changed file
with
3 additions
and
2 deletions
Show diff stats
lib/merit/badge_rules.rb
| ... | ... | @@ -145,7 +145,7 @@ module Merit |
| 145 | 145 | grant_on setting[:action], badge: badge.name, level: badge.level, to: setting[:to] do |source| |
| 146 | 146 | can_be_granted = true |
| 147 | 147 | rules[badge.name.to_sym].each do |s| |
| 148 | - if s[:to].is_a? Symbol | |
| 148 | + if setting[:to].is_a? Symbol | |
| 149 | 149 | to = source.send(setting[:to]) |
| 150 | 150 | else |
| 151 | 151 | begin |
| ... | ... | @@ -155,7 +155,8 @@ module Merit |
| 155 | 155 | end |
| 156 | 156 | end |
| 157 | 157 | # pass source and to for different situations |
| 158 | - can_be_granted &= s[:value].call(source, to) >= (badge.custom_fields || {}).fetch(:threshold, s[:default_threshold]).to_i | |
| 158 | + action = (badge.custom_fields || {}).fetch(s[:action], {}) | |
| 159 | + can_be_granted &= s[:value].call(source, to) >= action.fetch(:threshold, s[:default_threshold]).to_i | |
| 159 | 160 | end |
| 160 | 161 | can_be_granted |
| 161 | 162 | end | ... | ... |