diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /doc/development/gotchas.md | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'doc/development/gotchas.md')
-rw-r--r-- | doc/development/gotchas.md | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/doc/development/gotchas.md b/doc/development/gotchas.md index 6dff9deb59d..f7b44e74c17 100644 --- a/doc/development/gotchas.md +++ b/doc/development/gotchas.md @@ -106,7 +106,7 @@ end Using `any_instance` to stub a method (elasticsearch_indexing) that has been defined on a prepended module (EE::ApplicationSetting) is not supported. ``` -### Alternative: `expect_next_instance_of` or `allow_next_instance_of` +### Alternative: `expect_next_instance_of`, `allow_next_instance_of`, `expect_next_found_instance_of` or `allow_next_found_instance_of` Instead of writing: @@ -130,8 +130,21 @@ end allow_next_instance_of(Project) do |project| allow(project).to receive(:add_import_job) end + +# Do this: +expect_next_found_instance_of(Project) do |project| + expect(project).to receive(:add_import_job) +end + +# Do this: +allow_next_found_instance_of(Project) do |project| + allow(project).to receive(:add_import_job) +end ``` +_**Note:** Since Active Record is not calling the `.new` method on model classes to instantiate the objects, +you should use `expect_next_found_instance_of` or `allow_next_found_instance_of` mock helpers to setup mock on objects returned by Active Record query & finder methods._ + If we also want to initialize the instance with some particular arguments, we could also pass it like: |