-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from DFE-Digital/fix-rails6.0-serialization
Pass model names as strings when loading batches
- Loading branch information
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
RSpec.describe DfE::Analytics::LoadEntityBatch do | ||
include ActiveJob::TestHelper | ||
|
||
with_model :Candidate do | ||
table do |t| | ||
t.string :email_address | ||
end | ||
end | ||
|
||
before do | ||
allow(DfE::Analytics::SendEvents).to receive(:perform_later) | ||
end | ||
|
||
around do |ex| | ||
perform_enqueued_jobs do | ||
ex.run | ||
end | ||
end | ||
|
||
it 'accepts its first arg as a String to support Rails < 6.1' do | ||
# Rails 6.1rc1 added support for deserializing Class and Module params | ||
c = Candidate.create(email_address: 'foo@example.com') | ||
|
||
described_class.perform_later('Candidate', [c.id], 1) | ||
|
||
expect(DfE::Analytics::SendEvents).to have_received(:perform_later).once | ||
end | ||
|
||
it 'accepts its first arg as a Class' do | ||
# backwards compatability with existing enqueued jobs | ||
c = Candidate.create(email_address: 'foo@example.com') | ||
|
||
described_class.perform_later(Candidate, [c.id], 1) | ||
|
||
expect(DfE::Analytics::SendEvents).to have_received(:perform_later).once | ||
end | ||
end |