Sha256: 708958549b1faff26bda99370903a5e42ec09cd96f1c26d91f56816d2d6e6e24

Contents?: true

Size: 1003 Bytes

Versions: 4

Compression:

Stored size: 1003 Bytes

Contents

require File.expand_path("../test_helper", __FILE__)

class ScopeTest < SearchCop::TestCase
  def test_user_search
    expected = create(:product, :title => "Expected")
    rejected = create(:product, :notice => "Expected")

    results = Product.user_search("Expected")

    assert_includes results, expected
    refute_includes results, rejected
  end

  def test_options
    expected = create(:product, :title => "Expected")
    rejected = create(:product, :description => "Expected")

    results = Product.user_search("Expected")

    assert_includes results, expected
    refute_includes results, rejected
  end

  def test_aliases
    expected = create(:product, :comments => [create(:comment, :user => create(:user, :username => "Expected"))])
    rejected = create(:product, :comments => [create(:comment, :user => create(:user, :username => "Rejected"))])

    results = Product.search("user: Expected")

    assert_includes results, expected
    refute_includes results, rejected
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
search_cop-1.0.3 test/scope_test.rb
search_cop-1.0.2 test/scope_test.rb
search_cop-1.0.1 test/scope_test.rb
search_cop-1.0.0 test/scope_test.rb