Skip to content

Commit d16df7a

Browse files
committed
Move Salesforce Sync into Flipper Flag
This commit removes the SALESFORCE_ENABLED env var in favour of using Flipper feature flags.
1 parent 8241770 commit d16df7a

5 files changed

Lines changed: 13 additions & 21 deletions

File tree

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ RESEED_API_KEY=changeme
5959
ENABLE_IMMEDIATE_SCHOOL_ONBOARDING=true
6060

6161
# Salesforce Connect
62-
SALESFORCE_ENABLED=true
6362
SALESFORCE_CONNECT_HOST=salesforce_connect
6463
SALESFORCE_CONNECT_PORT=4101
6564
SALESFORCE_CONNECT_DB=salesforce_development

app/jobs/salesforce/salesforce_sync_job.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class SkipBecauseSalesforceIsDisabled < StandardError
2727
queue_as :salesforce_sync
2828

2929
before_perform do |_job|
30-
salesforce_enabled = ENV.fetch('SALESFORCE_ENABLED', 'true') == 'true'
31-
raise SkipBecauseSalesforceIsDisabled, 'SALESFORCE_ENABLED is not true.' unless salesforce_enabled
30+
raise SkipBecauseSalesforceIsDisabled, 'salesforce_sync Flipper flag is not enabled.' unless Flipper.enabled?(:salesforce_sync)
3231
end
3332

3433
def perform(*)

spec/jobs/salesforce/contact_sync_job_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
RSpec.describe Salesforce::ContactSyncJob do
66
subject(:perform_job) { described_class.perform_now(school_id: school.id) }
77

8+
before { Flipper.enable(:salesforce_sync) }
9+
810
let(:school) { create(:school, creator_agree_to_ux_contact: true) }
911
let!(:sf_contact) { create(:salesforce_contact, pi_accounts_unique_id__c: school.creator_id) }
1012

@@ -41,12 +43,8 @@
4143
end
4244
end
4345

44-
context 'when SALESFORCE_ENABLED is false' do
45-
around do |example|
46-
ClimateControl.modify(SALESFORCE_ENABLED: 'false') do
47-
example.run
48-
end
49-
end
46+
context 'when the salesforce_sync Flipper flag is disabled' do
47+
before { Flipper.disable(:salesforce_sync) }
5048

5149
it 'discards the job without syncing' do
5250
sf_contact.update!(experiencecsagreetouxcontact__c: false)

spec/jobs/salesforce/role_sync_job_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
RSpec.describe Salesforce::RoleSyncJob do
66
subject(:perform_job) { described_class.perform_now(role_id: role.id) }
77

8+
before { Flipper.enable(:salesforce_sync) }
9+
810
let(:role) { create(:role) }
911

1012
context 'when the job has run' do
@@ -43,12 +45,8 @@
4345
end
4446
end
4547

46-
context 'when SALESFORCE_ENABLED is false' do
47-
around do |example|
48-
ClimateControl.modify(SALESFORCE_ENABLED: 'false') do
49-
example.run
50-
end
51-
end
48+
context 'when the salesforce_sync Flipper flag is disabled' do
49+
before { Flipper.disable(:salesforce_sync) }
5250

5351
it 'discards the job without syncing' do
5452
perform_job

spec/jobs/salesforce/school_sync_job_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
RSpec.describe Salesforce::SchoolSyncJob do
66
subject(:perform_job) { described_class.perform_now(school_id: school.id) }
77

8+
before { Flipper.enable(:salesforce_sync) }
9+
810
let(:school) { create(:school) }
911

1012
context 'when the job has run' do
@@ -62,12 +64,8 @@
6264
end
6365
end
6466

65-
context 'when SALESFORCE_ENABLED is false' do
66-
around do |example|
67-
ClimateControl.modify(SALESFORCE_ENABLED: 'false') do
68-
example.run
69-
end
70-
end
67+
context 'when the salesforce_sync Flipper flag is disabled' do
68+
before { Flipper.disable(:salesforce_sync) }
7169

7270
it 'discards the job without syncing' do
7371
perform_job

0 commit comments

Comments
 (0)