Sha256: 2235663cb4b265f9ba88ae4096226f5d0772e59b94486fd38503741948fe139e

Contents?: true

Size: 744 Bytes

Versions: 3

Compression:

Stored size: 744 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")

describe Searchlogic::NamedScopes::AliasScope do
  before(:each) do
    User.alias_scope :username_has, lambda { |value| User.username_like(value) }
  end
  
  it "should allow alias scopes" do
    User.create(:username => "bjohnson")
    User.create(:username => "thunt")
    User.username_has("bjohnson").all.should == User.find_all_by_username("bjohnson")
  end
  
  it "should allow alias scopes from the search object" do
    search = User.search
    search.username_has = "bjohnson"
    search.username_has.should == "bjohnson"
  end
  
  it "should inherit alias scopes from superclasses" do
    Class.new(User).condition?("username_has").should be_true
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
searchlogic-2.5.2 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.1 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.0 spec/searchlogic/named_scopes/alias_scope_spec.rb