diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py index 236af43834..0c30cd0489 100644 --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -2151,6 +2151,34 @@ class AutodetectorTests(TestCase): ) self.assertNotIn("_order", [name for name, field in changes['testapp'][0].operations[0].fields]) + def test_add_model_order_with_respect_to_index_foo_together(self): + changes = self.get_changes([], [ + self.book, + ModelState('testapp', 'Author', [ + ('id', models.AutoField(primary_key=True)), + ('name', models.CharField(max_length=200)), + ('book', models.ForeignKey('otherapp.Book', models.CASCADE)), + ], options={ + 'order_with_respect_to': 'book', + 'index_together': {('name', '_order')}, + 'unique_together': {('id', '_order')}, + }), + ]) + self.assertNumberMigrations(changes, 'testapp', 1) + self.assertOperationTypes(changes, 'testapp', 0, ['CreateModel']) + self.assertOperationAttributes( + changes, + 'testapp', + 0, + 0, + name='Author', + options={ + 'order_with_respect_to': 'book', + 'index_together': {('name', '_order')}, + 'unique_together': {('id', '_order')}, + }, + ) + def test_alter_model_managers(self): """ Changing the model managers adds a new operation.