Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Piedram/appeals 44897 #21519

Merged
merged 7 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions app/workflows/transcription_packages.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

class TranscriptionPackages
include ActiveModel::Model
include ActiveModel::Validations

include MailRequestValidator::Distribution
include MailRequestValidator::DistributionDestination

def initialize(work_order_params)
@work_order_params = work_order_params
end

def call
create_work_order
create_zip_file
end

private

def create_work_order
# call job work_order
Hearings::WorkOrderJob.perform(@work_order_params)
end

def create_zip_file
# call job to create a zip File
Hearings::ZipAndUploadTranscriptionFilesJob.perform(@work_order_params.hearings)
end
end

32 changes: 32 additions & 0 deletions spec/workflows/transcription_packages_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

describe TranscriptionPackages do
describe "#call" do
context "start to execute all jobs" do
let(:hearings) {(1..5).map{ create(:hearing, :with_transcription_files)}}
let(:legacy_hearings) {(1..5).map{ create(:hearing, :with_transcription_files)}}
let(:work_order_params) do
{
work_order_name: "#1234567",
return_date: "05/07/2024",
contractor: "Contractor A",
hearings: hearings + legacy_hearings
}
end
subject { TranscriptionPackages.new(work_order_params) }

it "Call to initialize method" do
expect(subject.instance_variable_get(:@work_order_params)[:work_order_name]).to eq("#1234567")
expect(subject.instance_variable_get(:@work_order_params)[:return_date]).to eq("05/07/2024")
expect(subject.instance_variable_get(:@work_order_params)[:contractor]).to eq("Contractor A")
expect(subject.instance_variable_get(:@work_order_params)[:hearings]).to eq(hearings + legacy_hearings)
end

it "Call to Call method " do
allow_any_instance_of(TranscriptionPackages).to receive(:create_work_order).and_return(true)
allow_any_instance_of(TranscriptionPackages).to receive(:create_zip_file).and_return(true)
expect { subject.call }.not_to raise_error
end
end
end
end
Loading