Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a problem with create_by_full_name() when a new root is created.

  • Loading branch information...
commit 52b0f8f4a66e033302a207701c24beb568239609 1 parent 41dc56f
Malcolm Tredinnick authored
Showing with 8 additions and 1 deletion.
  1. +1 −1  acacia/managers.py
  2. +7 −0 acacia/tests/test_models.py
View
2  acacia/managers.py
@@ -53,7 +53,7 @@ def get_or_create_by_full_name(self, full_name):
# TODO: Feels like I should be able to do this with fewer queries.
pieces = full_name.rsplit(self.model.separator, 1)
if len(pieces) == 1:
- return self.model.create(name=pieces[0]), True
+ return self.create(name=pieces[0]), True
parent, created = self.get_or_create_by_full_name(pieces[0])
if not pieces[1]:
# full_name ended with a trailing separator (e.g. /foo/bar/).
View
7 acacia/tests/test_models.py
@@ -282,6 +282,13 @@ def test_create_by_full_name4(self):
self.failUnlessEqual(created, True)
self.failUnlessEqual(unicode(node), u"a/b/e")
+ def test_create_by_full_name5(self):
+ """
+ Tests that creating a new node with a new root works as expected.
+ """
+ _, created = models.Topic.objects.get_or_create_by_full_name("j/k/l")
+ self.failUnlessEqual(created, True)
+
def test_create_duplicate_entry(self):
"""
Tests that creating a node that already exists results in an error.
Please sign in to comment.
Something went wrong with that request. Please try again.