Prevent empty content items to be indexed (menu item)

Added an IsDirty property to IIndexDocument
Once handlers have contributed to index information, if a document is not dirty, don't add it to the index

--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-06-08 11:42:32 -07:00
parent abf8357f1b
commit 9574529898
4 changed files with 59 additions and 7 deletions

View File

@@ -216,5 +216,38 @@ namespace Orchard.Tests.Indexing {
_provider.Store("default", _provider.New(1).Add("body", null));
Assert.That(_provider.IsEmpty("default"), Is.False);
}
[Test]
public void IsDirtyShouldBeFalseForNewDocuments() {
IIndexDocument doc = _provider.New(1);
Assert.That(doc.IsDirty, Is.False);
}
[Test]
public void IsDirtyShouldBeTrueWhenIndexIsModified() {
IIndexDocument doc;
doc = _provider.New(1);
doc.Add("foo", "value");
Assert.That(doc.IsDirty, Is.True);
doc = _provider.New(1);
doc.Add("foo", false);
Assert.That(doc.IsDirty, Is.True);
doc = _provider.New(1);
doc.Add("foo", (float)1.0);
Assert.That(doc.IsDirty, Is.True);
doc = _provider.New(1);
doc.Add("foo", 1);
Assert.That(doc.IsDirty, Is.True);
doc = _provider.New(1);
doc.Add("foo", DateTime.Now);
Assert.That(doc.IsDirty, Is.True);
}
}
}