1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-31 07:52:37 +01:00

Fixed: Specials will be ignored if no specials existed previously

This commit is contained in:
Mark McDowall 2014-05-25 18:47:54 -07:00
parent be2690e2c8
commit 1b10002ed8
3 changed files with 88 additions and 0 deletions

View File

@ -233,6 +233,7 @@
<Compile Include="ProviderTests\DiskProviderTests\ArchiveProviderFixture.cs" />
<Compile Include="MediaFiles\DownloadedEpisodesImportServiceFixture.cs" />
<Compile Include="SeriesStatsTests\SeriesStatisticsFixture.cs" />
<Compile Include="TvTests\RefreshSeriesServiceFixture.cs" />
<Compile Include="TvTests\SeriesRepositoryTests\QualityProfileRepositoryFixture.cs" />
<Compile Include="TvTests\SeriesServiceTests\UpdateMultipleSeriesFixture.cs" />
<Compile Include="TvTests\SeriesServiceTests\UpdateSeriesFixture.cs" />

View File

@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Tv.Commands;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.TvTests
{
[TestFixture]
public class RefreshSeriesServiceFixture : CoreTest<RefreshSeriesService>
{
private Series _series;
[SetUp]
public void Setup()
{
var season1 = Builder<Season>.CreateNew()
.With(s => s.SeasonNumber = 1)
.Build();
_series = Builder<Series>.CreateNew()
.With(s => s.Seasons = new List<Season>
{
season1
})
.Build();
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(_series.Id))
.Returns(_series);
}
private void GivenNewSeriesInfo(Series series)
{
Mocker.GetMock<IProvideSeriesInfo>()
.Setup(s => s.GetSeriesInfo(It.IsAny<Int32>()))
.Returns(new Tuple<Series, List<Episode>>(series, new List<Episode>()));
}
[Test]
public void should_monitor_new_seasons_automatically()
{
var series = _series.JsonClone();
series.Seasons.Add(Builder<Season>.CreateNew()
.With(s => s.SeasonNumber = 2)
.Build());
GivenNewSeriesInfo(series);
Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 2).Monitored == true)));
}
[Test]
public void should_not_monitor_new_special_season_automatically()
{
var series = _series.JsonClone();
series.Seasons.Add(Builder<Season>.CreateNew()
.With(s => s.SeasonNumber = 0)
.Build());
GivenNewSeriesInfo(series);
Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 0).Monitored == false)));
}
}
}

View File

@ -101,6 +101,12 @@ namespace NzbDrone.Core.Tv
//Todo: Should this should use the previous season's monitored state?
if (existingSeason == null)
{
if (season.SeasonNumber == 0)
{
season.Monitored = false;
continue;
}
_logger.Debug("New season ({0}) for series: [{1}] {2}, setting monitored to true", season.SeasonNumber, series.TvdbId, series.Title);
season.Monitored = true;
}