Sha256: 6c8e74797c68d8af934a57b99895bee0a8ee69216ad7f32721ffb3017bd2b7de

Contents?: true

Size: 1002 Bytes

Versions: 8

Compression:

Stored size: 1002 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

  column(:access_level, :html => lambda {|data| content_tag :h1, data})

  column(:pet, :html => lambda {|data| content_tag :em, data}) do
    self.pet.try(:upcase)
  end

  def param_name
    :report
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
datagrid-0.9.0 spec/support/simple_report.rb
datagrid-0.8.4 spec/support/simple_report.rb
datagrid-0.8.3 spec/support/simple_report.rb
datagrid-0.8.2 spec/support/simple_report.rb
datagrid-0.8.1 spec/support/simple_report.rb
datagrid-0.8.0 spec/support/simple_report.rb
datagrid-0.7.1 spec/support/simple_report.rb
datagrid-0.7.0 spec/support/simple_report.rb