Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
require "rails_helper"
RSpec.describe AnalysisNotification, type: :model do
describe "#build" do
context "for audio type" do
it "returns AudioAnalysisNotification subclass" do
notification = described_class.build("audio", "job_id")
expect(notification).to be_a(AnalysisNotification::AudioAnalysisNotification)
expect(notification.job_id).to eq "job_id"
end
end
context "for video type" do
it "returns VideoAnalysisNotification subclass" do
notification = described_class.build("video", "job_id")
expect(notification).to be_a(AnalysisNotification::VideoAnalysisNotification)
expect(notification.job_id).to eq "job_id"
end
end
end
describe AnalysisNotification::VideoAnalysisNotification do
let!(:video) { create(:video, analysis_uid: "job_id") }
subject { described_class.new("job_id") }
describe "#video" do
it "fetches video using job id" do
expect(subject.video).to eq video
end
end
describe "#success!" do
it "updates status of the video" do
subject.success!
expect(video.reload).to be_analysis_success
end
end
describe "#failure!" do
it "updates status of the video" do
subject.failure!
expect(video.reload).to be_analysis_failure
end
end
end
describe AnalysisNotification::AudioAnalysisNotification do
let!(:video) { create(:video, audio_analysis_uid: "job_id") }
subject { described_class.new("job_id") }
describe "#video" do
it "fetches video using job id" do
expect(subject.video).to eq video
end
end
describe "#success!" do
it "updates status of the video" do
subject.success!
expect(video.reload).to be_audio_analysis_success
end
end
describe "#failure!" do
it "updates status of the video" do
subject.failure!
expect(video.reload).to be_audio_analysis_failure
end
end
end
end