Sha256: ea2e530c5d6f548b3828a2abdb5bf6cd9abe9497252fd30b6f411f9c6de8c7a6

Contents?: true

Size: 1007 Bytes

Versions: 2

Compression:

Stored size: 1007 Bytes

Contents

require 'spec_helper'

describe 'Tableficate::ActiveRecordExtention' do
  it 'should add and retreive data from the scope' do
    scope = NobelPrizeWinner.tableficate_ext
    scope.tableficate_data = {}
    scope.tableficate_data[:name] = 'Aaron'
    scope.tableficate_data.should == {name: 'Aaron'}
  end

  it 'maintains functionality if converted to an array' do
    scope = NobelPrizeWinner.tableficate_ext.to_a
    scope.tableficate_data = {}
    scope.tableficate_data[:name] = 'Aaron'
    scope.tableficate_data.should == {name: 'Aaron'}

    class NobelPrizeWinnerWithDefaultSorting < Tableficate::Base
      scope :nobel_prize_winner

      default_sort(:first_name)
    end
    scope = NobelPrizeWinnerWithDefaultSorting.tableficate({}).all
    scope.tableficate_data[:current_sort].should == {column: :first_name, dir: 'asc'}

    scope = NobelPrizeWinnerWithDefaultSorting.tableficate({}).find(1,2)
    scope.tableficate_data[:current_sort].should == {column: :first_name, dir: 'asc'}
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tableficate-0.3.2 spec/active_record_extension_spec.rb
tableficate-0.3.1 spec/active_record_extension_spec.rb