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
9a0748d4
Commit
9a0748d4
authored
Aug 29, 2020
by
Nicolas Dular
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use snowplow spec helper for invite controller
Start using the new snowplow helper
parent
1cb88955
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
46 deletions
+26
-46
spec/controllers/invites_controller_spec.rb
spec/controllers/invites_controller_spec.rb
+26
-46
No files found.
spec/controllers/invites_controller_spec.rb
View file @
9a0748d4
...
@@ -2,16 +2,22 @@
...
@@ -2,16 +2,22 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
InvitesController
do
RSpec
.
describe
InvitesController
,
:snowplow
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:member
)
{
create
(
:project_member
,
:invited
,
invite_email:
user
.
email
)
}
let
(
:member
)
{
create
(
:project_member
,
:invited
,
invite_email:
user
.
email
)
}
let
(
:raw_invite_token
)
{
member
.
raw_invite_token
}
let
(
:raw_invite_token
)
{
member
.
raw_invite_token
}
let
(
:project_members
)
{
member
.
source
.
users
}
let
(
:project_members
)
{
member
.
source
.
users
}
let
(
:md5_member_global_id
)
{
Digest
::
MD5
.
hexdigest
(
member
.
to_global_id
.
to_s
)
}
let
(
:md5_member_global_id
)
{
Digest
::
MD5
.
hexdigest
(
member
.
to_global_id
.
to_s
)
}
let
(
:params
)
{
{
id:
raw_invite_token
}
}
let
(
:params
)
{
{
id:
raw_invite_token
}
}
let
(
:snowplow_event
)
do
{
category:
'Growth::Acquisition::Experiment::InviteEmail'
,
label:
md5_member_global_id
,
property:
group_type
}
end
before
do
before
do
stub_application_setting
(
snowplow_enabled:
true
,
snowplow_collector_hostname:
'localhost'
)
controller
.
instance_variable_set
(
:@member
,
member
)
controller
.
instance_variable_set
(
:@member
,
member
)
end
end
...
@@ -45,51 +51,33 @@ RSpec.describe InvitesController do
...
@@ -45,51 +51,33 @@ RSpec.describe InvitesController do
context
'when new_user_invite is not set'
do
context
'when new_user_invite is not set'
do
it
'does not track the user as experiment group'
do
it
'does not track the user as experiment group'
do
expect
(
Gitlab
::
Tracking
).
not_to
receive
(
:event
)
request
request
expect_no_snowplow_event
end
end
end
end
context
'when new_user_invite is experiment'
do
context
'when new_user_invite is experiment'
do
let
(
:params
)
{
{
id:
raw_invite_token
,
new_user_invite:
'experiment'
}
}
let
(
:params
)
{
{
id:
raw_invite_token
,
new_user_invite:
'experiment'
}
}
let
(
:group_type
)
{
'experiment_group'
}
it
'tracks the user as experiment group'
do
it
'tracks the user as experiment group'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
and_call_original
.
with
(
'Growth::Acquisition::Experiment::InviteEmail'
,
'opened'
,
property:
'experiment_group'
,
label:
md5_member_global_id
)
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
and_call_original
.
with
(
'Growth::Acquisition::Experiment::InviteEmail'
,
'accepted'
,
property:
'experiment_group'
,
label:
md5_member_global_id
)
request
request
expect_snowplow_event
(
snowplow_event
.
merge
(
action:
'opened'
))
expect_snowplow_event
(
snowplow_event
.
merge
(
action:
'accepted'
))
end
end
end
end
context
'when new_user_invite is control'
do
context
'when new_user_invite is control'
do
let
(
:params
)
{
{
id:
raw_invite_token
,
new_user_invite:
'control'
}
}
let
(
:params
)
{
{
id:
raw_invite_token
,
new_user_invite:
'control'
}
}
let
(
:group_type
)
{
'control_group'
}
it
'tracks the user as control group'
do
it
'tracks the user as control group'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
and_call_original
.
with
(
'Growth::Acquisition::Experiment::InviteEmail'
,
'opened'
,
property:
'control_group'
,
label:
md5_member_global_id
)
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
and_call_original
.
with
(
'Growth::Acquisition::Experiment::InviteEmail'
,
'accepted'
,
property:
'control_group'
,
label:
md5_member_global_id
)
request
request
expect_snowplow_event
(
snowplow_event
.
merge
(
action:
'opened'
))
expect_snowplow_event
(
snowplow_event
.
merge
(
action:
'accepted'
))
end
end
end
end
end
end
...
@@ -124,39 +112,31 @@ RSpec.describe InvitesController do
...
@@ -124,39 +112,31 @@ RSpec.describe InvitesController do
context
'when new_user_invite is not set'
do
context
'when new_user_invite is not set'
do
it
'does not track an event'
do
it
'does not track an event'
do
expect
(
Gitlab
::
Tracking
).
not_to
receive
(
:event
)
request
request
expect_no_snowplow_event
end
end
end
end
context
'when new_user_invite is experiment'
do
context
'when new_user_invite is experiment'
do
let
(
:params
)
{
{
id:
raw_invite_token
,
new_user_invite:
'experiment'
}
}
let
(
:params
)
{
{
id:
raw_invite_token
,
new_user_invite:
'experiment'
}
}
let
(
:group_type
)
{
'experiment_group'
}
it
'tracks the user as experiment group'
do
it
'tracks the user as experiment group'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
and_call_original
.
with
(
'Growth::Acquisition::Experiment::InviteEmail'
,
'accepted'
,
property:
'experiment_group'
,
label:
md5_member_global_id
)
request
request
expect_snowplow_event
(
snowplow_event
.
merge
(
action:
'accepted'
))
end
end
end
end
context
'when new_user_invite is control'
do
context
'when new_user_invite is control'
do
let
(
:params
)
{
{
id:
raw_invite_token
,
new_user_invite:
'control'
}
}
let
(
:params
)
{
{
id:
raw_invite_token
,
new_user_invite:
'control'
}
}
let
(
:group_type
)
{
'control_group'
}
it
'tracks the user as control group'
do
it
'tracks the user as control group'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
and_call_original
.
with
(
'Growth::Acquisition::Experiment::InviteEmail'
,
'accepted'
,
property:
'control_group'
,
label:
md5_member_global_id
)
request
request
expect_snowplow_event
(
snowplow_event
.
merge
(
action:
'accepted'
))
end
end
end
end
end
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