Skip to content

Commit

Permalink
Merge pull request #201 from sergeyshushlyapin/feature/200-fix-field-…
Browse files Browse the repository at this point in the history
…version-saving

Save field value in a proper version
  • Loading branch information
sshushliapin authored Oct 25, 2018
2 parents 63fb417 + 63b5e0c commit c363714
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 26 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
1.7.1
1.7.3
* [FIX] #200: Unable to set to the ValidFrom of the latest version

1.7.2
* [FIX] #195: Content search config in SC9 uses incorrect class name

1.7.1
* [FIX] #191: Added references to Sitecore pipelines necessary for testing updates to layout fields with Sitecore 9 (thanks to [@AndyButland](https://github.com/AndyButland))

1.7.0
Expand Down
6 changes: 3 additions & 3 deletions src/AssemblyVersionInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;

[assembly: AssemblyVersion("1.7.1.0")]
[assembly: AssemblyFileVersion("1.7.1.0")]
[assembly: AssemblyInformationalVersion("1.7.1")]
[assembly: AssemblyVersion("1.7.3.0")]
[assembly: AssemblyFileVersion("1.7.3.0")]
[assembly: AssemblyInformationalVersion("1.7.3")]
7 changes: 3 additions & 4 deletions src/Sitecore.FakeDb/Data/DataProviders/FakeDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,9 @@ public override bool SaveItem(ItemDefinition itemDefinition, ItemChanges changes
}
else
{
item.Fields.Add(new DbField(change.FieldID)
{
Value = change.Value
});
var newField = new DbField(change.FieldID);
newField.SetValue(change.Language.Name, change.Version.Number, change.Value);
item.Fields.Add(newField);
}
}
}
Expand Down
69 changes: 51 additions & 18 deletions test/Sitecore.FakeDb.Tests/DbTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
using Sitecore.Security.Accounts;
using Sitecore.SecurityModel;
using Xunit;
using Version = Sitecore.Data.Version;

using Version = Sitecore.Data.Version;

[Trait("Category", "RequireLicense")]
public class DbTest
{
Expand Down Expand Up @@ -1813,22 +1813,55 @@ public void ShouldCreateDbWithSpecificLanguages(string database)

[Fact]
public void ShouldNotFailIfLanguageSwitcherDisposedElsewhere()
{
using (new Db()
.WithLanguages(Language.Parse("da")))
{
Switcher<DbLanguages>.Exit();
}
}

[Fact]
public void ShouldAddWildcard()
{
using (var db = new Db())
{
var item = db.GetItem("/sitecore/content/");
item.Add("*", new TemplateID(TemplateIDs.Folder));
}
{
using (new Db()
.WithLanguages(Language.Parse("da")))
{
Switcher<DbLanguages>.Exit();
}
}

[Fact]
public void ShouldAddWildcard()
{
using (var db = new Db())
{
var item = db.GetItem("/sitecore/content/");
item.Add("*", new TemplateID(TemplateIDs.Folder));
}
}

[Fact]
public void EditContextSavesFieldValueOfProperVersion()
{
var expectedV1 = DateTime.MinValue;
var expectedV2 = new DateTime(2018, 10, 25, 15, 14, 00, DateTimeKind.Utc);
using (var db = new Db
{
new DbItem("Home")
{
new DbField("Text")
{
{"en", 1, ""},
{"en", 2, ""}
}
}
})
{
var homeV2 = db.GetItem("/sitecore/content/Home", "en", 2);
using (new EditContext(homeV2))
{
homeV2.Publishing.ValidFrom = expectedV2;
}
var homeV1 = db.GetItem("/sitecore/content/Home", "en", 1);
homeV2 = db.GetItem("/sitecore/content/Home", "en", 2);

var actualV1 = homeV1.Publishing.ValidFrom;
var actualV2 = homeV2.Publishing.ValidFrom;

Assert.Equal(expectedV1, actualV1);
Assert.Equal(expectedV2, actualV2);
}
}
}
}

0 comments on commit c363714

Please sign in to comment.