Browse Source

Fix for draft version.

pull/636/head
Sebastian 5 years ago
parent
commit
5366fbff7d
  1. 34
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository_SnapshotStore.cs
  2. 2
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj
  3. 2
      backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj
  4. 4
      backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj
  5. 2
      backend/src/Squidex/Squidex.csproj
  6. 36
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs

34
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository_SnapshotStore.cs

@ -93,36 +93,32 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
private async Task UpsertDraftContentAsync(ContentDomainObject.State value, long oldVersion, long newVersion) private async Task UpsertDraftContentAsync(ContentDomainObject.State value, long oldVersion, long newVersion)
{ {
var content = SimpleMapper.Map(value, new MongoContentEntity var content = CreateContent(value, value.Data, newVersion);
{
IndexedAppId = value.AppId.Id,
IndexedSchemaId = value.SchemaId.Id,
Version = newVersion
});
content.DocumentId = value.UniqueId;
content.ScheduledAt = value.ScheduleJob?.DueTime;
content.ScheduleJob = value.ScheduleJob;
content.NewStatus = value.NewStatus;
await collectionAll.UpsertVersionedAsync(content.DocumentId, oldVersion, content); await collectionAll.UpsertVersionedAsync(content.DocumentId, oldVersion, content);
} }
private async Task UpsertPublishedContentAsync(ContentDomainObject.State value, long oldVersion, long newVersion) private async Task UpsertPublishedContentAsync(ContentDomainObject.State value, long oldVersion, long newVersion)
{ {
var content = SimpleMapper.Map(value, new MongoContentEntity var content = CreateContent(value, value.CurrentVersion.Data, newVersion);
{
IndexedAppId = value.AppId.Id, await collectionPublished.UpsertVersionedAsync(content.DocumentId, oldVersion, content);
IndexedSchemaId = value.SchemaId.Id, }
Version = newVersion
}); private static MongoContentEntity CreateContent(ContentDomainObject.State value, ContentData data, long newVersion)
{
var content = SimpleMapper.Map(value, new MongoContentEntity());
content.Data = data;
content.DocumentId = value.UniqueId; content.DocumentId = value.UniqueId;
content.IndexedAppId = value.AppId.Id;
content.IndexedSchemaId = value.SchemaId.Id;
content.NewStatus = null;
content.ScheduledAt = null; content.ScheduledAt = null;
content.ScheduleJob = null; content.ScheduleJob = null;
content.NewStatus = null; content.Version = newVersion;
await collectionPublished.UpsertVersionedAsync(content.DocumentId, oldVersion, content); return content;
} }
} }
} }

2
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj

@ -17,7 +17,7 @@
<ProjectReference Include="..\Squidex.Domain.Apps.Entities\Squidex.Domain.Apps.Entities.csproj" /> <ProjectReference Include="..\Squidex.Domain.Apps.Entities\Squidex.Domain.Apps.Entities.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.11.5" /> <PackageReference Include="MongoDB.Driver" Version="2.11.6" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />

2
backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj

@ -20,7 +20,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="IdentityServer4" Version="4.1.1" /> <PackageReference Include="IdentityServer4" Version="4.1.1" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" /> <PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.11.5" /> <PackageReference Include="MongoDB.Driver" Version="2.11.6" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" /> <PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />

4
backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj

@ -13,8 +13,8 @@
<ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" /> <ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.11.5" /> <PackageReference Include="MongoDB.Driver" Version="2.11.6" />
<PackageReference Include="MongoDB.Driver.GridFS" Version="2.11.5" /> <PackageReference Include="MongoDB.Driver.GridFS" Version="2.11.6" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="5.0.0" /> <PackageReference Include="System.Threading.Tasks.Dataflow" Version="5.0.0" />

2
backend/src/Squidex/Squidex.csproj

@ -48,7 +48,7 @@
<PackageReference Include="Microsoft.Orleans.Core" Version="3.4.0" /> <PackageReference Include="Microsoft.Orleans.Core" Version="3.4.0" />
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="3.4.0" /> <PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="3.4.0" />
<PackageReference Include="Microsoft.Orleans.OrleansRuntime" Version="3.4.0" /> <PackageReference Include="Microsoft.Orleans.OrleansRuntime" Version="3.4.0" />
<PackageReference Include="MongoDB.Driver" Version="2.11.5" /> <PackageReference Include="MongoDB.Driver" Version="2.11.6" />
<PackageReference Include="Namotion.Reflection" Version="1.0.15" /> <PackageReference Include="Namotion.Reflection" Version="1.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NJsonSchema" Version="10.3.2" /> <PackageReference Include="NJsonSchema" Version="10.3.2" />

36
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs

@ -415,6 +415,42 @@ namespace TestSuite.ApiTests
} }
} }
[Fact]
public async Task Should_create_draft_version()
{
TestEntity content = null;
try
{
// STEP 1: Create a new item.
content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }, true);
// STEP 2: Create draft.
content = await _.Contents.CreateDraftAsync(content.Id);
// STEP 3: Update the item and ensure that the data has not changed.
await _.Contents.PatchAsync(content.Id, new TestEntityData { Number = 2 });
var updated = await _.Contents.GetAsync(content.Id);
Assert.Equal(1, updated.Data.Number);
// STEP 4: Get the unpublished version
var unpublished = await _.Contents.GetAsync(content.Id, QueryContext.Default.Unpublished());
Assert.Equal(2, unpublished.Data.Number);
}
finally
{
if (content != null)
{
await _.Contents.DeleteAsync(content.Id);
}
}
}
[Fact] [Fact]
public async Task Should_delete_item() public async Task Should_delete_item()
{ {

Loading…
Cancel
Save