Sha256: a9c0c4fa0faf62b1804c89b879dd470660f89c3b784d156296a168ac1fe0f3d6

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

module Ransack
  module Nodes
    describe Condition do

      context 'with multiple values and an _any predicate' do
        subject {
          Condition.extract(
            Context.for(Person), 'name_eq_any', Person.first(2).map(&:name)
          )
        }

        specify { expect(subject.values.size).to eq(2) }
      end

      context 'with an invalid predicate' do
        subject {
          Condition.extract(
            Context.for(Person), 'name_invalid', Person.first.name
          )
        }

        context "when ignore_unknown_conditions is false" do
          before do
            Ransack.configure { |config| config.ignore_unknown_conditions = false }
          end

          specify { expect { subject }.to raise_error ArgumentError }
        end

        context "when ignore_unknown_conditions is true" do
          before do
            Ransack.configure { |config| config.ignore_unknown_conditions = true }
          end

          specify { subject.should be_nil }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ransack-1.5.1 spec/ransack/nodes/condition_spec.rb
ransack-1.5.0 spec/ransack/nodes/condition_spec.rb
ransack-1.4.1 spec/ransack/nodes/condition_spec.rb
ransack-1.4.0 spec/ransack/nodes/condition_spec.rb