Permalink
Browse files

failing tests

  • Loading branch information...
sandrew committed Jan 30, 2012
1 parent 1d6b267 commit ffc70bb7058d310ae677579c2b7ace4a983284c2
Showing with 37 additions and 0 deletions.
  1. +24 −0 test/integration/active_record_searchable_test.rb
  2. +13 −0 test/models/active_record_models.rb
@@ -32,6 +32,10 @@ def setup
create_table :active_record_class_with_dynamic_index_names do |t|
t.string :title
end
+ create_table :sti_ancestors do |t|
+ t.string :title
+ t.string :type
+ end
end
end
@@ -352,6 +356,26 @@ module ::Rails; end
end
+ context 'with Single Table Inheritance' do
+ setup do
+ StiAncestor.create! :title => 'Ancestor text'
+ FirstStiDescendant.create! :title => 'Descendant text'
+ SecondStiDescendant.create! :title => 'Another Descendant text'
+ end
+
+ should 'load all STI descendants items' do
+ res = Tire.search('sti_ancestors', :load => true) do
+ query do
+ string 'Descendant'
+ end
+ end.results.results
+
+ assert_length_of res.results, 2
+ assert_instance_of FirstStiDescendant, res[0]
+ assert_instance_of SecondStiDescendant, res[1]
+ end
+ end
+
end
end
@@ -78,3 +78,16 @@ class ActiveRecordClassWithDynamicIndexName < ActiveRecord::Base
"dynamic" + '_' + "index"
end
end
+
+class StiAncestor < ActiveRecord::Base
+ include Tire::Model::Search
+ include Tire::Model::Callbacks
+end
+
+class FirstStiDescendant < StiAncestor
+ index_name 'sti_ancestors'
+end
+
+class SecondStiDescendant < StiAncestor
+ index_name 'sti_ancestors'
+end

0 comments on commit ffc70bb

Please sign in to comment.