mirror of
https://github.com/Readarr/Readarr.git
synced 2026-03-05 13:20:32 -05:00
Fixed: Null reference error when import list adds new book to existing author
Fixes #1235 (cherry picked from commit 5e3045db86748d0ab407a6785007cb6bbd4f46a6)
This commit is contained in:
@@ -105,14 +105,14 @@ namespace NzbDrone.Core.Test.ImportListTests
|
||||
{
|
||||
Mocker.GetMock<IAuthorService>()
|
||||
.Setup(v => v.FindById(_importListReports.First().AuthorGoodreadsId))
|
||||
.Returns(new Author { ForeignAuthorId = _importListReports.First().AuthorGoodreadsId });
|
||||
.Returns(new Author { Id = 1, ForeignAuthorId = _importListReports.First().AuthorGoodreadsId });
|
||||
}
|
||||
|
||||
private void WithExistingBook()
|
||||
{
|
||||
Mocker.GetMock<IBookService>()
|
||||
.Setup(v => v.FindById(_importListReports.First().EditionGoodreadsId))
|
||||
.Returns(new Book { ForeignBookId = _importListReports.First().EditionGoodreadsId });
|
||||
.Returns(new Book { Id = 1, ForeignBookId = _importListReports.First().EditionGoodreadsId });
|
||||
}
|
||||
|
||||
private void WithExcludedAuthor()
|
||||
@@ -231,6 +231,7 @@ namespace NzbDrone.Core.Test.ImportListTests
|
||||
public void should_add_if_existing_author_but_new_book()
|
||||
{
|
||||
WithBookId();
|
||||
WithAuthorId();
|
||||
WithExistingAuthor();
|
||||
|
||||
Subject.Execute(new ImportListSyncCommand());
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
@@ -262,8 +263,9 @@ namespace NzbDrone.Core.ImportLists
|
||||
}
|
||||
};
|
||||
|
||||
if (importList.ShouldMonitor == ImportListMonitorType.SpecificBook)
|
||||
if (importList.ShouldMonitor == ImportListMonitorType.SpecificBook && toAddAuthor.AddOptions != null)
|
||||
{
|
||||
Debug.Assert(toAddAuthor.Id == 0, "new author added but ID is not 0");
|
||||
toAddAuthor.AddOptions.BooksToMonitor.Add(toAdd.ForeignBookId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user