Sha256: 174b745c6f68917145ec3b0cb8c85d1b39ab2eda9eb410261c6332db94e4cfc0

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 KB

Contents

require File.dirname(__FILE__) + '/../test_helper.rb'

module ConditionsTests
  class AnyOrAllTest < ActiveSupport::TestCase
    def test_any
      conditions = Searchlogic::Cache::AccountConditions.new
      assert !conditions.any?
      conditions = Searchlogic::Cache::AccountConditions.new(:any => true)
      assert conditions.any?
      conditions.any = "false"
      assert !conditions.any?
      conditions = Searchlogic::Cache::AccountConditions.new
      conditions.name_contains = "Binary"
      assert_equal ["\"accounts\".\"name\" LIKE ?", "%Binary%"], conditions.sanitize
      conditions.id = 1
      assert_equal ["\"accounts\".\"name\" LIKE ? AND \"accounts\".\"id\" = ?", "%Binary%", 1], conditions.sanitize
      conditions.any = true
      assert_equal ["\"accounts\".\"name\" LIKE ? OR \"accounts\".\"id\" = ?", "%Binary%", 1], conditions.sanitize
      conditions.any = false
      assert_equal ["\"accounts\".\"name\" LIKE ? AND \"accounts\".\"id\" = ?", "%Binary%", 1], conditions.sanitize
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
schof-searchlogic-0.0.2 test/conditions_tests/any_or_all_test.rb
searchlogic-1.5.10 test/conditions_tests/any_or_all_test.rb
searchlogic-1.5.7 test/conditions_tests/any_or_all_test.rb
searchlogic-1.5.8 test/conditions_tests/any_or_all_test.rb
searchlogic-1.6.1 test/conditions_tests/any_or_all_test.rb
searchlogic-1.5.6 test/conditions_tests/any_or_all_test.rb
searchlogic-1.5.9 test/conditions_tests/any_or_all_test.rb
searchlogic-1.6.0 test/conditions_tests/any_or_all_test.rb
searchlogic-1.6.3 test/conditions_tests/any_or_all_test.rb
searchlogic-1.6.2 test/conditions_tests/any_or_all_test.rb
searchlogic-1.6.6 test/conditions_tests/any_or_all_test.rb
searchlogic-1.6.5 test/conditions_tests/any_or_all_test.rb
searchlogic-1.6.4 test/conditions_tests/any_or_all_test.rb