Sha256: a9d80f445c3aa0f32837559dce01053271cd1f7110fd8545321114d8d45fac90

Contents?: true

Size: 702 Bytes

Versions: 2

Compression:

Stored size: 702 Bytes

Contents

require 'spec_helper'

describe Tabulatr::Data do
  it 'prefilters the result' do
    Tabulatr::Data.any_instance.stub_chain(:table_columns, :klass=).and_return(Product)
    Tabulatr::Data.any_instance.stub_chain(:table_columns, :map).as_null_object

    td = Tabulatr::Data.new(Product.where(price: 10))
    td.data_for_table(example_params)
    expect(td.instance_variable_get('@relation').to_sql).to match(/.+WHERE \"products\".\"price\" = 10.+/)
  end
end


private

def example_params
  {
    page: 1,
    pagesize: 20,
    arguments: 'title,price,active,vendor_product_name,updated_at,vendor:name,tags:title',
    table_id: 'product_table',
    product_search: nil,
    product_sort: nil
  }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tabulatr2-0.8.4 spec/lib/tabulatr/data/data_spec.rb
tabulatr2-0.8.3 spec/lib/tabulatr/data/data_spec.rb