Sha256: 42a3ef2adb306a0c1283fce19d91e1b4a059727b923e456fb6660452b19c6a3e

Contents?: true

Size: 1.26 KB

Versions: 19

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe Datagrid::Filters::ExtendedBooleanFilter do

  it "should support select option" do
    grid = test_report do
      scope {Entry}
      filter(:disabled, :xboolean)
    end
    expect(grid.filter_by_name(:disabled).select(grid)).to eq([["Yes", "YES"], ["No", "NO"]])
  end

  it "should generate pass boolean value to filter block" do
    grid = test_report do
      scope {Entry}
      filter(:disabled, :xboolean)
    end

    disabled_entry = Entry.create!(:disabled => true)
    enabled_entry = Entry.create!(:disabled => false)

    expect(grid.disabled).to be_nil
    expect(grid.assets).to include(disabled_entry, enabled_entry)
    grid.disabled = "YES"

    expect(grid.disabled).to eq("YES")
    expect(grid.assets).to include(disabled_entry)
    expect(grid.assets).not_to include(enabled_entry)
    grid.disabled = "NO"
    expect(grid.disabled).to eq("NO")
    expect(grid.assets).to include(enabled_entry)
    expect(grid.assets).not_to include(disabled_entry)
  end

  it "should normalize true/false as YES/NO" do
    grid = test_report do
      scope {Entry}
      filter(:disabled, :xboolean)
    end
    grid.disabled = true
    expect(grid.disabled).to eq("YES")
    grid.disabled = false
    expect(grid.disabled).to eq("NO")
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
datagrid-1.6.1 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.6.0 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.5.9 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.5.8 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.5.7 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.5.6 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.5.5 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.5.4 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.5.3 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.5.2 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.5.1 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.5.0 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.4.4 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.4.3 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.4.2 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.4.1 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.4.0 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.3.9 spec/datagrid/filters/extended_boolean_filter_spec.rb
datagrid-1.3.7 spec/datagrid/filters/extended_boolean_filter_spec.rb