Skip to content

Commit f6a479b

Browse files
committed
Bug Fix: Ensured ResetPermittedContentTypes() is correctly called
After marking the content types as `!IsNew` in the `StubTopicRepository` (45aa7be)`, the test which confirmed that `ResetPermittedContentTypes()` was called when saving a `ContentTypeDescriptor` with a `Relationships` collection marked `IsDirty()` started failing. It turns out this was indicative of a genuine bug in the underlying application which was covered up by the fact that the content type descriptors hadn't been saved. That's because the code to determine if the relationships are dirty was occurring after the `Save()`—at which point the relationships are marked as clean. Since collections containing `IsNew` topics cannot be marked as clean, however, this worked in the previous test case. In the updated test case, which better represents real world conditions, this failed. This is easily fixed by caching the value of `Relationships.IsDirty()` prior to marking the collection as clean. This resolves #81.
1 parent b86b4dc commit f6a479b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

OnTopic/Repositories/TopicRepository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ private void Save([NotNull]Topic topic, bool isRecursive, TopicCollection unreso
327327
| Establish variables
328328
\-----------------------------------------------------------------------------------------------------------------------*/
329329
var isNew = topic.IsNew;
330+
var areRelationshipsDirty = topic.Relationships.IsDirty();
330331

331332
/*------------------------------------------------------------------------------------------------------------------------
332333
| Validate content type
@@ -405,7 +406,7 @@ _contentTypeDescriptors is not null &&
405406
/*------------------------------------------------------------------------------------------------------------------------
406407
| If content type, and relationships have been updated, refresh permitted content types
407408
\-----------------------------------------------------------------------------------------------------------------------*/
408-
if (asContentType is not null && asContentType.Relationships.IsDirty()) {
409+
if (asContentType is not null && areRelationshipsDirty) {
409410
asContentType.ResetPermittedContentTypes();
410411
}
411412

0 commit comments

Comments
 (0)