Comments (6)
I fixed it in my fork: https://github.com/juddblair/closure_tree
Rspec is passing, and I built and tested the gem locally with my application, and everything looks good. I didn't write a breaking test for the implementation, but I can submit a pull request for my fix if you'd like.
from closure_tree.
Excellent issue request, sir. Thanks for your thoroughness!
I pulled your change onto a new branch, but the weather's too nice to keep typing right now. I think we (and by "we", I don't mean you have to do it) should add a couple breaking tests (to test with a prefix and a suffix), or do something clever with running the whole test suite with Label or Tag with or without a prefix, just to make sure things are working in all environments.
Thanks again for taking the time to write this up!
from closure_tree.
Sure thing - I started playing around with the tests since, despite the nice weather, I'm under the weather. I added a prefix and suffix to the spec helper and noticed a few things:
- The indexes were too long with long prefixes/suffixes. I changed the test table definitions to use explicit index names, which I also had to do in my application. Might be something to fix in the generator if possible.
- Suffix was problematic - since we singularize the hierarchy table name and use that to name the class, anything that ended with an "s" (actually any suffixes, but especially seemingly plural ones) threw AR for a loop. I fixed this by escaping the prefix/suffix before singularizing it, and then re-adding them, but the resulting line is...interesting (acts_as_tree.rb:393). Might be a cleaner way to do that but it does work.
- A test on cuisine type failed because the table name assertion didn't take prefix/suffix into account. Fixed this.
- Several User tests failed because with the addition of prefix/suffix, the supplied table name was no longer correct. Fixed this. As an aside, should we supply the prefix/suffix to custom table names? It seems like we should just accept what people pass in (using a pre-existing table with a different/no prefix/suffix seems to be a good use case, or a shared DB), but I'm not sure how others do this. I'd vote for correct as-is.
Personally, I think the tests should run with all permutations (prefix, suffix, prefix+suffix, neither), but this seems like a good start.
I updated my fork with my changes.
from closure_tree.
All permutations: http://travis-ci.org/#!/mceachen/closure_tree/builds/2473467
We'll see how it goes.
from closure_tree.
released 3.6.0. Thanks again for your help!
from closure_tree.
Sweet! Thanks for the quick turnaround with the release, much appreciated.
from closure_tree.
Related Issues (20)
- What should I do when my data volume is very large, more than 100 million? HOT 3
- easiest way to move element within list? HOT 3
- How can I migrate 3 million data to hierarchy table?
- N + 1 feedback
- Determinstic ordering using a second column if the value of the first is null
- `parent_id` as zero HOT 1
- Postgres 12 + Rails 6.1: RETURNING "id" issue HOT 1
- Hierarchy model inheritance breaks usage with STI and superclass validations HOT 1
- Regression in combination with paper_trail gem HOT 5
- Deferred hierachy rebuild
- Self-referential model breaks `#ancestors` method. HOT 1
- Children Not Destroyed on call.
- reason for with_ancestor method using map HOT 2
- Fix compound unique index for template in hierarchies_table HOT 4
- Dirty tracking lost when setting parent with numeric_order option HOT 1
- Could there be an option for with_ancestor to include ancestors?
- Loss of namespace when using Accessing Data methods HOT 1
- SystemStackError when updating fixtures HOT 1
- parallel_test fails HOT 2
- Usage with STI table HOT 1
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 closure_tree.