Skip to content

Commit

Permalink
TASK: Turn full discard also into a no-op if there are no changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 28, 2024
1 parent f0e088e commit 5e12a48
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,26 @@ Feature: Workspace discarding - basic functionality
| newContentStreamId | "user-cs-two-discarded" |

Then workspaces live,user-ws-one,user-ws-two have status UP_TO_DATE

Scenario: Discard is a no-op if there are no changes (and the workspace is outdated)
And the command SetNodeProperties is executed with payload:
| Key | Value |
| workspaceName | "live" |
| nodeAggregateId | "nody-mc-nodeface" |
| originDimensionSpacePoint | {} |
| propertyValues | {"text": "Modified in live workspace"} |

And the command DiscardWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-two-discarded" |
Then workspaces user-test has status OUTDATED

Then I expect exactly 1 events to be published on stream with prefix "Workspace:user-test"

And I am in workspace "user-test" and dimension space point {}
Then I expect node aggregate identifier "nody-mc-nodeface" to lead to node user-cs-identifier;nody-mc-nodeface;{}
And I expect this node to have the following properties:
| Key | Value |
| text | "Original" |
Then I expect the content stream "user-cs-two-discarded" to not exist
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,11 @@ private function handleDiscardWorkspace(
$workspace = $this->requireWorkspace($command->workspaceName, $commandHandlingDependencies);
$baseWorkspace = $this->requireBaseWorkspace($workspace, $commandHandlingDependencies);

return $this->discardWorkspace(
if (!$this->hasEventsInContentStreamExceptForking(ContentStreamEventStreamName::fromContentStreamId($workspace->currentContentStreamId))) {
return;
}

yield from $this->discardWorkspace(
$workspace,
$baseWorkspace,
$command->newContentStreamId,
Expand All @@ -706,7 +710,6 @@ private function discardWorkspace(
ContentStreamId $newContentStream,
CommandHandlingDependencies $commandHandlingDependencies
): \Generator {
// todo only discard if changes, needs new changes flag on the Workspace model
yield $this->forkContentStream(
$newContentStream,
$baseWorkspace->currentContentStreamId,
Expand Down

0 comments on commit 5e12a48

Please sign in to comment.