spec/integration/associations_spec.rb in pg_search-0.7.9 vs spec/integration/associations_spec.rb in pg_search-1.0.0

- old
+ new

@@ -115,22 +115,27 @@ results = ModelWithHasMany.with_associated('foo bar') expect(results.map(&:title)).to match_array(included.map(&:title)) expect(results).not_to include(excluded) end - it "uses an unscoped relation of the assocated model" do + it "uses an unscoped relation of the associated model" do excluded = ModelWithHasMany.create!(:title => 'abcdef', :other_models => [ AssociatedModelWithHasMany.create!(:title => 'abcdef') ]) + included = [ ModelWithHasMany.create!(:title => 'abcdef', :other_models => [ AssociatedModelWithHasMany.create!(:title => 'foo'), AssociatedModelWithHasMany.create!(:title => 'bar') ]) ] - results = ModelWithHasMany.limit(1).order("id ASC").with_associated('foo bar') + results = ModelWithHasMany + .limit(1) + .order("#{ModelWithHasMany.quoted_table_name}.id ASC") + .with_associated('foo bar') + expect(results.map(&:title)).to match_array(included.map(&:title)) expect(results).not_to include(excluded) end end @@ -298,10 +303,10 @@ ) ] results = ModelWithAssociation.with_associated('foo bar') - expect(results.to_sql.scan("INNER JOIN").length).to eq(1) + expect(results.to_sql.scan("INNER JOIN #{AssociatedModel.quoted_table_name}").length).to eq(1) included.each { |object| expect(results).to include(object) } excluded.each { |object| expect(results).not_to include(object) } end end