mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
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:
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user