Skip to content

Commit

Permalink
Guard for nil podcast_container
Browse files Browse the repository at this point in the history
  • Loading branch information
svevang committed Aug 3, 2023
1 parent 79b9e2e commit df1740d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/apple/episode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ def drafting?
end

def container_upload_complete?
feeder_episode.apple_podcast_container.container_upload_satisfied?
return false unless has_container?

podcast_container.container_upload_satisfied?
end

def audio_asset_vendor_id
Expand Down
12 changes: 12 additions & 0 deletions test/models/apple/episode_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@
assert_equal false, ep.synced_with_apple?
end
end

it "should be false when the podcast_container is nil" do
ep = build(:apple_episode)
assert ep.podcast_container.nil?

# it returns early via the guard
ep.stub(:podcast_container, -> { raise "shouldn't happen" }) do
ep.stub(:has_container?, false) do
refute ep.container_upload_complete?
end
end
end
end

describe "#enclosure_filename" do
Expand Down

0 comments on commit df1740d

Please sign in to comment.