Keenan Brock
247e745e2e
change nav tests 2
...
Change nav test to more clearly show what is being tested
2023-03-24 23:14:52 -04:00
Keenan Brock
015ef1eeca
add back ancestor_ids{_in_database,_before_last_save} and parent_id
...
this was removed by 0fcd12fd https://github.com/stefankroes/ancestry/pull/589
adding fields back.
added tests to exercise
2023-03-24 23:14:52 -04:00
Keenan Brock
9b3a034661
Merge pull request #635 from kbrock/ordered_descendants
...
Delete nodes from leafs up to root
2023-03-19 22:21:06 -04:00
Keenan Brock
d00654a4e8
Delete nodes from leafs up to root
...
When destroying dependents, start with the furthest down leafs and work
your way up to the current node
https://github.com/stefankroes/ancestry/issues/90
2023-03-19 22:15:35 -04:00
Keenan Brock
6f3326e960
fixed changelog v4.3
2023-03-19 22:13:03 -04:00
Keenan Brock
0bba8f6fb7
Merge pull request #643 from kbrock/add_ancestor_ids_in_database
...
Add back ancestor_ids_in_database
2023-03-17 21:30:34 -04:00
Keenan Brock
df7aeb31c4
431 changelog
2023-03-17 21:13:08 -04:00
Keenan Brock
e76cba3a2f
add back ancestor_ids{_in_database,_before_last_save} and parent_id
...
this was removed by 0fcd12fd https://github.com/stefankroes/ancestry/pull/589
adding fields back.
added tests to exercise
2023-03-17 21:13:08 -04:00
Keenan Brock
b559d8b583
Merge pull request #642 from kbrock/random_tests
...
ancestry column tests
2023-03-17 21:00:08 -04:00
Keenan Brock
8f7ef4fecd
display default_update_strategy in test logs
2023-03-17 20:54:04 -04:00
Keenan Brock
43ceac4c17
fill out tests to cover more fields
...
I never could fully read the tree navigation test.
rewrite all methods in same order (looks like copy/paste)
from here, I feel much more comfortable adding and verifying tests exist
2023-03-17 20:54:04 -04:00
Keenan Brock
290f8a120b
Moved update hook tests into hook_tests
2023-03-17 20:54:03 -04:00
Keenan Brock
19f8434334
Merge pull request #634 from kbrock/update_descendants_changed
...
Changes to update_descendants_with_new_ancestry
2023-03-15 21:08:39 -04:00
Keenan Brock
11fa95aa2a
Changes to update_descendants_with_new_ancestry
...
- this is called after a save (/via #589 ), dropping `new_record?`
- putting `ancestry_changed?` in the callback definition. not needed in the method
- had wanted to remove `sane_ancestor_ids?` since validations already ran
Unfortunately, `update_attribute` (read: no validations) allows bogus ancestry through.
Decided to continue skipping updates if the ancestry is deemed not valid.
It can only get this way if a user skips validations.
Not sure the desired behavior if something is corrupting ancestor's ancestry value.
I can see reason why we may want to update them all.
For now, keeping this skip updates check in place
2023-03-14 19:19:50 -04:00
Keenan Brock
e246bee2d0
test sane_ancestor_ids? method
2023-03-14 16:18:06 -04:00
Keenan Brock
07c74caab9
Merge pull request #629 from kbrock/more_sti_tests
...
reverting deprecating has_ancestry in subclasses
2023-03-14 16:04:47 -04:00
Keenan Brock
91637e0b12
un-deprecate ancestry_base_class
...
keeping ancestry_base_class, so defining has_ancestry on a non-base class
will work fine
2023-03-14 16:01:50 -04:00
Keenan Brock
741199aee8
Ensure has_ancestry in subclasses do not leak
2023-03-14 16:01:50 -04:00
Keenan Brock
257af8a0bc
Merge pull request #632 from kbrock/apply_orphan_strategy
...
Support overriding apply_orphan_strategy
2023-03-14 16:00:57 -04:00
Keenan Brock
a39494657e
Merge pull request #633 from kbrock/ancestry_writers
...
update Ancestry writers
2023-03-14 15:50:28 -04:00
Kirill Shnurov
0c0240aefe
remove ancestry_base_class instance reader
2023-03-14 15:44:18 -04:00
Kirill Shnurov
918e443d94
remove ancestry_* writers
2023-03-14 15:16:27 -04:00
Keenan Brock
f04349b665
Support apply_orphan_strategy
...
apply_orphan_strategy was removed in 1a25355
Many gems override this method to apply a custom orphan strategy
This adds support back and adds a test around the behavior
If a developer uses super in this method, that will break
You will need to directly call the desired apply_orphan_strategy_* instead
2023-03-14 14:38:51 -04:00
Keenan Brock
7621f09363
Merge pull request #624 from kbrock/github_matrix_tests
...
Tests more closely follow suggested configurations
2023-03-11 13:17:52 -05:00
Keenan Brock
beeeb4e275
better ancestry column testing
...
- properly configure null columns with materialized_path2
- support and test binary columns (for mysql)
- make update_strategy=:sql for postgres explicit rather than auto selected
- display options to console (probably temporary)
2023-03-11 13:14:16 -05:00
Keenan Brock
a5b2d27aa5
remove ancestry_format from tests
...
This is not really a value we should be exposing
The test globally set the format, so they should know what format is being used
without asking
2023-03-11 11:05:14 -05:00
Keenan Brock
0ba9506372
Merge pull request #626 from kbrock/ancestry_sti_test
...
Deprecate adding ancestry to the middle of an STI tree
2023-03-10 21:13:13 -05:00
Keenan Brock
bf947ebb09
Deprecate adding ancestry to the middle of an STI tree
...
Provide deprecation warning for has_ancestry in the middle of a tree
Still haven't thought up with a good use case for this.
2023-03-10 15:33:19 -05:00
Keenan Brock
3879d3d522
Update ancestry sti subclass test
...
the helper function `with_model` calls has_ancestry for us
So essentially we are calling this twice.
- fixed to not define has_ancestry at the root node.
This is now ensuring that search and the counter_caches are working.
2023-03-10 15:22:38 -05:00
Keenan Brock
cfa09bdc61
Merge pull request #623 from kbrock/fix_43_changelog
...
fix changelog line [skip ci]
2023-03-10 10:46:50 -05:00
Keenan Brock
6e25859603
fix changelog line [skip ci]
2023-03-10 10:44:49 -05:00
Keenan Brock
8b71773e8b
Merge pull request #619 from kbrock/counter_cache_column
...
Counter cache column
2023-03-09 17:39:39 -05:00
Keenan Brock
ff8ee39f7a
drop _counter_cache_column
...
The value is available, no reason to define a duplicate method
2023-03-09 17:36:10 -05:00
Keenan Brock
187dc1d948
Merge pull request #617 from kbrock/orphan_strategy
...
Drop Orphan strategy class attribute
2023-03-09 17:07:57 -05:00
Keenan Brock
1a2535567c
drop orphan_strategy accessor
...
Instead of a case statement in the callback, pull each strategy into own method
2023-03-09 16:22:17 -05:00
Keenan Brock
796ef7c320
drop orphan_strategy=
...
Attributes that affect the way ancestry works need to be set in has_ancestry
and not changed later on
2023-03-09 16:22:17 -05:00
Keenan Brock
ea0bc1e3f4
Merge pull request #621 from kbrock/release_v430b
...
Release v430b
2023-03-09 16:19:28 -05:00
Keenan Brock
04fcb08baa
update arrange in docs
2023-03-09 16:15:07 -05:00
Keenan Brock
66a20f2a3b
Update Readme documentation
2023-03-09 16:15:07 -05:00
Keenan Brock
92b68e63be
updates to changelog
2023-03-09 16:15:05 -05:00
Keenan Brock
aeab49dc4a
Merge pull request #415 from kbrock/partial_tree_sort
...
Make arrange_nodes more memory efficient
2023-03-04 22:43:23 -05:00
Keenan Brock
b5f22921fd
Merge pull request #614 from kbrock/release_v430
...
release v4.3 CHANGELOG [skip ci]
2023-03-04 18:30:14 -05:00
Keenan Brock
a078aa2daf
release v4.3 CHANGELOG
...
* Fix: materialized_path2 strategy https://github.com/stefankroes/ancestry/pull/597
* Fix: descendants ancestry is now updated in after_update callbacks https://github.com/stefankroes/ancestry/pull/589
* Document updated grammar https://github.com/stefankroes/ancestry/pull/594
* Documented `update_strategy` https://github.com/stefankroes/ancestry/pull/588
* Fix: fixed has_parent? when non-default primary id https://github.com/stefankroes/ancestry/pull/585
* Documented column collation and testing https://github.com/stefankroes/ancestry/pull/601 https://github.com/stefankroes/ancestry/pull/607
* Added initializer with default_ancestry_format https://github.com/stefankroes/ancestry/pull/612
* ruby 3.2 support https://github.com/stefankroes/ancestry/pull/596
2023-03-04 18:27:10 -05:00
Keenan Brock
f6213602da
Merge pull request #616 from kbrock/default_ancestry_format_fix
...
Default ancestry format to materialized_path
2023-03-04 00:57:28 -05:00
Keenan Brock
719a457f2c
flatten_arranged_nodes: Don't allocate a arrays per child
...
Since this is in its own method, we no longer have such a big call stack
Also, we are no longer creating a 2 new arrays for every set of children
2023-03-04 00:00:50 -05:00
Keenan Brock
8414d90832
extract flatten_arranged_nodes
...
this is the part responsible for taking a tree and producing an array of nodes
with the parent node before the children
Since children is always a hash, this will never enter the sorting code
and never require the block. so the sorting and the &block was dropped.
This works because ruby enumerates the hashes with insert order (no need to sort again)
2023-03-03 23:38:08 -05:00
Keenan Brock
9ed56654aa
Condense sort_by_ancestry sorting algorithm
...
- Only preforms one compare (<=>) vs two ( == and <=> )
- null ancestry is a space (ensures it sorts first when using materialized path 2)
But it does not actually change the sorting algorithm
It is still sorting levels by id (not optimal)
And still issues when missing nodes
2023-03-03 23:38:08 -05:00
Keenan Brock
22a3f18797
update sort tests
...
We are sorting records that come back from a query.
That means certain assumptions can be made about the records coming back
It will not contain cousins without at least one parent node in there.
2023-03-03 23:38:07 -05:00
Keenan Brock
6a29b385f9
Default ancestry format to materialized_path
...
Wish we did not have to do this,
but for now, no breaking changes
Fixes bug introduced in 53f1914
2023-03-03 20:46:31 -05:00
Keenan Brock
cb7f3032b5
Merge pull request #615 from Fryguy/fix_readme_rendering
...
Fix README rendering [skip ci]
2023-03-03 11:24:49 -05:00