Skip to content

Commit

Permalink
Coverage for the publishing->attempt reset
Browse files Browse the repository at this point in the history
  • Loading branch information
svevang committed Oct 3, 2024
1 parent b470697 commit 67012e6
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions test/models/apple/publisher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,33 @@
end

describe "#publish_drafting!" do
let(:episode1) { build(:uploaded_apple_episode, show: apple_publisher.show, api_response: build(:apple_episode_api_response, publishing_state: "DRAFTING")) }
let(:episode2) { build(:uploaded_apple_episode, show: apple_publisher.show, api_response: build(:apple_episode_api_response, publishing_state: "DRAFTING")) }
let(:episodes) { [episode1, episode2] }

it "should call the episode publish drafting class method" do
mock = Minitest::Mock.new
mock.expect(:call, [], [apple_publisher.api, apple_publisher.show, [episode1]])
mock.expect(:call, [], [Apple::Api, Apple::Show, episodes])

Apple::Episode.stub(:publish, mock) do
apple_publisher.publish_drafting!([episode])
apple_publisher.publish_drafting!(episodes)
end

assert mock.verify
end

it "should reset the asset processing attempts" do
episodes.each do |ep|
ep.feeder_episode.apple_update_delivery_status(asset_processing_attempts: 3)
end
mock = Minitest::Mock.new
mock.expect(:call, [], [Apple::Api, Apple::Show, episodes])

Apple::Episode.stub(:publish, mock) { apple_publisher.publish_drafting!(episodes) }

assert_equal 0, episode1.delivery_status.asset_processing_attempts
assert_equal 0, episode2.delivery_status.asset_processing_attempts
end
end

describe "#wait_for_upload_processing" do
Expand Down

0 comments on commit 67012e6

Please sign in to comment.