Sha256: 801456a0776c7471a3c57ff26ea318a80653302a0a4aa261c4a3cfc472e14562

Contents?: true

Size: 976 Bytes

Versions: 12

Compression:

Stored size: 976 Bytes

Contents

# frozen_string_literal: true

require 'test_helper'

module EacRailsUtils
  class DataTableTestHelperTest < ActionView::TestCase
    include ::EacRailsUtils::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.13.0 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.12.3 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.12.2 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.12.1 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.12.0 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.11.6 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.11.5 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.11.4 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.11.3 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.11.2 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.11.1 test/helpers/eac_rails_utils/data_table_test_helper_test.rb
eac_rails_utils-0.11.0 test/helpers/eac_rails_utils/data_table_test_helper_test.rb