Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Oct 9, 2024
1 parent 6ede4f4 commit 0b71433
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
9 changes: 7 additions & 2 deletions lib/datagrid/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

This comment has been minimized.

Copy link
@zhuravel

zhuravel Oct 9, 2024

Contributor

Module.include and Module.prepend are public since Ruby 2.1. Can be replaced with:

ActionView::Base.include(Datagrid::Helper)
ActionView::Helpers::FormBuilder.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
1 change: 0 additions & 1 deletion spec/datagrid/helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b71433

Please sign in to comment.