Skip to content
Snippets Groups Projects
Commit 39f4cfbb authored by Rongrong Liu's avatar Rongrong Liu
Browse files

Restrict duo pro assignment email to duo pro for sm

parent dddae8b6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -76,10 +76,6 @@ def eligible_for_gitlab_duo_pro_seat?
raise NotImplementedError, 'Subclasses must implement the eligible_for_gitlab_duo_pro_seat? method'
end
 
def duo_pro_or_enterprise?
add_on_purchase.add_on.code_suggestions? || add_on_purchase.add_on.duo_enterprise?
end
def log_event(message, error: nil, error_code: nil)
log_params = base_log_params.tap do |result|
result[:message] = message
Loading
Loading
Loading
Loading
@@ -33,6 +33,10 @@ def should_trigger_duo_pro_iterable?(response)
response.success? && duo_pro_or_enterprise? && !user_already_assigned?
end
 
def duo_pro_or_enterprise?
add_on_purchase.add_on.code_suggestions? || add_on_purchase.add_on.duo_enterprise?
end
def create_iterable_trigger
::Onboarding::CreateIterableTriggerWorker.perform_async(iterable_params)
end
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@ def should_send_duo_seat_assignment_email?(response)
Feature.enabled?(:duo_seat_assignment_email_for_sm, :instance) &&
!user_already_assigned? &&
response.success? &&
duo_pro_or_enterprise?
add_on_purchase.add_on.code_suggestions? # checking if it is a duo_pro add_on
end
end
end
Loading
Loading
Loading
Loading
@@ -37,11 +37,6 @@
 
expect { subject }.to change { Rails.cache.read(cache_key) }.from(false).to(nil)
end
it 'sends seat assignment email' do
expect { subject }.to have_enqueued_mail(
GitlabSubscriptions::DuoSeatAssignmentMailer, :duo_pro_email).with(user)
end
end
 
shared_examples 'error response' do |error|
Loading
Loading
@@ -148,13 +143,32 @@
end
end
 
context 'when duo_seat_assignment_email_for_sm flag is off' do
before do
stub_feature_flags(duo_seat_assignment_email_for_sm: false)
context 'with duo pro seat assignment email' do
it 'sends seat assignment email' do
expect { response }.to have_enqueued_mail(
GitlabSubscriptions::DuoSeatAssignmentMailer, :duo_pro_email).with(user)
end
 
it 'does not enqueue the seat assignment email' do
expect { response }.not_to have_enqueued_mail(GitlabSubscriptions::DuoSeatAssignmentMailer, :duo_pro_email)
context 'when the add_on is not duo_pro' do
let(:add_on) { create(:gitlab_subscription_add_on, :duo_enterprise) }
let(:add_on_purchase) { create(:gitlab_subscription_add_on_purchase, :self_managed, add_on: add_on) }
let(:user) { create(:user) }
it 'does not enqueue the seat assignment email' do
expect { response }.not_to have_enqueued_mail(GitlabSubscriptions::DuoSeatAssignmentMailer, :duo_pro_email)
end
end
context 'when duo_seat_assignment_email_for_sm flag is off' do
before do
stub_feature_flags(duo_seat_assignment_email_for_sm: false)
end
it 'does not enqueue the seat assignment email' do
expect do
response
end.not_to have_enqueued_mail(GitlabSubscriptions::DuoSeatAssignmentMailer, :duo_pro_email)
end
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment