add job spec
This commit is contained in:
@@ -156,5 +156,57 @@ describe MatchAppearanceReleasesJob do
|
||||
expect(AppearanceRelease.last.contract.attached?).to eq true
|
||||
end
|
||||
|
||||
it "creates two new incomplete appearance releases if BrayniacAI returns two matches for headshot and contract" do
|
||||
signed_ids = [
|
||||
dummy_appearance_release.person_photo.blob.signed_id,
|
||||
dummy_appearance_release.contract.blob.signed_id
|
||||
]
|
||||
keys = [
|
||||
dummy_appearance_release.person_photo.key,
|
||||
dummy_appearance_release.contract.key
|
||||
]
|
||||
payload = {
|
||||
project: project,
|
||||
attachments: signed_ids
|
||||
}
|
||||
qr_matching_payload = {
|
||||
bucket: '',
|
||||
files: keys,
|
||||
request_id: dummy_matching_request.id
|
||||
}
|
||||
mock_match1 = double(
|
||||
headshots: [keys[0]],
|
||||
contracts: [],
|
||||
unknowns: [],
|
||||
identifier: 'some/identifier/123'
|
||||
)
|
||||
mock_match2 = double(
|
||||
headshots: [],
|
||||
contracts: [keys[1]],
|
||||
unknowns: [],
|
||||
identifier: 'some/identifier/789'
|
||||
)
|
||||
matches = [mock_match1, mock_match2]
|
||||
qr_matching_mock_response = double(
|
||||
request_id: dummy_matching_request.id,
|
||||
matches: matches
|
||||
)
|
||||
|
||||
expect(MatchingRequest).to receive(:create).with(payload).and_return(dummy_matching_request)
|
||||
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
||||
expect(dummy_matching_request).to receive(:destroy)
|
||||
|
||||
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
||||
|
||||
releases = AppearanceRelease.last(2)
|
||||
|
||||
expect(releases[0].identifier).to eq mock_match1.identifier
|
||||
expect(releases[0].person_photo.attached?).to eq true
|
||||
expect(releases[0].contract.attached?).to eq false
|
||||
|
||||
expect(releases[1].identifier).to eq mock_match2.identifier
|
||||
expect(releases[1].person_photo.attached?).to eq false
|
||||
expect(releases[1].contract.attached?).to eq true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user