diff options
Diffstat (limited to 'spec/workers/namespaces/in_product_marketing_emails_worker_spec.rb')
-rw-r--r-- | spec/workers/namespaces/in_product_marketing_emails_worker_spec.rb | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/spec/workers/namespaces/in_product_marketing_emails_worker_spec.rb b/spec/workers/namespaces/in_product_marketing_emails_worker_spec.rb index 24143e8cf8a..3b94eb0d1be 100644 --- a/spec/workers/namespaces/in_product_marketing_emails_worker_spec.rb +++ b/spec/workers/namespaces/in_product_marketing_emails_worker_spec.rb @@ -3,45 +3,37 @@ require 'spec_helper' RSpec.describe Namespaces::InProductMarketingEmailsWorker, '#perform' do - context 'when the application setting is enabled' do - before do - stub_application_setting(in_product_marketing_emails_enabled: true) + using RSpec::Parameterized::TableSyntax + + # Running this in EE would call the overridden method, which can't be tested in CE. + # The EE code is covered in a separate EE spec. + context 'not on gitlab.com', unless: Gitlab.ee? 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 - context 'when the experiment is inactive' do - before do - stub_experiment(in_product_marketing_emails: false) - end - - it 'does not execute the in product marketing emails service' do - expect(Namespaces::InProductMarketingEmailsService).not_to receive(:send_for_all_tracks_and_intervals) - - subject.perform - end - end - - context 'when the experiment is active' do - before do - stub_experiment(in_product_marketing_emails: true) - end - - it 'calls the send_for_all_tracks_and_intervals method on the in product marketing emails service' do - expect(Namespaces::InProductMarketingEmailsService).to receive(:send_for_all_tracks_and_intervals) - - subject.perform - end + with_them do + it_behaves_like 'in-product marketing email' end end - context 'when the application setting is disabled' do - before do - stub_application_setting(in_product_marketing_emails_enabled: false) - end + context 'on gitlab.com' do + let(:is_gitlab_com) { true } - it 'does not execute the in product marketing emails service' do - expect(Namespaces::InProductMarketingEmailsService).not_to receive(:send_for_all_tracks_and_intervals) + where(:in_product_marketing_emails_enabled, :experiment_active, :executes_service) do + true | true | 1 + true | false | 0 + false | false | 0 + false | true | 0 + end - subject.perform + with_them do + it_behaves_like 'in-product marketing email' end end end |