Sha256: 9e41b0f8b7b29a57161b440ebacf06fbcee620cabb691b6a64a7c2f2f112d315

Contents?: true

Size: 1.22 KB

Versions: 13

Compression:

Stored size: 1.22 KB

Contents

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

module ConditionTests
  class KeywordsTest < ActiveSupport::TestCase
    def test_sanitize
      condition = Searchlogic::Condition::Keywords.new(Account, :column => Account.columns_hash["name"])
      condition.value = "freedom yeah, freedom YEAH right"
      assert_equal ["\"accounts\".\"name\" LIKE ? AND \"accounts\".\"name\" LIKE ? AND \"accounts\".\"name\" LIKE ?", "%freedom%", "%yeah%", "%right%"], condition.sanitize
    
      condition = Searchlogic::Condition::Keywords.new(Account, :column => Account.columns_hash["name"])
      condition.value = "%^$*(^$)"
      assert_nil condition.sanitize
    
      condition = Searchlogic::Condition::Keywords.new(Account, :column => Account.columns_hash["name"])
      condition.value = "%^$*(^$) àáâãäåßéèêëìíîïñòóôõöùúûüýÿ"
      assert_equal ["\"accounts\".\"name\" LIKE ?", "%àáâãäåßéèêëìíîïñòóôõöùúûüýÿ%"], condition.sanitize
      
      condition = Searchlogic::Condition::Keywords.new(Account, :column => Account.columns_hash["name"])
      condition.value = "ben@ben.com"
      assert_equal ["\"accounts\".\"name\" LIKE ?", "%ben@ben.com%"], condition.sanitize
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

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