Sha256: b4f099a50827df5d8d9bd8ff840df0f4a062fdbe6f019b59865f873459ef8c89

Contents?: true

Size: 950 Bytes

Versions: 5

Compression:

Stored size: 950 Bytes

Contents

require 'spec_helper'

describe Tableficate::Filter::Input do
  before(:each) do
    template = mock('Template')
    template.stub!(:lookup_context).and_return(ActionView::LookupContext.new([]))
    @table = Tableficate::Table.new(template, NobelPrizeWinner.joins(:nobel_prizes).limit(1), {}, {})
    @table.column(:first_name)
  end

  it 'should look for a partial based on the input type and use it if found' do
    @table.template.lookup_context.stub(:exists?).and_return(true)

    Tableficate::Filter::Input.new(@table, :first_name, type: 'search').template.should == 'filters/input_search'
  end

  it 'should look for a partial based on the input type and use the default if it is not found' do
    @table.template.lookup_context.should_receive(:exists?) do |*args|
      (args.first == 'tableficate/filters/input')
    end

    Tableficate::Filter::Input.new(@table, :first_name, type: 'search').template.should == 'filters/input'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tableficate-0.3.2 spec/filters/input_spec.rb
tableficate-0.3.1 spec/filters/input_spec.rb
tableficate-0.3.0 spec/filters/input_spec.rb
tableficate-0.2.1 spec/filters/input_spec.rb
tableficate-0.2.0 spec/filters/input_spec.rb