From 157124df89930918e80cb6e333c48889ee274ce9 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 16 Jan 2015 23:16:31 -0800 Subject: [PATCH] Fixed: Disable EZTV when using the default URL --- .../Datastore/Migration/074_disable_eztv.cs | 66 +++++++++++++++++++ .../IndexerTests/EztvTests/EztvFixture.cs | 2 +- .../NzbDrone.Core.Test.csproj | 1 + .../Datastore/Migration/074_disable_eztv.cs | 14 ++++ .../Indexers/Eztv/EztvSettings.cs | 4 +- src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + 6 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/074_disable_eztv.cs create mode 100644 src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/074_disable_eztv.cs b/src/NzbDrone.Core.Test/Datastore/Migration/074_disable_eztv.cs new file mode 100644 index 000000000..455bba398 --- /dev/null +++ b/src/NzbDrone.Core.Test/Datastore/Migration/074_disable_eztv.cs @@ -0,0 +1,66 @@ +using System; +using System.Linq; +using FluentAssertions; +using FluentMigrator; +using NUnit.Framework; +using NzbDrone.Core.Indexers; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.Datastore.Migration +{ + [TestFixture] + public class disable_eztv : MigrationTest + { + [Test] + public void should_disable_rss_for_eztv() + { + WithTestDb(c => + { + InsertIndexer(c, "https://www.ezrss.it/"); + }); + + var indexers = Mocker.Resolve().All().ToList(); + indexers.First().EnableRss.Should().BeFalse(); + } + + [Test] + public void should_disable_search_for_eztv() + { + WithTestDb(c => + { + InsertIndexer(c, "https://www.ezrss.it/"); + }); + + var indexers = Mocker.Resolve().All().ToList(); + indexers.First().EnableSearch.Should().BeFalse(); + } + + [Test] + public void should_not_disable_if_using_custom_url() + { + WithTestDb(c => + { + InsertIndexer(c, "https://ezrss.sonarr.tv/"); + }); + + var indexers = Mocker.Resolve().All().ToList(); + indexers.First().EnableRss.Should().BeTrue(); + indexers.First().EnableSearch.Should().BeTrue(); + } + + private void InsertIndexer(MigrationBase migrationBase, string url) + { + migrationBase.Insert.IntoTable("Indexers").Row(new + { + Name = "eztv", + Implementation = "Eztv", + Settings = String.Format(@"{{ + ""baseUrl"": ""{0}"" + }}", url), + ConfigContract = "EztvSettings", + EnableRss = 1, + EnableSearch = 1 + }); + } + } +} diff --git a/src/NzbDrone.Core.Test/IndexerTests/EztvTests/EztvFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/EztvTests/EztvFixture.cs index ac350320f..ad407a447 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/EztvTests/EztvFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/EztvTests/EztvFixture.cs @@ -20,7 +20,7 @@ public void Setup() Subject.Definition = new IndexerDefinition() { Name = "Eztv", - Settings = new EztvSettings() + Settings = new EztvSettings { BaseUrl = "https://www.ezrss.it/" } }; } diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 1074dbc46..3653dfc5b 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -117,6 +117,7 @@ + diff --git a/src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs b/src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs new file mode 100644 index 000000000..c090df19b --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs @@ -0,0 +1,14 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(74)] + public class disable_eztv : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Execute.Sql("UPDATE Indexers SET EnableRss = 0, EnableSearch = 0 WHERE Implementation = 'Eztv' AND Settings LIKE '%ezrss.it%'"); + } + } +} diff --git a/src/NzbDrone.Core/Indexers/Eztv/EztvSettings.cs b/src/NzbDrone.Core/Indexers/Eztv/EztvSettings.cs index a0769d65f..64be09f2f 100644 --- a/src/NzbDrone.Core/Indexers/Eztv/EztvSettings.cs +++ b/src/NzbDrone.Core/Indexers/Eztv/EztvSettings.cs @@ -21,10 +21,10 @@ public class EztvSettings : IProviderConfig public EztvSettings() { - BaseUrl = "https://www.ezrss.it/"; + BaseUrl = ""; } - [FieldDefinition(0, Label = "Website URL")] + [FieldDefinition(0, Label = "Website URL", HelpText = "Enter to URL to an EZTV compatible RSS feed")] public String BaseUrl { get; set; } public ValidationResult Validate() diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index b3047621c..dcf6713a4 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -232,6 +232,7 @@ +