Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category is duplicated when deleted from the parent and added to the new parent. #64

Open
teddychoi opened this issue Oct 22, 2014 · 0 comments
Labels

Comments

@teddychoi
Copy link
Member

To move a Category object from the parent to the new parent, the category should be discarded from the parent and added to the new parent. But when a category is deleted from the parent and added to the new parent, the created_at attribute is overwritten with the newer time than the deleted_at, and as a result, the category exists in both two parents. The converse situation is also true.
Here is a regression test.

def test_previous_change_applied():
    subs = SubscriptionList()
    category = Category(label='first-order')
    subcategory = Category(label='second-order')
    to_move = Category(label='to-move')
    category.add(subcategory)
    subs.add(category)
    subs.add(to_move)
    assert len(subs) == 2
    assert len(subs.categories['first-order']) == 1

    subs.discard(to_move)
    category.add(to_move)
    assert len(subs) == 1
    assert len(subs.categories['first-order']) == 2

To work around this, I have to save the SubscriptionList to the stage after deleting the category from the parent, reread the SubscriptionList, and add the category to the new parent.

@teddychoi teddychoi added the bug label Oct 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant