Skip to content

Commit

Permalink
Update info message and specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ericaporter committed Apr 12, 2024
1 parent 9f279e4 commit 4c5b24f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/dfe/analytics/load_entity_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class LoadEntityBatch < AnalyticsJob
BQ_BATCH_MAX_BYTES = 10_000_000

def perform(model_class_arg, ids, entity_tag)
return unless DfE::Analytics.enabled?
unless DfE::Analytics.enabled?
Rails.logger.info('Bulk upload only available when DfE::Analytics is enabled, please check it is enabled in this env')
return
end

model_class = resolve_model_class(model_class_arg)

Expand Down
15 changes: 15 additions & 0 deletions spec/dfe/analytics/entity_table_check_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,24 @@
end

describe '#perform' do
context 'when dfe-analytics is not enabled' do
before do
allow(DfE::Analytics).to receive(:enabled?).and_return(false)
allow(DfE::Analytics).to receive(:entity_table_checks_enabled?).and_return(true)
allow(DfE::Analytics).to receive(:entities_for_analytics).and_return(%w[Candidate Application])
end

it 'does not call EntityTableChecks' do
expect(DfE::Analytics::Services::EntityTableChecks).not_to receive(:call)

described_class.new.perform
end
end

context 'when entity table checks are not enabled' do
before do
allow(DfE::Analytics).to receive(:entity_table_checks_enabled?).and_return(false)
allow(DfE::Analytics).to receive(:entities_for_analytics).and_return(%w[Candidate Application])
end

it 'does not call EntityTableChecks' do
Expand Down
1 change: 1 addition & 0 deletions spec/dfe/analytics/load_entity_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
end

before do
allow(DfE::Analytics).to receive(:enabled?).and_return(true)
allow(DfE::Analytics::SendEvents).to receive(:perform_now)

allow(DfE::Analytics).to receive(:allowlist).and_return({
Expand Down

0 comments on commit 4c5b24f

Please sign in to comment.