Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="DamianPutSnapshot.cs" company="Hibernating Rhinos LTD"> | ||
// Copyright (c) Hibernating Rhinos LTD. All rights reserved. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
using Raven.Abstractions.Data; | ||
using Raven.Client; | ||
using Raven.Client.Embedded; | ||
using Raven.Database.Plugins; | ||
using Raven.Json.Linq; | ||
using Xunit; | ||
|
||
namespace Raven.Tests.Bugs | ||
{ | ||
public class DamianPutSnapshot : RavenTest | ||
{ | ||
[Fact] | ||
public void Cannot_modify_snapshot() | ||
{ | ||
using (var documentStore = NewDocumentStore()) | ||
{ | ||
documentStore.Initialize(); | ||
documentStore.DocumentDatabase.PutTriggers.Add(new PutTrigger {Database = documentStore.DocumentDatabase}); | ||
using (IDocumentSession session = documentStore.OpenSession()) | ||
{ | ||
session.Store(new Doc {Id = "DocId1", Name = "Name1"}); | ||
session.SaveChanges(); | ||
} | ||
} | ||
} | ||
|
||
public class Doc | ||
{ | ||
public string Id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
public class PutTrigger : AbstractPutTrigger | ||
{ | ||
public override void OnPut(string key, | ||
RavenJObject document, | ||
RavenJObject metadata, | ||
TransactionInformation transactionInformation) | ||
{ | ||
using (Database.DisableAllTriggersForCurrentThread()) | ||
{ | ||
var revisionCopy = new RavenJObject(document); | ||
Database.Put("CopyOfDoc", null, revisionCopy, new RavenJObject(metadata), transactionInformation); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters