Skip to content

Commit

Permalink
Merge pull request #50 from dolittle/fix-apply-public
Browse files Browse the repository at this point in the history
Setting public to true when applying public events
  • Loading branch information
jakhog authored May 18, 2021
2 parents d71b243 + 77bc706 commit 4bebe63
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Source/aggregates/AggregateRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class AggregateRoot {
*/
applyPublic(event: any, eventType?: EventType): void {
eventType = eventType || EventType.unspecified;
this.applyImplementation(event, eventType, false);
this.applyImplementation(event, eventType, true);
}

/**
Expand Down
16 changes: 16 additions & 0 deletions Source/aggregates/for_AggregateRoot/when_applying_public_events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Dolittle. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import { EventSourceId, EventType, EventTypeId, Generation } from '@dolittle/sdk.events';
import { AggregateRoot } from '../AggregateRoot';

describe('when applying public events', () => {
const event = { something: 42 };

const eventType = new EventType(EventTypeId.from('7b078c73-5843-434e-9b4d-ecae4e91469e'), Generation.first);
const aggregateRoot = new AggregateRoot(EventSourceId.from('8f58f9d5-fded-49f3-8334-a3c1f447d4da'));
aggregateRoot.applyPublic(event, eventType);

it('should have one event applied', () => aggregateRoot.appliedEvents.length.should.equal(1));
it('should have the event applied be public', () => aggregateRoot.appliedEvents[0].isPublic.should.be.true);
});
6 changes: 0 additions & 6 deletions Source/aggregates/for_Dummy/when_nothing.ts

This file was deleted.

0 comments on commit 4bebe63

Please sign in to comment.