Fix Snowplow spec helper for Ruby 2.6.6
What does this MR do?
@splattael experienced issues with the Snowplow Spec helper in #259282 (comment 425243784) with Ruby 2.6. Thanks @syasonik for the pragmatic idea how to fix it for now
With Ruby 2.6 using **kwargs
here will not work because it would be an
empty hash that we then expect to be submitted to
Gitlab::Tracking#event
.
An example when using expect_snowplow_event
:
expect_snowplow_event(
category: 'cluster:services:prometheus',
action: 'enabled_manual_prometheus'
)
Error:
Gitlab::Tracking received :event with unexpected arguments
expected: ("cluster:services:prometheus", "enabled_manual_prometheus", {})
got: ("cluster:services:prometheus", "enabled_manual_prometheus") (1 time)
This has not been an issue so far because the other specs we migrated
always provided additional kwargs
.
To prevent this, we only expect the **kwargs
parameter when it exists.
However, this will get fixed with Ruby 2.7 and we can remove the
condition again.
See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ "Double splat with an empty hash (**{}) passes no arguments" for more information.
To revert the change again after migrating to Ruby 2.7, there is #263430 (closed)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team