Permalink
Browse files

[#353] Added test for Inherited and decendent model

  • Loading branch information...
1 parent d26aac8 commit ddf20d968904fdf003cb6b29b8d15636f7cdaf0b E-Max committed May 4, 2012
Showing with 17 additions and 4 deletions.
  1. +3 −0 spec/fixtures/models.rb
  2. +1 −1 spec/thinking_sphinx/search_spec.rb
  3. +13 −3 spec/thinking_sphinx/source_spec.rb
@@ -99,6 +99,9 @@ class Child < Person
end
end
+class Teenager < Child
+end
+
class Alpha < ActiveRecord::Base
has_many :betas, :class_name => 'Beta'
has_many :thetas
@@ -514,7 +514,7 @@
filter = @client.filters.last
filter.values.should == [
Parent.to_crc32, Admin::Person.to_crc32,
- Child.to_crc32, Person.to_crc32
+ Child.to_crc32, Teenager.to_crc32, Person.to_crc32
]
filter.attribute.should == 'class_crc'
filter.exclude?.should be_false
@@ -93,9 +93,9 @@
it "should use a environment user if nothing else is provided" do
Person.connection.stub!(:instance_variable_get => {
- :user => nil,
- :username => nil
- })
+ :user => nil,
+ :username => nil
+ })
@source = ThinkingSphinx::Source.new(@index)
riddle = @source.to_riddle_for_core(1, 0)
@@ -165,6 +165,16 @@
it "should include any defined groupings" do
@query.should match(/GROUP BY.+`first_name`/)
end
+
+ it "should include descendants" do
+ index = ThinkingSphinx::Index.new(Child)
+ source = ThinkingSphinx::Source.new(index, :sql_range_step => 1000)
+ riddle = source.to_riddle_for_core(1, 0)
+ query = riddle.sql_query
+
+ query.should match(/WHERE.+`people`\.`type` IN \('Child', 'Teenager'\)/)
+ query.should_not match(/WHERE.+"users"."type" = 'Employee'/)
+ end
end
describe "#sql_query_range" do

0 comments on commit ddf20d9

Please sign in to comment.