Sha256: 75a919edbbeb24ef1e26ae90e147028d85c182fc6ff2e911856b4382897a143f

Contents?: true

Size: 694 Bytes

Versions: 6

Compression:

Stored size: 694 Bytes

Contents

require '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

6 entries across 6 versions & 1 rubygems

Version Path
searchlogic-2.5.8 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.7 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.6 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.5 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.4 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.3 spec/searchlogic/named_scopes/alias_scope_spec.rb