diff --git a/lib/datagrid/engine.rb b/lib/datagrid/engine.rb index 7e67b4d..cf5d1f2 100644 --- a/lib/datagrid/engine.rb +++ b/lib/datagrid/engine.rb @@ -5,11 +5,16 @@ module Datagrid # @!private class Engine < ::Rails::Engine + def self.extend_modules + ActionView::Base.send(:include, Datagrid::Helper) + ActionView::Helpers::FormBuilder.send(:include, Datagrid::FormBuilder) + end + initializer "datagrid.helpers" do ActiveSupport.on_load :action_view do - ActionView::Base.send(:include, Datagrid::Helper) - ActionView::Helpers::FormBuilder.send(:include, Datagrid::FormBuilder) + Engine.extend_modules end end + end end diff --git a/spec/datagrid/helper_spec.rb b/spec/datagrid/helper_spec.rb index 253acc6..1cd558c 100644 --- a/spec/datagrid/helper_spec.rb +++ b/spec/datagrid/helper_spec.rb @@ -662,7 +662,6 @@ def name end describe ".datagrid_header" do - it "should support order_by_value colums" do grid = test_report(order: "category") do scope { Entry } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d9f3da2..a555bb8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -109,8 +109,8 @@ def action_view_template File.expand_path("../../app/views", __FILE__), File.expand_path("../support/test_partials", __FILE__), ], {}) - klass = ActionView::Base.respond_to?(:with_empty_template_cache) ? ActionView::Base.with_empty_template_cache : ActionView::Base - template = klass.new(context, {}, ::ActionController::Base.new) + Datagrid::Engine.extend_modules + template = ActionView::Base.with_empty_template_cache.new(context, {}, ::ActionController::Base.new) allow(template).to receive(:protect_against_forgery?).and_return(false) template end