From 767586304a35b40700228762794158fe30cd9e90 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 22 Nov 2013 09:17:04 -0800 Subject: [PATCH] Never allow empty episode formats to be saved --- src/NzbDrone.Api/Config/NamingModule.cs | 8 ++------ src/NzbDrone.Integration.Test/NamingConfigTests.cs | 6 ++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Api/Config/NamingModule.cs b/src/NzbDrone.Api/Config/NamingModule.cs index 3e6b8efe0..1f0b39fac 100644 --- a/src/NzbDrone.Api/Config/NamingModule.cs +++ b/src/NzbDrone.Api/Config/NamingModule.cs @@ -37,12 +37,8 @@ public NamingModule(INamingConfigService namingConfigService, Get["/samples"] = x => GetExamples(this.Bind()); SharedValidator.RuleFor(c => c.MultiEpisodeStyle).InclusiveBetween(0, 3); - - SharedValidator.When(spec => spec.RenameEpisodes, () => - { - SharedValidator.RuleFor(c => c.StandardEpisodeFormat).ValidEpisodeFormat(); - SharedValidator.RuleFor(c => c.DailyEpisodeFormat).ValidDailyEpisodeFormat(); - }); + SharedValidator.RuleFor(c => c.StandardEpisodeFormat).ValidEpisodeFormat(); + SharedValidator.RuleFor(c => c.DailyEpisodeFormat).ValidDailyEpisodeFormat(); } private void UpdateNamingConfig(NamingConfigResource resource) diff --git a/src/NzbDrone.Integration.Test/NamingConfigTests.cs b/src/NzbDrone.Integration.Test/NamingConfigTests.cs index eed8373ba..3f351bb68 100644 --- a/src/NzbDrone.Integration.Test/NamingConfigTests.cs +++ b/src/NzbDrone.Integration.Test/NamingConfigTests.cs @@ -81,10 +81,8 @@ public void should_not_require_format_when_rename_episodes_is_false() config.StandardEpisodeFormat = ""; config.DailyEpisodeFormat = ""; - var result = NamingConfig.Put(config); - result.RenameEpisodes.Should().BeFalse(); - result.StandardEpisodeFormat.Should().Be(config.StandardEpisodeFormat); - result.DailyEpisodeFormat.Should().Be(config.DailyEpisodeFormat); + var errors = NamingConfig.InvalidPut(config); + errors.Should().NotBeEmpty(); } [Test]