Comments (3)
I guess there may be some issue with acts_as_tree, hope I can solve it.
from bullet.
From my limited investigations I couldn't work out if it was acts_as_tree or STI that was the cause. I think maybe it is a combination of both. The children of a Document, Page or Folder can be a Page or Folder and I think its not being picked up that both have the same base class and thus use the same table for the query. In which case I'm guessing you would need to look down the inheritance chain.
Great work by the way :)
from bullet.
Hi, I have add tests about STI in spec/bullet_association_spec.rb
from line 775 to line 864. Unfortunately, they all passed. So can you check all of the tests and figure out what do I have missed? Or you can add more tests to make it failure.
describe Bullet::Association, "STI" do
def setup_db
ActiveRecord::Schema.define(:version => 1) do
create_table :documents do |t|
t.string :name
t.string :type
t.integer :parent_id
t.integer :author_id
end
create_table :authors do |t|
t.string :name
end
end
end
def teardown_db
ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Base.connection.drop_table(table)
end
end
class Document < ActiveRecord::Base
has_many :children, :class_name => "Document", :foreign_key => 'parent_id'
belongs_to :parent, :class_name => "Document", :foreign_key => 'parent_id'
belongs_to :author
end
class Page < Document
end
class Folder < Document
end
class Author < ActiveRecord::Base
has_many :documents
end
before(:all) do
setup_db
author1 = Author.create(:name => 'author1')
author2 = Author.create(:name => 'author2')
folder1 = Folder.create(:name => 'folder1', :author_id => author1.id)
folder2 = Folder.create(:name => 'folder2', :author_id => author2.id)
page1 = Page.create(:name => 'page1', :parent_id => folder1.id, :author_id => author1.id)
page2 = Page.create(:name => 'page2', :parent_id => folder1.id, :author_id => author1.id)
page3 = Page.create(:name => 'page3', :parent_id => folder2.id, :author_id => author2.id)
page4 = Page.create(:name => 'page4', :parent_id => folder2.id, :author_id => author2.id)
end
before(:each) do
Bullet::Association.start_request
end
after(:each) do
Bullet::Association.end_request
end
it "should detect unpreload associations" do
Page.find(:all).each do |page|
page.author.name
end
Bullet::Association.should be_has_unpreload_associations
Bullet::Association.check_unused_preload_associations
Bullet::Association.should_not be_has_unused_preload_associations
end
it "should not detect unpreload associations" do
Page.find(:all, :include => :author).each do |page|
page.author.name
end
Bullet::Association.should_not be_has_unpreload_associations
Bullet::Association.check_unused_preload_associations
Bullet::Association.should_not be_has_unused_preload_associations
end
it "should detect unused preload associations" do
Page.find(:all, :include => :author).collect(&:name)
Bullet::Association.should_not be_has_unpreload_associations
Bullet::Association.check_unused_preload_associations
Bullet::Association.should be_has_unused_preload_associations
end
it "should not detect unused preload associations" do
Page.find(:all).collect(&:name)
Bullet::Association.should_not be_has_unpreload_associations
Bullet::Association.check_unused_preload_associations
Bullet::Association.should_not be_has_unused_preload_associations
end
end
from bullet.
Related Issues (20)
- Support for mongoid 8.0
- Missing tests for eager_load
- Request to create new tag for current master HOT 1
- Using Bullet With Sidekiq Worker Middleware HOT 3
- No such middleware to insert before: ActionDispatch::ContentSecurityPolicy::Middleware (RuntimeError) HOT 1
- Undefined method include? for Rails::Configuration::MiddlewareStackProxy after upgrading to 7.0.6 HOT 5
- False "AVOID eager loading detected" on model association
- False positive with count associtiaons HOT 4
- Comparison with prospite and Rails strict_loading
- Suppress messages for impossible JOINS across multiple databases?
- Include in test as well?
- Too many allocations when using Bullet >= 7.0.5
- Why sentry not received alert when n+1 query detected in staging env ?
- Content Security Policy not properly detected in Rails HOT 4
- Nonces are not applied to inline CSS styles
- Obvious N+1 query not detected in RSpec (when setup code is run before it) HOT 1
- add_safelist ignored HOT 1
- Support to rails 7.1.0.alpha HOT 3
- `skip_html_injection` as a URL query param?
- Feature request: accept lambda rather than using uniform_notifier
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bullet.