From 6c22a5ffdbd613b8df647412fe31e853c4f47b83 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Fri, 6 Feb 2015 21:18:13 +0100 Subject: [PATCH] Fixed: Health Checks on mono now shows correct wiki links. --- .../HealthCheck/HealthCheckFixture.cs | 24 +++++++++++++++++++ .../NzbDrone.Core.Test.csproj | 1 + src/NzbDrone.Core/HealthCheck/HealthCheck.cs | 15 ++++++++---- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/NzbDrone.Core.Test/HealthCheck/HealthCheckFixture.cs diff --git a/src/NzbDrone.Core.Test/HealthCheck/HealthCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/HealthCheckFixture.cs new file mode 100644 index 000000000..f7faaea38 --- /dev/null +++ b/src/NzbDrone.Core.Test/HealthCheck/HealthCheckFixture.cs @@ -0,0 +1,24 @@ +using System; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.HealthCheck; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.HealthCheck +{ + [TestFixture] + public class HealthCheckFixture : CoreTest + { + private const string WikiRoot = "https://github.com/Sonarr/Sonarr/wiki/"; + + [TestCase("I blew up because of some weird user mistake", null, WikiRoot + "Health-checks#i-blew-up-because-of-some-weird-user-mistake")] + [TestCase("I blew up because of some weird user mistake", "#my-health-check", WikiRoot + "Health-checks#my-health-check")] + [TestCase("I blew up because of some weird user mistake", "Custom-Page#my-health-check", WikiRoot + "Custom-Page#my-health-check")] + public void should_format_wiki_url(string message, string wikiFragment, string expectedUrl) + { + var subject = new NzbDrone.Core.HealthCheck.HealthCheck(typeof(HealthCheckBase), HealthCheckResult.Warning, message, wikiFragment); + + subject.WikiUrl.Should().Be(expectedUrl); + } + } +} diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index d61e4cadb..9bf60de39 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -178,6 +178,7 @@ + diff --git a/src/NzbDrone.Core/HealthCheck/HealthCheck.cs b/src/NzbDrone.Core/HealthCheck/HealthCheck.cs index 31f0a3035..e720aca8f 100644 --- a/src/NzbDrone.Core/HealthCheck/HealthCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/HealthCheck.cs @@ -34,10 +34,17 @@ namespace NzbDrone.Core.HealthCheck private static Uri MakeWikiUrl(String fragment) { - var rootUri = new Uri("https://github.com/NzbDrone/NzbDrone/wiki/Health-checks"); - var fragmentUri = new Uri(fragment, UriKind.Relative); - - return new Uri(rootUri, fragmentUri); + var rootUri = new Uri("https://github.com/Sonarr/Sonarr/wiki/Health-checks"); + if (fragment.StartsWith("#")) + { // Mono doesn't understand # and generates a different url than windows. + return new Uri(rootUri + fragment); + } + else + { + var fragmentUri = new Uri(fragment, UriKind.Relative); + + return new Uri(rootUri, fragmentUri); + } } }