#17238: A module's default route URL should be a valid URL without the need for further escaping.

- adding a Path property on ExtensionDescriptor that's used in place of the area name for default route URLs
- the Path property if not set will be the Name if it's a valid URL segment, otherwise it will be the Id
- if an *invalid* Path is given an error will be logged and the extension will not be loaded

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2011-02-01 15:56:12 -08:00
parent 4c25a7cc29
commit 1b82ea74f9
11 changed files with 108 additions and 20 deletions

View File

@@ -48,12 +48,15 @@ namespace Orchard.Tests.Environment.Extensions {
}
[Test]
public void NamesFromFoldersWithModuleTxtShouldBeListed() {
public void IdsFromFoldersWithModuleTxtShouldBeListed() {
IExtensionFolders folders = new ModuleFolders(new[] { _tempFolderName }, new StubCacheManager(), new StubWebSiteFolder());
var names = folders.AvailableExtensions().Select(d => d.Id);
Assert.That(names.Count(), Is.EqualTo(2));
Assert.That(names, Has.Some.EqualTo("Sample1"));
Assert.That(names, Has.Some.EqualTo("Sample3"));
var ids = folders.AvailableExtensions().Select(d => d.Id);
Assert.That(ids.Count(), Is.EqualTo(5));
Assert.That(ids, Has.Some.EqualTo("Sample1")); // Sample1 - obviously
Assert.That(ids, Has.Some.EqualTo("Sample3")); // Sample3
Assert.That(ids, Has.Some.EqualTo("Sample4")); // Sample4
Assert.That(ids, Has.Some.EqualTo("Sample6")); // Sample6
Assert.That(ids, Has.Some.EqualTo("Sample7")); // Sample7
}
[Test]
@@ -61,7 +64,31 @@ namespace Orchard.Tests.Environment.Extensions {
IExtensionFolders folders = new ModuleFolders(new[] { _tempFolderName }, new StubCacheManager(), new StubWebSiteFolder());
var sample1 = folders.AvailableExtensions().Single(d => d.Id == "Sample1");
Assert.That(sample1.Id, Is.Not.Empty);
Assert.That(sample1.Author, Is.EqualTo("Bertrand Le Roy"));
Assert.That(sample1.Author, Is.EqualTo("Bertrand Le Roy")); // Sample1
}
}
[Test]
public void NamesFromFoldersWithModuleTxtShouldFallBackToIdIfNotGiven() {
IExtensionFolders folders = new ModuleFolders(new[] { _tempFolderName }, new StubCacheManager(), new StubWebSiteFolder());
var names = folders.AvailableExtensions().Select(d => d.Name);
Assert.That(names.Count(), Is.EqualTo(5));
Assert.That(names, Has.Some.EqualTo("Le plug-in français")); // Sample1
Assert.That(names, Has.Some.EqualTo("This is another test.txt")); // Sample3
Assert.That(names, Has.Some.EqualTo("Sample4")); // Sample4
Assert.That(names, Has.Some.EqualTo("SampleSix")); // Sample6
Assert.That(names, Has.Some.EqualTo("Sample7")); // Sample7
}
[Test]
public void PathsFromFoldersWithModuleTxtShouldFallBackAppropriatelyIfNotGiven() {
IExtensionFolders folders = new ModuleFolders(new[] { _tempFolderName }, new StubCacheManager(), new StubWebSiteFolder());
var paths = folders.AvailableExtensions().Select(d => d.Path);
Assert.That(paths.Count(), Is.EqualTo(5));
Assert.That(paths, Has.Some.EqualTo("Sample1")); // Sample1 - Id, Name invalid URL segment
Assert.That(paths, Has.Some.EqualTo("Sample3")); // Sample3 - Id, Name invalid URL segment
Assert.That(paths, Has.Some.EqualTo("ThisIs.Sample4")); // Sample4 - Path
Assert.That(paths, Has.Some.EqualTo("SampleSix")); // Sample6 - Name, no Path
Assert.That(paths, Has.Some.EqualTo("Sample7")); // Sample7 - Id, no Name or Path
}
}
}

View File

@@ -1 +1,2 @@
Name: This is another test.txt
Description: But not really.

View File

@@ -0,0 +1,2 @@
Path: ThisIs.Sample4
Author: Bertrand Le Roy

View File

@@ -0,0 +1,3 @@
Name: AnotherSample
Path: Sample 5
Author: Some One

View File

@@ -0,0 +1,2 @@
Name: SampleSix
Author: Some One