Sha256: 9810486e15c5bf8e24fbfd3c71c246c4b5e5500a05c066657617bdeb708e8226

Contents?: true

Size: 979 Bytes

Versions: 1

Compression:

Stored size: 979 Bytes

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

1 entries across 1 versions & 1 rubygems

Version Path
ransack-1.3.0 spec/ransack/nodes/condition_spec.rb