Skip to content

Commit

Permalink
Don't override audio_url if it's provided by the user
Browse files Browse the repository at this point in the history
  • Loading branch information
samnang committed Mar 2, 2025
1 parent 1646249 commit 5d57e4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/models/broadcast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def set_call_flow_logic
def process_audio_file
return unless audio_file.attached?
return unless audio_file_blob_changed?
return if audio_url.present?

AudioFileProcessorJob.perform_later(self)
end
Expand Down
9 changes: 5 additions & 4 deletions spec/requests/open_ews_api/v1/broadcasts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
}
)

stub_request(:get, "https://www.example.com/sample.mp3").to_return(status: 200)
allow(AudioFileProcessorJob).to receive(:perform_later).with(broadcast)
stub_request(:get, "https://www.example.com/test.mp3")
.to_return(status: 200, body: file_fixture("test.mp3"))

set_authorization_header_for(account)
perform_enqueued_jobs do
Expand All @@ -113,7 +113,7 @@
type: :broadcast,
attributes: {
status: "running",
audio_url: "https://www.example.com/sample.mp3",
audio_url: "https://www.example.com/test.mp3",
beneficiary_filter: {
gender: { eq: "F" }
}
Expand All @@ -126,12 +126,13 @@
expect(response_body).to match_jsonapi_resource_schema("broadcast")
expect(json_response.dig("data", "attributes")).to include(
"status" => "queued",
"audio_url" => "https://www.example.com/sample.mp3",
"audio_url" => "https://www.example.com/test.mp3",
"beneficiary_filter" => {
"gender" => { "eq" => "F" }
}
)
expect(broadcast.reload.status).to eq("running")
expect(broadcast.audio_file).to be_attached
expect(broadcast.beneficiaries).to match_array([ female_beneficiary ])
expect(broadcast.delivery_attempts.count).to eq(1)
expect(broadcast.delivery_attempts.first.beneficiary).to eq(female_beneficiary)
Expand Down

0 comments on commit 5d57e4f

Please sign in to comment.