Skip to content

Commit

Permalink
Fix regression bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Nov 14, 2024
1 parent d488792 commit a80b0bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/datagrid/filters/date_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def default_input_options
end

def apply(grid_object, scope, value)
if driver.timestamp_column?(scope, name)
if grid_object.driver.timestamp_column?(scope, name)
value = Datagrid::Utils.format_date_as_timestamp(value)
end
super
Expand Down
15 changes: 15 additions & 0 deletions spec/datagrid/filters/date_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,19 @@ def entry_dated(date)
expect(report.assets).to include(e4)
expect(report.assets).to_not include(e5)
end


it "allows filter to be defined before scope" do
class ParentGrid < Datagrid::Base
filter(:created_at, :date, range: true)
end

class ChildGrid < ParentGrid
scope do
Entry
end
end

expect(ChildGrid.new.assets).to eq([])
end
end

0 comments on commit a80b0bc

Please sign in to comment.