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
826423aa
Commit
826423aa
authored
Apr 13, 2021
by
Nicolas Dular
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable in-product emails only for free instances
This enables in-product-marketing emails only for free instances
parent
ebb5e2d7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
135 additions
and
28 deletions
+135
-28
app/workers/namespaces/in_product_marketing_emails_worker.rb
app/workers/namespaces/in_product_marketing_emails_worker.rb
+19
-2
changelogs/unreleased/nicolasdular-in-product-emails-only-for-free.yml
...released/nicolasdular-in-product-emails-only-for-free.yml
+5
-0
ee/app/workers/ee/namespaces/in_product_marketing_emails_worker.rb
...rkers/ee/namespaces/in_product_marketing_emails_worker.rb
+16
-0
ee/spec/workers/ee/namespaces/in_product_marketing_emails_worker_spec.rb
.../ee/namespaces/in_product_marketing_emails_worker_spec.rb
+64
-0
spec/support/shared_examples/workers/in_product_marketing_email_shared_example.rb
...ples/workers/in_product_marketing_email_shared_example.rb
+15
-0
spec/workers/namespaces/in_product_marketing_emails_worker_spec.rb
...ers/namespaces/in_product_marketing_emails_worker_spec.rb
+16
-26
No files found.
app/workers/namespaces/in_product_marketing_emails_worker.rb
View file @
826423aa
...
...
@@ -9,10 +9,27 @@ module Namespaces
urgency
:low
def
perform
return
unless
Gitlab
::
CurrentSettings
.
in_product_marketing_emails_enabled
return
if
Gitlab
.
com?
&&
!
Gitlab
::
Experimentation
.
active?
(
:in_product_marketing_emails
)
return
if
paid_self_managed_instance?
return
if
setting_disabled?
return
if
experiment_inactive?
Namespaces
::
InProductMarketingEmailsService
.
send_for_all_tracks_and_intervals
end
private
def
paid_self_managed_instance?
false
end
def
setting_disabled?
!
Gitlab
::
CurrentSettings
.
in_product_marketing_emails_enabled
end
def
experiment_inactive?
Gitlab
.
com?
&&
!
Gitlab
::
Experimentation
.
active?
(
:in_product_marketing_emails
)
end
end
end
Namespaces
::
InProductMarketingEmailsWorker
.
prepend_if_ee
(
'EE::Namespaces::InProductMarketingEmailsWorker'
)
changelogs/unreleased/nicolasdular-in-product-emails-only-for-free.yml
0 → 100644
View file @
826423aa
---
title
:
Enable in-product emails only for free instances
merge_request
:
59290
author
:
type
:
changed
ee/app/workers/ee/namespaces/in_product_marketing_emails_worker.rb
0 → 100644
View file @
826423aa
# frozen_string_literal: true
module
EE
module
Namespaces
module
InProductMarketingEmailsWorker
# rubocop:disable Scalability/IdempotentWorker
extend
::
Gitlab
::
Utils
::
Override
private
override
:paid_self_managed_instance?
def
paid_self_managed_instance?
!::
Gitlab
.
com?
&&
License
.
current
&
.
paid?
end
end
end
end
ee/spec/workers/ee/namespaces/in_product_marketing_emails_worker_spec.rb
0 → 100644
View file @
826423aa
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Namespaces
::
InProductMarketingEmailsWorker
,
'#perform'
do
using
RSpec
::
Parameterized
::
TableSyntax
context
'not on gitlab.com'
do
let
(
:is_gitlab_com
)
{
false
}
let
(
:license
)
{
build
(
:license
)
}
where
(
:in_product_marketing_emails_enabled
,
:experiment_active
,
:executes_service
)
do
true
|
true
|
1
true
|
false
|
1
false
|
false
|
0
false
|
true
|
0
end
with_them
do
context
'with a license'
do
before
do
allow
(
license
).
to
receive
(
:paid?
).
and_return
(
is_paid
)
allow
(
License
).
to
receive
(
:current
).
and_return
(
license
)
end
context
'paid'
do
let
(
:is_paid
)
{
true
}
let
(
:executes_service
)
{
0
}
include_examples
'in-product marketing email'
end
context
'free'
do
let
(
:is_paid
)
{
false
}
include_examples
'in-product marketing email'
end
end
context
'without a license'
do
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
nil
)
end
include_examples
'in-product marketing email'
end
end
end
context
'on gitlab.com'
do
let
(
:is_gitlab_com
)
{
true
}
where
(
:in_product_marketing_emails_enabled
,
:experiment_active
,
:executes_service
)
do
true
|
true
|
1
true
|
false
|
0
false
|
false
|
0
false
|
true
|
0
end
with_them
do
include_examples
'in-product marketing email'
end
end
end
spec/support/shared_examples/workers/in_product_marketing_email_shared_example.rb
0 → 100644
View file @
826423aa
# frozen_string_literal: true
RSpec
.
shared_examples
'in-product marketing email'
do
before
do
stub_application_setting
(
in_product_marketing_emails_enabled:
in_product_marketing_emails_enabled
)
stub_experiment
(
in_product_marketing_emails:
experiment_active
)
allow
(
::
Gitlab
).
to
receive
(
:com?
).
and_return
(
is_gitlab_com
)
end
it
'executes the email service service'
do
expect
(
Namespaces
::
InProductMarketingEmailsService
).
to
receive
(
:send_for_all_tracks_and_intervals
).
exactly
(
executes_service
).
times
subject
.
perform
end
end
spec/workers/namespaces/in_product_marketing_emails_worker_spec.rb
View file @
826423aa
...
...
@@ -5,32 +5,22 @@ require 'spec_helper'
RSpec
.
describe
Namespaces
::
InProductMarketingEmailsWorker
,
'#perform'
do
using
RSpec
::
Parameterized
::
TableSyntax
RSpec
.
shared_examples
'in-product marketing email'
do
before
do
stub_application_setting
(
in_product_marketing_emails_enabled:
in_product_marketing_emails_enabled
)
stub_experiment
(
in_product_marketing_emails:
experiment_active
)
allow
(
::
Gitlab
).
to
receive
(
:com?
).
and_return
(
is_gitlab_com
)
end
it
'executes the email service service'
do
expect
(
Namespaces
::
InProductMarketingEmailsService
).
to
receive
(
:send_for_all_tracks_and_intervals
).
exactly
(
executes_service
).
times
subject
.
perform
end
end
context
'not on gitlab.com'
do
let
(
:is_gitlab_com
)
{
false
}
where
(
:in_product_marketing_emails_enabled
,
:experiment_active
,
:executes_service
)
do
true
|
true
|
1
true
|
false
|
1
false
|
false
|
0
false
|
true
|
0
end
with_them
do
include_examples
'in-product marketing email'
# Running these tests in EE would call the overriden method, which we can't test in CE.
# EE is covered in a separate EE spec.
unless
Gitlab
.
ee?
context
'not on gitlab.com'
do
let
(
:is_gitlab_com
)
{
false
}
where
(
:in_product_marketing_emails_enabled
,
:experiment_active
,
:executes_service
)
do
true
|
true
|
1
true
|
false
|
1
false
|
false
|
0
false
|
true
|
0
end
with_them
do
include_examples
'in-product marketing email'
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