Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Tweaked a tests tweak from r16960 so it uses the right model.

When testing for permission enforcement in the admin for m2m
relationships we were erroneously using the ID of the related model
instead of using the ID of the corresponding automatically created
intermediate model. This manifested as a failure under Oracle but can
fail with any backend if the IDs of both models diverge.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17001 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ab72e6bdd1e42dce83fd7dba35919d6468d8ada3 1 parent 62afd58
Ramiro Morales authored
6  tests/regressiontests/admin_inlines/tests.py
@@ -233,7 +233,9 @@ def setUp(self):
233 233
         author = Author.objects.create(pk=1, name=u'The Author')
234 234
         book = author.books.create(name=u'The inline Book')
235 235
         self.author_change_url = '/admin/admin_inlines/author/%i/' % author.id
236  
-        self.book_id = book.id
  236
+        # Get the ID of the automatically created intermediate model for thw Author-Book m2m
  237
+        author_book_auto_m2m_intermediate = Author.books.through.objects.get(author=author, book=book)
  238
+        self.author_book_auto_m2m_intermediate_id = author_book_auto_m2m_intermediate.pk
237 239
 
238 240
         holder = Holder2.objects.create(dummy=13)
239 241
         inner2 = Inner2.objects.create(dummy=42, holder=holder)
@@ -311,7 +313,7 @@ def test_inline_change_m2m_change_perm(self):
311 313
         self.assertContains(response, '<h2>Author-book relationships</h2>')
312 314
         self.assertContains(response, 'Add another Author-Book Relationship')
313 315
         self.assertContains(response, 'value="4" id="id_Author_books-TOTAL_FORMS"')
314  
-        self.assertContains(response, '<input type="hidden" name="Author_books-0-id" value="%i"' % self.book_id)
  316
+        self.assertContains(response, '<input type="hidden" name="Author_books-0-id" value="%i"' % self.author_book_auto_m2m_intermediate_id)
315 317
         self.assertContains(response, 'id="id_Author_books-0-DELETE"')
316 318
 
317 319
     def test_inline_change_fk_add_perm(self):

0 notes on commit ab72e6b

Please sign in to comment.
Something went wrong with that request. Please try again.