Sha256: d0788fdbe6e74e6f480b526b10c090d8daaa005bca42f736439e9f46c05abe87

Contents?: true

Size: 961 Bytes

Versions: 11

Compression:

Stored size: 961 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 with symbols" do
    User.alias_scope :login_has, :username_has
    User.create(:username => "bjohnson")
    User.create(:username => "thunt")
    User.login_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

11 entries across 11 versions & 1 rubygems

Version Path
searchlogic-2.5.19 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.18 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.17 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.16 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.15 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.14 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.13 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.12 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.11 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.10 spec/searchlogic/named_scopes/alias_scope_spec.rb
searchlogic-2.5.9 spec/searchlogic/named_scopes/alias_scope_spec.rb