update specs
This commit is contained in:
@@ -10,14 +10,10 @@ describe MatchAppearanceReleasesJob do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe ".perform_now" do
|
describe ".perform_now" do
|
||||||
# before do
|
|
||||||
# allow(ProjectsChannel).to receive(:appearance_matching_flash_message).with(be_kind_of(Project), I18n.t("appearance_releases.create.matching_completed"))
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
it "returns if no attachment is sent" do
|
it "returns if no attachment is sent" do
|
||||||
expect(MatchingRequest).not_to receive(:create)
|
expect(MatchingRequest).not_to receive(:create)
|
||||||
attachments = []
|
attachments = []
|
||||||
|
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), failure_flash_message, :alert)
|
||||||
MatchAppearanceReleasesJob.perform_now project, attachments
|
MatchAppearanceReleasesJob.perform_now project, attachments
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -25,6 +21,7 @@ describe MatchAppearanceReleasesJob do
|
|||||||
expect(MatchingRequest).not_to receive(:create)
|
expect(MatchingRequest).not_to receive(:create)
|
||||||
dummy_video = create(:video)
|
dummy_video = create(:video)
|
||||||
attachments = [dummy_video.file.blob.signed_id]
|
attachments = [dummy_video.file.blob.signed_id]
|
||||||
|
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), failure_flash_message, :alert)
|
||||||
MatchAppearanceReleasesJob.perform_now project, attachments
|
MatchAppearanceReleasesJob.perform_now project, attachments
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -49,14 +46,14 @@ describe MatchAppearanceReleasesJob do
|
|||||||
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
||||||
expect(dummy_matching_request).to receive(:destroy)
|
expect(dummy_matching_request).to receive(:destroy)
|
||||||
|
|
||||||
|
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
||||||
}.to change{AppearanceRelease.count}.by(1)
|
}.to change{AppearanceRelease.count}.by(1)
|
||||||
|
|
||||||
expect(AppearanceRelease.last.contract).not_to be_attached
|
expect(AppearanceRelease.last.contract).not_to be_attached
|
||||||
expect(AppearanceRelease.last.person_photo).to be_attached
|
expect(AppearanceRelease.last.person_photo).to be_attached
|
||||||
|
|
||||||
# expect(ProjectsChannel).to receive(:appearance_matching_flash_message)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates a new incomplete appearance release for contracts which cannot be matched by BrayniacAI" do
|
it "creates a new incomplete appearance release for contracts which cannot be matched by BrayniacAI" do
|
||||||
@@ -80,6 +77,8 @@ describe MatchAppearanceReleasesJob do
|
|||||||
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
||||||
expect(dummy_matching_request).to receive(:destroy)
|
expect(dummy_matching_request).to receive(:destroy)
|
||||||
|
|
||||||
|
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
||||||
}.to change{AppearanceRelease.count}.by(1)
|
}.to change{AppearanceRelease.count}.by(1)
|
||||||
@@ -116,6 +115,8 @@ describe MatchAppearanceReleasesJob do
|
|||||||
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
||||||
expect(dummy_matching_request).to receive(:destroy)
|
expect(dummy_matching_request).to receive(:destroy)
|
||||||
|
|
||||||
|
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
|
||||||
|
|
||||||
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
||||||
|
|
||||||
expect(AppearanceRelease.last.identifier).to eq mock_match.identifier
|
expect(AppearanceRelease.last.identifier).to eq mock_match.identifier
|
||||||
@@ -151,6 +152,8 @@ describe MatchAppearanceReleasesJob do
|
|||||||
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
||||||
expect(dummy_matching_request).to receive(:destroy)
|
expect(dummy_matching_request).to receive(:destroy)
|
||||||
|
|
||||||
|
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
||||||
}.to change{AppearanceRelease.count}.by(2)
|
}.to change{AppearanceRelease.count}.by(2)
|
||||||
@@ -194,6 +197,8 @@ describe MatchAppearanceReleasesJob do
|
|||||||
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
||||||
expect(dummy_matching_request).to receive(:destroy)
|
expect(dummy_matching_request).to receive(:destroy)
|
||||||
|
|
||||||
|
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
|
||||||
|
|
||||||
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
||||||
|
|
||||||
expect(AppearanceRelease.last.identifier).to eq mock_match.identifier
|
expect(AppearanceRelease.last.identifier).to eq mock_match.identifier
|
||||||
@@ -235,6 +240,8 @@ describe MatchAppearanceReleasesJob do
|
|||||||
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
||||||
expect(dummy_matching_request).to receive(:destroy)
|
expect(dummy_matching_request).to receive(:destroy)
|
||||||
|
|
||||||
|
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
|
||||||
|
|
||||||
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
||||||
|
|
||||||
expect(AppearanceRelease.last.identifier).to eq mock_match.identifier
|
expect(AppearanceRelease.last.identifier).to eq mock_match.identifier
|
||||||
@@ -282,6 +289,8 @@ describe MatchAppearanceReleasesJob do
|
|||||||
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
|
||||||
expect(dummy_matching_request).to receive(:destroy)
|
expect(dummy_matching_request).to receive(:destroy)
|
||||||
|
|
||||||
|
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
|
||||||
|
|
||||||
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
MatchAppearanceReleasesJob.perform_now project, signed_ids
|
||||||
|
|
||||||
releases = AppearanceRelease.last(2)
|
releases = AppearanceRelease.last(2)
|
||||||
@@ -295,4 +304,14 @@ describe MatchAppearanceReleasesJob do
|
|||||||
expect(releases[1].contract.attached?).to eq true
|
expect(releases[1].contract.attached?).to eq true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def success_flash_message
|
||||||
|
I18n.t 'appearance_releases.create.matching_completed'
|
||||||
|
end
|
||||||
|
|
||||||
|
def failure_flash_message
|
||||||
|
I18n.t 'appearance_releases.create.matching_failed'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user