Added a quick patch to support disabled by default jobs. setting interval to 0 will disable the job

pull/4/head
Keivan 14 years ago
parent 24c47801b3
commit 3083ff6fcf

@ -231,6 +231,40 @@ namespace NzbDrone.Core.Test
//Assert //Assert
Assert.Count(1, timers); 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<IJob> fakeTimers = new List<IJob> { disabledJob };
var mocker = new AutoMoqer();
mocker.SetConstant(repo);
mocker.SetConstant(fakeTimers);
var timerProvider = mocker.Resolve<JobProvider>();
timerProvider.Initialize();
}
var mocker2 = new AutoMoqer();
mocker2.SetConstant(repo);
var assertTimerProvider = mocker2.Resolve<JobProvider>();
var timers = assertTimerProvider.All();
//Assert
Assert.Count(1, timers);
Assert.IsFalse(timers[0].Enable);
} }
@ -255,6 +289,24 @@ namespace NzbDrone.Core.Test
} }
} }
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 class BrokenJob : IJob
{ {
public string Name public string Name

@ -14,6 +14,8 @@ namespace NzbDrone.Core.Providers.Jobs
/// <summary> /// <summary>
/// Default Interval that this job should run at. In seconds. /// Default Interval that this job should run at. In seconds.
/// </summary> /// </summary>
/// <remarks>Setting this value to 0 means the job will not be
/// executed by the schedule and is only triggered manually.</remarks>
int DefaultInterval { get; } int DefaultInterval { get; }

@ -208,7 +208,7 @@ namespace NzbDrone.Core.Providers.Jobs
{ {
var settings = new JobSetting var settings = new JobSetting
{ {
Enable = true, Enable = timerProviderLocal.DefaultInterval > 0,
TypeName = timer.GetType().ToString(), TypeName = timer.GetType().ToString(),
Name = timerProviderLocal.Name, Name = timerProviderLocal.Name,
Interval = timerProviderLocal.DefaultInterval, Interval = timerProviderLocal.DefaultInterval,

Loading…
Cancel
Save