diff --git a/NzbDrone.Core.Test/JobProviderTest.cs b/NzbDrone.Core.Test/JobProviderTest.cs index 02f11ef8b..ed4eb960e 100644 --- a/NzbDrone.Core.Test/JobProviderTest.cs +++ b/NzbDrone.Core.Test/JobProviderTest.cs @@ -231,6 +231,40 @@ public void Init_Timers_only_registers_once() //Assert Assert.Count(1, timers); + Assert.IsTrue(timers[0].Enable); + } + + + + [Test] + public void Init_Timers_sets_interval_0_to_disabled() + { + var repo = MockLib.GetEmptyRepository(); + + for (int i = 0; i < 2; i++) + { + var disabledJob = new DisabledJob(); + IEnumerable fakeTimers = new List { disabledJob }; + var mocker = new AutoMoqer(); + + mocker.SetConstant(repo); + mocker.SetConstant(fakeTimers); + + var timerProvider = mocker.Resolve(); + timerProvider.Initialize(); + } + + var mocker2 = new AutoMoqer(); + + mocker2.SetConstant(repo); + var assertTimerProvider = mocker2.Resolve(); + + var timers = assertTimerProvider.All(); + + + //Assert + Assert.Count(1, timers); + Assert.IsFalse(timers[0].Enable); } @@ -255,6 +289,24 @@ public void Start(ProgressNotification notification, int targetId) } } + public class DisabledJob : IJob + { + public string Name + { + get { return "DisabledJob"; } + } + + public int DefaultInterval + { + get { return 0; } + } + + public void Start(ProgressNotification notification, int targetId) + { + + } + } + public class BrokenJob : IJob { public string Name diff --git a/NzbDrone.Core/Providers/Jobs/IJob.cs b/NzbDrone.Core/Providers/Jobs/IJob.cs index 3f7b5e1dc..ac2f85e76 100644 --- a/NzbDrone.Core/Providers/Jobs/IJob.cs +++ b/NzbDrone.Core/Providers/Jobs/IJob.cs @@ -14,6 +14,8 @@ public interface IJob /// /// Default Interval that this job should run at. In seconds. /// + /// Setting this value to 0 means the job will not be + /// executed by the schedule and is only triggered manually. int DefaultInterval { get; } diff --git a/NzbDrone.Core/Providers/Jobs/JobProvider.cs b/NzbDrone.Core/Providers/Jobs/JobProvider.cs index 3201571e2..c3edf5de7 100644 --- a/NzbDrone.Core/Providers/Jobs/JobProvider.cs +++ b/NzbDrone.Core/Providers/Jobs/JobProvider.cs @@ -208,7 +208,7 @@ public virtual void Initialize() { var settings = new JobSetting { - Enable = true, + Enable = timerProviderLocal.DefaultInterval > 0, TypeName = timer.GetType().ToString(), Name = timerProviderLocal.Name, Interval = timerProviderLocal.DefaultInterval,