diff --git a/config/application.rb b/config/application.rb index 4cbd4c94af..603050a1ed 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,3 +1,4 @@ +require File.expand_path('../rails_bigdecimal_fix', __FILE__) require 'rails' require File.expand_path('../boot', __FILE__) diff --git a/config/boot.rb b/config/boot.rb index a9a3bfda34..dc15c7a2a9 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -9,6 +9,8 @@ GEMFILE_EXTENSIONS = [ msfenv_real_pathname = Pathname.new(__FILE__).realpath root = msfenv_real_pathname.parent.parent +require File.expand_path('../rails_bigdecimal_fix', __FILE__) + unless ENV['BUNDLE_GEMFILE'] require 'pathname' @@ -22,18 +24,6 @@ unless ENV['BUNDLE_GEMFILE'] end end -# Remove bigdecimal warning - start -# https://github.com/ruby/bigdecimal/pull/115 -# https://github.com/rapid7/metasploit-framework/pull/11184#issuecomment-461971266 -# TODO: remove when upgrading from rails 4.x -require 'bigdecimal' - -def BigDecimal.new(*args, **kwargs) - return BigDecimal(*args) if kwargs.empty? - BigDecimal(*args, **kwargs) -end -# Remove bigdecimal warning - end - begin require 'bundler/setup' rescue LoadError => e diff --git a/config/rails_bigdecimal_fix.rb b/config/rails_bigdecimal_fix.rb new file mode 100644 index 0000000000..fbe0465fd7 --- /dev/null +++ b/config/rails_bigdecimal_fix.rb @@ -0,0 +1,11 @@ +# Remove bigdecimal warning - start +# https://github.com/ruby/bigdecimal/pull/115 +# https://github.com/rapid7/metasploit-framework/pull/11184#issuecomment-461971266 +# TODO: remove when upgrading from rails 4.x +require 'bigdecimal' + +def BigDecimal.new(*args, **kwargs) + return BigDecimal(*args) if kwargs.empty? + BigDecimal(*args, **kwargs) +end +# Remove bigdecimal warning - end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a5b1cfc002..4558f6cd47 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,8 @@ require 'stringio' ENV['RAILS_ENV'] = 'test' +require File.expand_path('../../config/rails_bigdecimal_fix', __FILE__) + # @note must be before loading config/environment because railtie needs to be loaded before # `Metasploit::Framework::Application.initialize!` is called. #