Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-30 15:09:03 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-30 15:09:03 +0300
commitb0139a824fba85e5b71e69f2c99d423700ff76cc (patch)
tree0be37882f9bdaf64d6bc8bcd486d0e1066124513 /doc/development/event_store.md
parent312ac59328577a230a049eb71c56f648508d209f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/event_store.md')
-rw-r--r--doc/development/event_store.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/doc/development/event_store.md b/doc/development/event_store.md
index fa7208ead04..ffde51216cf 100644
--- a/doc/development/event_store.md
+++ b/doc/development/event_store.md
@@ -293,6 +293,8 @@ in the `handle_event` method of the subscriber worker.
## Testing
+### Testing the publisher
+
The publisher's responsibility is to ensure that the event is published correctly.
To test that an event has been published correctly, we can use the RSpec matcher `:publish_event`:
@@ -308,6 +310,25 @@ it 'publishes a ProjectDeleted event with project id and namespace id' do
end
```
+It is also possible to compose matchers inside the `:publish_event` matcher.
+This could be useful when we want to assert that an event is created with a certain kind of value,
+but we do not know the value in advance. An example of this is when publishing an event
+after creating a new record.
+
+```ruby
+it 'publishes a ProjectCreatedEvent with project id and namespace id' do
+ # The project ID will only be generated when the `create_project`
+ # is called in the expect block.
+ expected_data = { project_id: kind_of(Numeric), namespace_id: group_id }
+
+ expect { create_project(user, name: 'Project', path: 'project', namespace_id: group_id) }
+ .to publish_event(Projects::ProjectCreatedEvent)
+ .with(expected_data)
+end
+```
+
+### Testing the subscriber
+
The subscriber must ensure that a published event can be consumed correctly. For this purpose
we have added helpers and shared examples to standardize the way we test subscribers: