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

#887 Exclude not active crumbs siblings #892

Merged
merged 8 commits into from
Jun 26, 2019
Merged

#887 Exclude not active crumbs siblings #892

merged 8 commits into from
Jun 26, 2019

Conversation

duker33
Copy link
Contributor

@duker33 duker33 commented Jun 21, 2019

Closes #887

@duker33 duker33 requested a review from ArtemijRodionov June 21, 2019 15:54
@duker33 duker33 self-assigned this Jun 21, 2019
@duker33 duker33 changed the title #887 Fix crumbs #887 Exclude not active crumbs siblings Jun 22, 2019
@@ -20,7 +21,7 @@
from django.utils.translation import ugettext as _

from catalog.helpers import reverse_catalog_url
from pages.models import CustomPage
from pages import models as pages_models
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from pages import models as pages_models
import pages

pages.models has the same length, but wider scope, so i'd prefer it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@artemiy312 , some django models preprocessing black magic does not allow us to use just pages.models appropriately. I'll create subtask about it for research and possible renaming all over the system

@@ -527,20 +531,33 @@ def test_tags_pagination_has_canonical_links(self):
)
)

def test_category_matrix_page(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like an accidentally removed test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@artemiy312 , it's just moved to shopelectro.tests.tests_views.CategoriesMatrix#test_roots_sorting with another task. I just removed code old doubling

# The test below proves the bug. Now fix it.
@unittest.expectedFailure
def test_crumb_siblings_are_active(self):
parent = models.Category.objects.raw(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems it is the same, but simpler

Suggested change
parent = models.Category.objects.raw(
parent = models.Category.objects.annotate(c=Count('children')).filter(c__gt=1).first()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! I'll try it

category = parent.children.active().first()
soup = self.get_category_soup(category.children.active().first())
siblings = soup.select('.breadcrumbs-siblings-links a')
self.assertTrue(all([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you

Suggested change
self.assertTrue(all([
self.assertFalse(models.Category.objects.filter(
name__in=[s.text.strip() for s in siblings],
page__is_active=False,
).exists())

@duker33 duker33 merged commit 9360507 into master Jun 26, 2019
@duker33 duker33 deleted the 887_fix_crumbs branch June 26, 2019 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exclude non active crums siblings
2 participants