Sha256: 83aec9285299254f1be62b6bc0da45bce018d7756125b54f5c583696cad3cc47

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

require 'pry'

describe DataTables::Modules::Order do

  before(:each) do
    # Make everything public :P
    DataTables::Modules::Order.send(:public, *DataTables::Modules::Order.protected_instance_methods)
  end

  let!(:complex_params) do
    HashWithIndifferentAccess.new({
      "columns": [
        {
          "data": "id",
          "name": "",
          "orderable": true,
          "search": { "regex": false, "value": "" },
          "searchable": true
        },
        {
          "data": "post.user.email",
          "name": "",
          "orderable": true,
          "search": { "regex": false, "value": "foo@bar.baz" },
          "searchable": true
        },
        {
          "data": nil,
          "name": "",
          "orderable": false,
          "search": { "regex": false, "value": "" },
          "searchable": true
        }
      ],
      "draw": 3,
      "length": 10,
      "order": [
        { "column": 1, "dir": "asc" }
      ],
      "sRangeSeparator": "~",
      "search": { "regex": false, "value": "" },
      "start": 0
    })
  end

  xit 'handles multi nested requests' do

  end

  it 'transmutes datatable order' do

    order = DataTables::Modules::Order.new(Post, Post.all, complex_params)

    transmuted = order.orderable_columns(complex_params[:order], complex_params[:columns])

    expect(transmuted).to eq({"post.user.email"=>"asc"})
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
data_tables-responder-0.4.4rc1 spec/data_tables/order_spec.rb
data_tables-responder-0.4.3 spec/data_tables/order_spec.rb
data_tables-responder-0.5.0rc1 spec/data_tables/order_spec.rb