#17111: Correcting fix. Fixing specflows.

--HG--
branch : dev
This commit is contained in:
andrerod 2011-02-09 00:07:12 -08:00
parent 4eff84d2f7
commit 5d55e95506
3 changed files with 17 additions and 2 deletions

View File

@ -80,6 +80,22 @@ namespace Orchard.Core.Tests.Routable.Services {
Assert.That(thing.Slug, Is.EqualTo("please-do-not-use-any-of-the-following-characters-in-your-slugs"));
}
[Test]
public void SpacesSlugShouldBeTreatedAsEmpty() {
var contentManager = _container.Resolve<IContentManager>();
var thing = contentManager.Create<Thing>("thing", t => {
t.As<RoutePart>().Record = new RoutePartRecord();
t.Title = "My Title";
t.Slug = " ";
});
_routableService.FillSlugFromTitle(thing.As<RoutePart>());
Assert.That(thing.Slug, Is.EqualTo("my-title"));
}
[Test]
public void SlashInSlugIsAllowed() {
Assert.That(_routableService.IsSlugValid("some/page"), Is.True);

View File

@ -47,7 +47,7 @@ namespace Orchard.Core.Routable.Services {
}
public void FillSlugFromTitle<TModel>(TModel model) where TModel : IRoutableAspect {
if (!string.IsNullOrEmpty(model.Slug) || string.IsNullOrEmpty(model.Title))
if ((model.Slug != null && !string.IsNullOrEmpty(model.Slug.Trim())) || string.IsNullOrEmpty(model.Title))
return;
FillSlugContext slugContext = new FillSlugContext(model.Title);

View File

@ -10,7 +10,6 @@ namespace Orchard.Core.Routable.ViewModels {
[StringLength(1024)]
public string Title { get; set; }
[StringLength(1024)]
[Required(AllowEmptyStrings = false)]
public string Slug { get; set; }
public int? ContainerId { get; set; }
public bool PromoteToHomePage { get; set; }