Skip to content

Commit 7ce1685

Browse files
committed
Add BigDecimal.new compatibility shim for Ruby 2.7 with Rails 4.2
- Rails 4.2 uses deprecated BigDecimal.new API - Ruby 2.7 deprecated BigDecimal.new in favor of BigDecimal() kernel method - Add compatibility shim to restore BigDecimal.new for Ruby 2.6-2.7 - Only activates for Ruby < 3.0 to avoid affecting modern Ruby versions
1 parent bbc5e9a commit 7ce1685

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spec/spec_helper.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
add_filter '/spec/'
66
end
77

8+
# Fix BigDecimal.new deprecation for Ruby 2.6-2.7 with Rails < 5.0
9+
if RUBY_VERSION >= '2.6' && RUBY_VERSION < '3.0'
10+
require 'bigdecimal'
11+
unless BigDecimal.respond_to?(:new)
12+
def BigDecimal.new(*args, **kwargs)
13+
BigDecimal(*args, **kwargs)
14+
end
15+
end
16+
end
17+
818
require 'logger'
919
require 'active_record'
1020
require 'sql_query'

0 commit comments

Comments
 (0)