Sha256: 25f363d2885fa0739a68dca935f08deb8bfaf30e31d67a96630020fd4cdb4c32

Contents?: true

Size: 830 Bytes

Versions: 9

Compression:

Stored size: 830 Bytes

Contents


def test_report(attributes = {}, &block)
  klass = Class.new
  klass.class_eval do
    include Datagrid
  end
  if block
    klass.class_eval(&block)
  end
  klass.new(attributes)
end

class SimpleReport

  include Datagrid

  scope do
    ::Entry.includes(:group).order("entries.created_at")
  end

  filter(:group_id, :integer, :multiple => true)
  filter(:category, :enum, :select => ["first", "second"])
  filter(:disabled, :eboolean)
  filter(:confirmed, :boolean)

  filter(:name) do |value|
    self.scoped(:conditions => {:name => value})
  end

  column(:group, :order => "groups.name") do
    self.group.name
  end

  column(:name) do |user|
    user.name
  end

  column(:actions, :html => true) do |model|
    render :partial => "actions", :locals => {:model => model}
  end

  def param_name
    :report
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
datagrid-0.6.4 spec/support/simple_report.rb
datagrid-0.6.3 spec/support/simple_report.rb
datagrid-0.6.2 spec/support/simple_report.rb
datagrid-0.6.0 spec/support/simple_report.rb
datagrid-0.5.4 spec/support/simple_report.rb
datagrid-0.5.3 spec/support/simple_report.rb
datagrid-0.5.2 spec/support/simple_report.rb
datagrid-0.5.1 spec/support/simple_report.rb
datagrid-0.5.0 spec/support/simple_report.rb