Sha256: c99e50a330ee0707105cb8a176c9a700e33ac3801ee110db51a0c2e16accfc23

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

describe Datagrid::Filters::StringFilter do

  it "should support multiple values" do
    report = test_report(:name => "one,two") do
      scope {Entry}
      filter(:name, :string, :multiple => true)
    end
    expect(report.assets).to include(Entry.create!( :name => "one"))
    expect(report.assets).to include(Entry.create!( :name => "two"))
    expect(report.assets).not_to include(Entry.create!( :name => "three"))
  end
  it "should support custom separator multiple values" do
    report = test_report(:name => "one,1|two,2") do
      scope {Entry}
      filter(:name, :string, :multiple => '|')
    end
    expect(report.assets).to include(Entry.create!( :name => "one,1"))
    expect(report.assets).to include(Entry.create!( :name => "two,2"))
    expect(report.assets).not_to include(Entry.create!( :name => "one"))
    expect(report.assets).not_to include(Entry.create!( :name => "two"))
  end

  it "supports range" do
    report = test_report(:name => ['ab', 'lm']) do
      scope {Entry}
      filter(:name, :string, range: true)
    end
    expect(report.assets).to include(Entry.create!( :name => "ac"))
    expect(report.assets).to include(Entry.create!( :name => "kl"))
    expect(report.assets).not_to include(Entry.create!( :name => "aa"))
    expect(report.assets).not_to include(Entry.create!( :name => "mn"))
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
datagrid-1.6.1 spec/datagrid/filters/string_filter_spec.rb
datagrid-1.6.0 spec/datagrid/filters/string_filter_spec.rb
datagrid-1.5.9 spec/datagrid/filters/string_filter_spec.rb
datagrid-1.5.8 spec/datagrid/filters/string_filter_spec.rb
datagrid-1.5.7 spec/datagrid/filters/string_filter_spec.rb
datagrid-1.5.6 spec/datagrid/filters/string_filter_spec.rb