Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2c0ec5e5
Commit
2c0ec5e5
authored
Jan 22, 2021
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add standard_context to snowplow test helper
parent
3019860b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
5 deletions
+16
-5
doc/development/testing_guide/best_practices.md
doc/development/testing_guide/best_practices.md
+3
-1
ee/spec/services/epics/issue_promote_service_spec.rb
ee/spec/services/epics/issue_promote_service_spec.rb
+3
-3
spec/support/helpers/snowplow_helpers.rb
spec/support/helpers/snowplow_helpers.rb
+9
-1
spec/support/snowplow.rb
spec/support/snowplow.rb
+1
-0
No files found.
doc/development/testing_guide/best_practices.md
View file @
2c0ec5e5
...
...
@@ -767,12 +767,14 @@ describe '#show', :snowplow do
expect_snowplow_event
(
category:
'Experiment'
,
action:
'start'
,
standard_context:
{
namespace:
group
,
project:
project
}
)
expect_snowplow_event
(
category:
'Experiment'
,
action:
'sent'
,
property:
'property'
,
label:
'label'
label:
'label'
,
standard_context:
{
namespace:
group
,
project:
project
}
)
end
end
...
...
ee/spec/services/epics/issue_promote_service_spec.rb
View file @
2c0ec5e5
...
...
@@ -65,7 +65,7 @@ RSpec.describe Epics::IssuePromoteService, :aggregate_failures do
subject
.
execute
(
issue
)
expect_snowplow_event
(
category:
'epics'
,
action:
'promote'
,
property:
'issue_id'
,
value:
issue
.
id
,
standard_context:
kind_of
(
Gitlab
::
Tracking
::
StandardContext
)
)
standard_context:
{
namespace:
group
,
project:
project
}
)
end
it
'creates a new epic with correct attributes'
do
...
...
@@ -201,7 +201,7 @@ RSpec.describe Epics::IssuePromoteService, :aggregate_failures do
expect
(
epic
.
notes
.
where
(
discussion_id:
discussion
.
discussion_id
).
count
).
to
eq
(
0
)
expect
(
issue
.
notes
.
where
(
discussion_id:
discussion
.
discussion_id
).
count
).
to
eq
(
1
)
expect_snowplow_event
(
category:
'epics'
,
action:
'promote'
,
property:
'issue_id'
,
value:
issue
.
id
,
standard_context:
kind_of
(
Gitlab
::
Tracking
::
StandardContext
)
)
standard_context:
{
namespace:
group
,
project:
project
}
)
end
it
'copies note attachments'
do
...
...
@@ -211,7 +211,7 @@ RSpec.describe Epics::IssuePromoteService, :aggregate_failures do
expect
(
epic
.
notes
.
user
.
first
.
attachment
).
to
be_kind_of
(
AttachmentUploader
)
expect_snowplow_event
(
category:
'epics'
,
action:
'promote'
,
property:
'issue_id'
,
value:
issue
.
id
,
standard_context:
kind_of
(
Gitlab
::
Tracking
::
StandardContext
)
)
standard_context:
{
namespace:
group
,
project:
project
}
)
end
end
...
...
spec/support/helpers/snowplow_helpers.rb
View file @
2c0ec5e5
...
...
@@ -46,7 +46,7 @@ module SnowplowHelpers
# }
# ]
# )
def
expect_snowplow_event
(
category
:,
action
:,
context:
nil
,
**
kwargs
)
def
expect_snowplow_event
(
category
:,
action
:,
context:
nil
,
standard_context:
nil
,
**
kwargs
)
if
context
kwargs
[
:context
]
=
[]
context
.
each
do
|
c
|
...
...
@@ -56,6 +56,14 @@ module SnowplowHelpers
end
end
if
standard_context
expect
(
Gitlab
::
Tracking
::
StandardContext
)
.
to
have_received
(
:new
)
.
with
(
**
standard_context
)
kwargs
[
:standard_context
]
=
an_instance_of
(
Gitlab
::
Tracking
::
StandardContext
)
end
expect
(
Gitlab
::
Tracking
).
to
have_received
(
:event
)
# rubocop:disable RSpec/ExpectGitlabTracking
.
with
(
category
,
action
,
**
kwargs
).
at_least
(
:once
)
end
...
...
spec/support/snowplow.rb
View file @
2c0ec5e5
...
...
@@ -18,6 +18,7 @@ RSpec.configure do |config|
stub_application_setting
(
snowplow_enabled:
true
)
allow
(
SnowplowTracker
::
SelfDescribingJson
).
to
receive
(
:new
).
and_call_original
allow
(
Gitlab
::
Tracking
::
StandardContext
).
to
receive
(
:new
).
and_call_original
allow
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
and_call_original
# rubocop:disable RSpec/ExpectGitlabTracking
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment