Skip to content

Commit a05d5b7

Browse files
committed
Added test to demonstrate the custom foreignkey bug
1 parent 0001c47 commit a05d5b7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

simple_history/tests/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,8 @@ class UnicodeVerboseName(models.Model):
193193

194194
class Meta:
195195
verbose_name = '\u570b'
196+
197+
198+
class CustomFKError(models.Model):
199+
fk = models.ForeignKey(SecondLevelInheritedModel)
200+
history = HistoricalRecords()

simple_history/tests/tests/test_models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
except ImportError: # django 1.4 compatibility
99
from django.contrib.auth.models import User
1010
from django.db.models.loading import get_model
11+
from django.db.migrations import state
1112
from django.test import TestCase
1213
from django.core.files.base import ContentFile
1314

@@ -18,7 +19,7 @@
1819
FileModel, Document, Book, HistoricalPoll, Library, State, AbstractBase,
1920
ConcreteAttr, ConcreteUtil, SelfFK, Temperature, WaterLevel,
2021
ExternalModel1, ExternalModel3, UnicodeVerboseName, HistoricalChoice,
21-
HistoricalState
22+
HistoricalState, HistoricalCustomFKError
2223
)
2324
from ..external.models import ExternalModel2, ExternalModel4
2425

@@ -469,3 +470,6 @@ def test_import_related(self):
469470
def test_string_related(self):
470471
field_object = HistoricalState._meta.get_field_by_name('library_id')[0]
471472
self.assertEqual(field_object.related.model, State)
473+
474+
def test_state_serialization_of_customfk(self):
475+
state.ModelState.from_model(HistoricalCustomFKError)

0 commit comments

Comments
 (0)