File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class Transcript < ApplicationRecord
2222 has_many :tasks , as : :owner
2323
2424 before_validation :initialize_attributes , on : :create
25+ after_save :publish!
2526
2627 validates :original_url , presence : true
2728
@@ -98,6 +99,10 @@ def copy_media(force = false)
9899 end
99100 end
100101
102+ def publish!
103+ episode &.publish! if status_complete? && status_previously_changed?
104+ end
105+
101106 def retryable?
102107 if %w[ started created processing retrying ] . include? ( status )
103108 last_event = task &.updated_at || updated_at || Time . now
Original file line number Diff line number Diff line change 5757 end
5858 end
5959
60+ describe "#publish!" do
61+ let ( :transcript ) { create ( :transcript , status : "started" ) }
62+
63+ it "publishes the episode when complete and status has changed" do
64+ publish = Minitest ::Mock . new
65+ publish . expect ( :call , nil ) { raise "should not have called" }
66+
67+ transcript . episode . stub ( :publish! , publish ) do
68+ transcript . update ( status : "processing" )
69+ end
70+
71+ publish = Minitest ::Mock . new
72+ publish . expect ( :call , nil )
73+ transcript . episode . stub ( :publish! , publish ) do
74+ transcript . update ( status : "complete" )
75+ end
76+
77+ assert publish . verify
78+ end
79+ end
80+
6081 describe "rss_mime_type" do
6182 it "returns the mime type for the transcript format" do
6283 assert_equal "text/html" , transcript . rss_mime_type
You can’t perform that action at this time.
0 commit comments