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

hotfix/APPEALS-45399-45401 #21555

Merged
merged 6 commits into from
May 6, 2024
2 changes: 1 addition & 1 deletion app/jobs/hearings/fetch_webex_recordings_details_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def fetch_recording_details(id)
host: ENV["WEBEX_HOST_MAIN"],
port: ENV["WEBEX_PORT"],
aud: ENV["WEBEX_ORGANIZATION"],
apikey: ENV["WEBEX_BOTTOKEN"],
apikey: CredStash.get("webex_#{Rails.deploy_env}_access_token"),
domain: ENV["WEBEX_DOMAIN_MAIN"],
api_endpoint: ENV["WEBEX_API_MAIN"],
query: nil
Expand Down
6 changes: 3 additions & 3 deletions app/jobs/hearings/fetch_webex_recordings_list_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ def log_error(error)
private

def fetch_recordings_list
from = CGI.escape(2.hours.ago.in_time_zone("America/New_York").beginning_of_hour.iso8601)
to = CGI.escape(1.hour.ago.in_time_zone("America/New_York").beginning_of_hour.iso8601)
from = 2.hours.ago.in_time_zone("America/New_York").beginning_of_hour.iso8601
to = 1.hour.ago.in_time_zone("America/New_York").beginning_of_hour.iso8601
max = 100
query = { "from": from, "to": to, "max": max }

WebexService.new(
host: ENV["WEBEX_HOST_MAIN"],
port: ENV["WEBEX_PORT"],
aud: ENV["WEBEX_ORGANIZATION"],
apikey: ENV["WEBEX_BOTTOKEN"],
apikey: CredStash.get("webex_#{Rails.deploy_env}_access_token"),
domain: ENV["WEBEX_DOMAIN_MAIN"],
api_endpoint: ENV["WEBEX_API_MAIN"],
query: query
Expand Down
11 changes: 11 additions & 0 deletions spec/jobs/hearings/fetch_webex_recordings_details_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,27 @@
let(:mp3_file_name) { "180000304_1_LegacyHearing-1.mp3" }
let(:hearing) { create(:hearing) }
let(:file_name) { "#{hearing.docket_number}_#{hearing.id}_#{hearing.class}" }
let(:access_token) { "sample_#{Rails.deploy_env}_token" }

subject { described_class.perform_now(id: id, file_name: file_name) }

before do
allow(CredStash).to receive(:get).with("webex_#{Rails.deploy_env}_access_token").and_return(access_token)
end

context "method testing" do
before do
allow_any_instance_of(Hearings::DownloadTranscriptionFileJob)
.to receive(:perform)
.and_return(nil)
end

it "Uses correct api key for correct environment" do
allow(WebexService).to receive(:new).and_call_original
expect(WebexService).to receive(:new).with(hash_including(apikey: access_token))
subject
end

it "hits the webex API and returns recording details" do
get_details = Hearings::FetchWebexRecordingsDetailsJob.new
run = get_details.send(:fetch_recording_details, id)
Expand Down
43 changes: 34 additions & 9 deletions spec/jobs/hearings/fetch_webex_recordings_list_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,43 @@

describe Hearings::FetchWebexRecordingsListJob, type: :job do
include ActiveJob::TestHelper
let(:access_token) { "sample_#{Rails.deploy_env}_token" }

subject { described_class.perform_now }

it "Returns the correct array of ids" do
allow_any_instance_of(Hearings::DownloadTranscriptionFileJob)
.to receive(:perform)
.and_return(nil)
expect(subject).to eq(%w[
4f914b1dfe3c4d11a61730f18c0f5387
3324fb76946249cfa07fc30b3ccbf580
42b80117a2a74dcf9863bf06264f8075
])
before do
allow(CredStash).to receive(:get).with("webex_#{Rails.deploy_env}_access_token").and_return(access_token)
end

context "job success" do
before do
allow_any_instance_of(Hearings::DownloadTranscriptionFileJob)
.to receive(:perform)
.and_return(nil)
end

it "Returns the correct array of ids" do
expect(subject).to eq(%w[
4f914b1dfe3c4d11a61730f18c0f5387
3324fb76946249cfa07fc30b3ccbf580
42b80117a2a74dcf9863bf06264f8075
])
end

it "Uses correct api key for correct environment" do
allow(WebexService).to receive(:new).and_call_original
expect(WebexService).to receive(:new).with(hash_including(apikey: access_token))
subject
end

it "Uses correctly formatted to and from query parameters" do
to_param = 1.hour.ago.in_time_zone("America/New_York").beginning_of_hour.iso8601
from_param = 2.hours.ago.in_time_zone("America/New_York").beginning_of_hour.iso8601

allow(WebexService).to receive(:new).and_call_original
expect(WebexService).to receive(:new).with(hash_including(query: { to: to_param, from: from_param, max: 100 }))
subject
end
end

context "job errors" do
Expand Down
Loading