From ce8713d953f1f1b648d760166a6fbaaa559f3ec1 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 1 Dec 2011 23:26:38 -0800 Subject: [PATCH] last fix for deleted job didn't work, this should fix it. --- .../JobProviderTests/JobProviderFixture.cs | 27 ++++++++++++++++--- NzbDrone.Core/Jobs/JobProvider.cs | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs index c132925e2..5017fffb3 100644 --- a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs @@ -290,20 +290,41 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests { IList fakeJobs = new List { fakeJob }; Mocker.SetConstant(fakeJobs); - + WithRealDb(); var deletedJob = Builder.CreateNew().Build(); Db.Insert(deletedJob); var jobProvider = Mocker.Resolve(); - + //Act jobProvider.Initialize(); //Assert var registeredJobs = Db.Fetch(); 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 fakeJobs = new List { fakeJob }; + Mocker.SetConstant(fakeJobs); + + WithRealDb(); + var deletedJob = Builder.CreateNew() + .With(c => c.Name = fakeJob.Name).Build(); + + Db.Insert(deletedJob); + var jobProvider = Mocker.Resolve(); + + //Act + jobProvider.Initialize(); + + //Assert + var registeredJobs = Db.Fetch(); + registeredJobs.Should().HaveCount(1); + registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName); } [Test] diff --git a/NzbDrone.Core/Jobs/JobProvider.cs b/NzbDrone.Core/Jobs/JobProvider.cs index f63fc997c..4a8e28e0b 100644 --- a/NzbDrone.Core/Jobs/JobProvider.cs +++ b/NzbDrone.Core/Jobs/JobProvider.cs @@ -76,7 +76,7 @@ namespace NzbDrone.Core.Jobs 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); _database.Delete(currentJob);