last fix for deleted job didn't work, this should fix it.

pull/2/head
kay.one 13 years ago
parent 08a5b28f40
commit ce8713d953

@ -302,8 +302,29 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
//Assert //Assert
var registeredJobs = Db.Fetch<JobDefinition>(); var registeredJobs = Db.Fetch<JobDefinition>();
registeredJobs.Should().HaveCount(1); registeredJobs.Should().HaveCount(1);
registeredJobs.Should().NotContain(c => c.Name == deletedJob.Name); registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
}
[Test]
public void inti_should_removed_jobs_that_no_longer_exist_even_with_same_name()
{
IList<IJob> fakeJobs = new List<IJob> { fakeJob };
Mocker.SetConstant(fakeJobs);
WithRealDb();
var deletedJob = Builder<JobDefinition>.CreateNew()
.With(c => c.Name = fakeJob.Name).Build();
Db.Insert(deletedJob);
var jobProvider = Mocker.Resolve<JobProvider>();
//Act
jobProvider.Initialize();
//Assert
var registeredJobs = Db.Fetch<JobDefinition>();
registeredJobs.Should().HaveCount(1);
registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
} }
[Test] [Test]

@ -76,7 +76,7 @@ namespace NzbDrone.Core.Jobs
foreach (var currentJob in currentJobs) foreach (var currentJob in currentJobs)
{ {
if (!_jobs.Any(c => c.Name == currentJob.Name)) if (!_jobs.Any(c => c.GetType().ToString() == currentJob.TypeName))
{ {
logger.Debug("Removing job from database '{0}'", currentJob.Name); logger.Debug("Removing job from database '{0}'", currentJob.Name);
_database.Delete(currentJob); _database.Delete(currentJob);

Loading…
Cancel
Save