Skip to content

Commit c742aab

Browse files
committed
Fix exception on not recognized shortcut
1 parent 2585ad7 commit c742aab

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/calculate-all.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def decode_expression_shortcut(shortcut, group_values = [])
9797
when /^(\w+)_minimum$/, /^minimum_(\w+)$/
9898
"MIN(#{$1})"
9999
else
100-
raise ArgumentError, "Can't recognize expression shortcut #{key}"
100+
raise ArgumentError, "Can't recognize expression shortcut #{shortcut}"
101101
end
102102
end
103103
end

test/calculate_all_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ def test_no_args
9090
end
9191
end
9292

93+
def test_unknown_shortcut
94+
assert_raises ArgumentError do
95+
Order.all.calculate_all(:foo)
96+
end
97+
end
98+
9399
def test_model_and_no_data
94100
assert_nil(Order.calculate_all("sum(cents)"))
95101
end

0 commit comments

Comments
 (0)