Sha256: 45ee46379aafab0411a29696b7893159e30ee7c83edd617396fb135327b41e74

Contents?: true

Size: 1.03 KB

Versions: 33

Compression:

Stored size: 1.03 KB

Contents

require 'rails_helper'

describe Tabulatr::Data::Formatting do
  class DummyFormattingClass
    include Tabulatr::Data::Formatting
    def table_columns; end
  end

  before(:each) do
    @dummy = DummyFormattingClass.new
    @dummy.instance_variable_set('@relation', Product.all)
    col_options = Tabulatr::ParamsBuilder.new(sort_sql: 'products.title', filter_sql: 'products.title')
    column = Tabulatr::Renderer::Column.from(
        name: :title,
        klass: Product,
        table_name: :products,
        col_options: col_options
    )
    allow(@dummy).to receive(:table_columns).and_return([column])
  end

  describe '#apply_formats' do
    it 'applies given formatting block to a column' do
      allow(@dummy).to receive(:format_row).and_return(nil)
      p = Product.create!(title: 'title of product')
      @dummy.table_columns.first.output = ->(record){record.title.upcase}
      result = @dummy.apply_formats
      expect(result.count).to be 1
      expect(result.first[:products][:title]).to eql 'TITLE OF PRODUCT'
    end
  end

end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
tabulatr2-0.10.4 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.10.3 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.10.2 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.10.1 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.10.0 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.48 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.47 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.46 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.45 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.44 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.43 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.42 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.41 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.40 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.39 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.38 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.37 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.36 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.35 spec/lib/tabulatr/data/formatting_spec.rb
tabulatr2-0.9.34 spec/lib/tabulatr/data/formatting_spec.rb