bogdan / datagrid

Gem to create tables grids with sortable columns and filters
MIT License
1.02k stars 115 forks source link

Upgrade to 1.6.2 broke column_names_filter #296

Closed greenfork closed 3 years ago

greenfork commented 3 years ago
Error:
PositionsControllerTest#test_should_get_index:
ArgumentError: wrong number of arguments (given 3, expected 1..2)
    app/grids/positions_grid.rb:135:in `<class:PositionsGrid>'
    app/grids/positions_grid.rb:3:in `<top (required)>'
    app/controllers/positions_controller.rb:23:in `index'
    app/controllers/authorized_controller.rb:50:in `handle_api_error'
    app/controllers/authorized_controller.rb:120:in `set_time_zone'
    app/controllers/authorized_controller.rb:33:in `set_tokens'
    test/controllers/positions_controller_test.rb:8:in `block in <class:PositionsControllerTest>'
    test/test_helper.rb:57:in `block (4 levels) in run'
    test/test_helper.rb:56:in `block (3 levels) in run'
    test/test_helper.rb:55:in `block (2 levels) in run'
    test/test_helper.rb:54:in `block in run'
    test/test_helper.rb:53:in `run'

with this line

  column_names_filter(
    header: "Columns",
    default: %i[city search_location pay manager recruiter team links stats priority]
  )
bogdan commented 3 years ago

Can you show full backtrace for the issue?

greenfork commented 3 years ago

This is full backtrace unfortunately. I think the reason is double splat change https://github.com/bogdan/datagrid/commit/5a2ff92453758745f2793cbee34326c7eed11fda#diff-e862b050fb30334bd970ac6714786a6120a21c965b4a95f3f57b3f4792adafaeL124-R125

Reproducible example

require "datagrid"

class UsersGrid

  include Datagrid

  scope do
    [1,2,3]
  end

  column_names_filter(header: "Header")

  column(:name) { |val| val }
end
grfork@pisec /tmp> ruby datagrid.rb
/home/grfork/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/datagrid-1.6.2/lib/datagrid/filters.rb:97:in `filter': wrong number of arguments (given 3, expected 1..2) (ArgumentError)
    from /home/grfork/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/datagrid-1.6.2/lib/datagrid/column_names_attribute.rb:30:in `column_names_filter'
    from datagrid.rb:11:in `<class:UsersGrid>'
    from datagrid.rb:3:in `<main>'
bogdan commented 3 years ago

Try version 1.6.3.

greenfork commented 3 years ago

Yep, all works fine, thank you.