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