Sha256: eb00b49e6eef12ce4b39d6c9d0d62490c8637d632fcbbc7fcbb101b09c2579b0

Contents?: true

Size: 951 Bytes

Versions: 12

Compression:

Stored size: 951 Bytes

Contents

# frozen_string_literal: true
require 'test_helper'

module Eac
  class DataTableTestHelper < ActionView::TestCase
    include ::Eac::DataTableHelper

    class Person
      attr_reader :name, :age, :job

      def initialize(name, age, job)
        @name = name
        @age = age
        @job = job
      end
    end

    class Job
      attr_reader :name, :id

      def initialize(name)
        @name = name
        @id = SecureRandom.random_number(100_000)
      end
    end

    def test_data_table
      ds = []
      ds << Person.new('Fulano', 15, Job.new('Padeiro'))
      ds << Person.new('Sicrano', 25, nil)

      data_table(ds) do |s|
        s.paging = false
        s.column('Name', 'name')
        s.column('Age', 'age')
        s.column('Name + Age') { |v| "#{v.name} + #{v.age}" }
        s.column('Job', 'job')
        s.column('Job ID', 'job.id')
        s.column('Job ID + 10', 'job.id') { |_v| + 10 }
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
eac_rails_utils-0.8.0 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.7.1 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.7.0 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.6.0 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.5.0 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.4.0 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.3.0 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.2.2 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.2.1 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.2.0 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.1.15 test/lib/eac/data_table_test_helper.rb
eac_rails_utils-0.1.14 test/lib/eac/data_table_test_helper.rb