mirror of https://github.com/Sonarr/Sonarr
Fixed: PRevent import if potential bulk season release doesn't have air date for all episodes
Closes #5021
This commit is contained in:
parent
d48950ec3c
commit
f9b2c2d843
|
@ -136,7 +136,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_reject_if_episode_title_is_required_for_bulk_season_releases_and_it_is_mising()
|
public void should_reject_if_episode_title_is_required_for_bulk_season_releases_and_it_is_missing()
|
||||||
{
|
{
|
||||||
_localEpisode.Episodes.First().Title = "TBA";
|
_localEpisode.Episodes.First().Title = "TBA";
|
||||||
|
|
||||||
|
@ -154,5 +154,28 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||||
|
|
||||||
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeFalse();
|
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_reject_if_episode_title_is_required_for_bulk_season_releases_and_some_episodes_do_not_have_air_date()
|
||||||
|
{
|
||||||
|
_localEpisode.Episodes.First().Title = "TBA";
|
||||||
|
|
||||||
|
Mocker.GetMock<IConfigService>()
|
||||||
|
.Setup(s => s.EpisodeTitleRequired)
|
||||||
|
.Returns(EpisodeTitleRequiredType.BulkSeasonReleases);
|
||||||
|
|
||||||
|
|
||||||
|
Mocker.GetMock<IEpisodeService>()
|
||||||
|
.Setup(s => s.GetEpisodesBySeason(It.IsAny<int>(), It.IsAny<int>()))
|
||||||
|
.Returns(Builder<Episode>.CreateListOfSize(5)
|
||||||
|
.All()
|
||||||
|
.With(e => e.Title = "TBA")
|
||||||
|
.With(e => e.AirDateUtc = null)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(e => e.AirDateUtc = _localEpisode.Episodes.First().AirDateUtc)
|
||||||
|
.BuildList());
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,12 +55,12 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
var firstEpisode = episodes.First();
|
var firstEpisode = episodes.First();
|
||||||
var episodesInSeason = _episodeService.GetEpisodesBySeason(firstEpisode.SeriesId, firstEpisode.EpisodeNumber);
|
var episodesInSeason = _episodeService.GetEpisodesBySeason(firstEpisode.SeriesId, firstEpisode.EpisodeNumber);
|
||||||
var allEpisodesOnTheSameDay = firstEpisode.AirDateUtc.HasValue && episodes.All(e =>
|
var allEpisodesOnTheSameDay = firstEpisode.AirDateUtc.HasValue && episodes.All(e =>
|
||||||
e.AirDateUtc.HasValue &&
|
!e.AirDateUtc.HasValue ||
|
||||||
e.AirDateUtc.Value == firstEpisode.AirDateUtc.Value);
|
e.AirDateUtc.Value == firstEpisode.AirDateUtc.Value);
|
||||||
|
|
||||||
if (episodeTitleRequired == EpisodeTitleRequiredType.BulkSeasonReleases &&
|
if (episodeTitleRequired == EpisodeTitleRequiredType.BulkSeasonReleases &&
|
||||||
allEpisodesOnTheSameDay &&
|
allEpisodesOnTheSameDay &&
|
||||||
episodesInSeason.Count(e => e.AirDateUtc.HasValue &&
|
episodesInSeason.Count(e => !e.AirDateUtc.HasValue ||
|
||||||
e.AirDateUtc.Value == firstEpisode.AirDateUtc.Value
|
e.AirDateUtc.Value == firstEpisode.AirDateUtc.Value
|
||||||
) < 4
|
) < 4
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue