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
678af159
Commit
678af159
authored
May 07, 2021
by
Nicolas Dular
Committed by
Gabriel Mazetto
May 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only send in-product emails to free groups
parent
199ae04f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
2 deletions
+95
-2
app/models/group.rb
app/models/group.rb
+2
-0
app/services/namespaces/in_product_marketing_emails_service.rb
...ervices/namespaces/in_product_marketing_emails_service.rb
+12
-2
ee/app/services/ee/namespaces/in_product_marketing_emails_service.rb
...ices/ee/namespaces/in_product_marketing_emails_service.rb
+16
-0
ee/changelogs/unreleased/nicolasdular-in-product-marketing-only-for-free.yml
...eased/nicolasdular-in-product-marketing-only-for-free.yml
+5
-0
ee/spec/services/namespaces/in_product_marketing_emails_service_spec.rb
...es/namespaces/in_product_marketing_emails_service_spec.rb
+50
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+10
-0
No files found.
app/models/group.rb
View file @
678af159
...
...
@@ -107,6 +107,8 @@ class Group < Namespace
scope
:with_users
,
->
{
includes
(
:users
)
}
scope
:with_onboarding_progress
,
->
{
joins
(
:onboarding_progress
)
}
scope
:by_id
,
->
(
groups
)
{
where
(
id:
groups
)
}
scope
:for_authorized_group_members
,
->
(
user_ids
)
do
...
...
app/services/namespaces/in_product_marketing_emails_service.rb
View file @
678af159
...
...
@@ -66,7 +66,6 @@ module Namespaces
Experiment
.
add_group
(
:in_product_marketing_emails
,
variant:
variant
,
group:
group
)
end
# rubocop: disable CodeReuse/ActiveRecord
def
groups_for_track
onboarding_progress_scope
=
OnboardingProgress
.
completed_actions_with_latest_in_range
(
completed_actions
,
range
)
...
...
@@ -75,9 +74,18 @@ module Namespaces
# Filtering out sub-groups is a temporary fix to prevent calling
# `.root_ancestor` on groups that are not root groups.
# See https://gitlab.com/groups/gitlab-org/-/epics/5594 for more information.
Group
.
where
(
parent_id:
nil
).
joins
(
:onboarding_progress
).
merge
(
onboarding_progress_scope
)
Group
.
top_most
.
with_onboarding_progress
.
merge
(
onboarding_progress_scope
)
.
merge
(
subscription_scope
)
end
def
subscription_scope
{}
end
# rubocop: disable CodeReuse/ActiveRecord
def
users_for_group
(
group
)
group
.
users
.
where
(
email_opted_in:
true
)
...
...
@@ -136,3 +144,5 @@ module Namespaces
end
end
end
Namespaces
::
InProductMarketingEmailsService
.
prepend_ee_mod
ee/app/services/ee/namespaces/in_product_marketing_emails_service.rb
0 → 100644
View file @
678af159
# frozen_string_literal: true
module
EE
module
Namespaces
module
InProductMarketingEmailsService
extend
::
Gitlab
::
Utils
::
Override
private
override
:subscription_scope
def
subscription_scope
::
Namespace
.
in_default_plan
end
end
end
end
ee/changelogs/unreleased/nicolasdular-in-product-marketing-only-for-free.yml
0 → 100644
View file @
678af159
---
title
:
Only send in-product emails to free groups
merge_request
:
60906
author
:
type
:
changed
ee/spec/services/namespaces/in_product_marketing_emails_service_spec.rb
0 → 100644
View file @
678af159
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Namespaces
::
InProductMarketingEmailsService
,
'#execute'
do
let
(
:frozen_time
)
{
Time
.
zone
.
parse
(
'23 Mar 2021 10:14:40 UTC'
)
}
let_it_be
(
:user
)
{
create
(
:user
,
email_opted_in:
true
)
}
before
do
travel_to
(
frozen_time
)
create
(
:onboarding_progress
,
namespace:
group
,
created_at:
frozen_time
-
2
.
days
,
git_write_at:
nil
)
group
.
add_developer
(
user
)
stub_experiment_for_subject
(
in_product_marketing_emails:
true
)
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user
,
anything
,
anything
).
and_return
(
true
)
allow
(
Notify
).
to
receive
(
:in_product_marketing_email
).
and_return
(
double
(
deliver_later:
nil
))
end
context
'when group has a plan'
do
before
do
described_class
.
new
(
:create
,
1
).
execute
end
context
'on the free plan'
do
let
(
:group
)
{
create
(
:group_with_plan
,
plan: :free_plan
)
}
it
'sends an email'
do
expect
(
Notify
).
to
have_received
(
:in_product_marketing_email
)
end
end
context
'on a trial'
do
let
(
:group
)
{
create
(
:group_with_plan
,
trial_ends_on:
frozen_time
+
10
.
days
)
}
it
'sends an email'
do
expect
(
Notify
).
to
have_received
(
:in_product_marketing_email
)
end
end
context
'on a paid plan'
do
let
(
:group
)
{
create
(
:group_with_plan
,
plan: :bronze_plan
)
}
it
'does not send email'
do
expect
(
Notify
).
not_to
have_received
(
:in_product_marketing_email
)
end
end
end
end
spec/models/group_spec.rb
View file @
678af159
...
...
@@ -632,6 +632,16 @@ RSpec.describe Group do
it
{
is_expected
.
to
match_array
([
private_group
,
internal_group
])
}
end
describe
'with_onboarding_progress'
do
subject
{
described_class
.
with_onboarding_progress
}
it
'joins onboarding_progress'
do
create
(
:onboarding_progress
,
namespace:
group
)
expect
(
subject
).
to
eq
([
group
])
end
end
describe
'for_authorized_group_members'
do
let_it_be
(
:group_member1
)
{
create
(
:group_member
,
source:
private_group
,
user_id:
user1
.
id
,
access_level:
Gitlab
::
Access
::
OWNER
)
}
...
...
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