@@ -84,27 +84,30 @@ class PublishingApiDocumentRepublishingJobIntegrationTest < ActiveSupport::TestC
8484 publication_presenter = PublishingApiPresenters . presenter_for ( edition , update_type : "republish" )
8585 draft_publication_presenter = PublishingApiPresenters . presenter_for ( draft_edition , update_type : "republish" )
8686 html_attachment_presenter = PublishingApiPresenters . presenter_for ( edition . attachments . first , update_type : "republish" )
87- draft_html_attachment_presenter = PublishingApiPresenters . presenter_for ( draft_edition . attachments . first , update_type : "republish" )
8887
8988 WebMock . reset!
9089
90+ # The live edition and its new draft share the HTML attachment's content_id and,
91+ # now that neither carries an auth bypass token, present identical content, so the
92+ # attachment content is PUT once per edition version.
93+ html_attachment_content_request = stub_publishing_api_put_content ( html_attachment_presenter . content_id , html_attachment_presenter . content )
94+
9195 requests = [
9296 stub_publishing_api_patch_links ( publication_presenter . content_id , links : publication_presenter . links ) ,
9397 stub_publishing_api_put_content ( publication_presenter . content_id , with_locale ( :en ) { publication_presenter . content } ) ,
9498 stub_publishing_api_put_content ( publication_presenter . content_id , with_locale ( :es ) { publication_presenter . content } ) ,
9599 stub_publishing_api_publish ( publication_presenter . content_id , locale : "en" , update_type : nil ) ,
96100 stub_publishing_api_publish ( publication_presenter . content_id , locale : "es" , update_type : nil ) ,
97- stub_publishing_api_put_content ( html_attachment_presenter . content_id , html_attachment_presenter . content ) ,
98101 stub_publishing_api_patch_links ( html_attachment_presenter . content_id , links : html_attachment_presenter . links ) ,
99102 stub_publishing_api_publish ( html_attachment_presenter . content_id , locale : "en" , update_type : nil ) ,
100103 stub_publishing_api_put_content ( draft_publication_presenter . content_id , with_locale ( :en ) { draft_publication_presenter . content } ) ,
101104 stub_publishing_api_put_content ( draft_publication_presenter . content_id , with_locale ( :es ) { draft_publication_presenter . content } ) ,
102- stub_publishing_api_put_content ( draft_html_attachment_presenter . content_id , draft_html_attachment_presenter . content ) ,
103105 ]
104106
105107 PublishingApiDocumentRepublishingJob . new . perform ( edition . document . id , false )
106108
107109 assert_all_requested ( requests )
110+ assert_requested ( html_attachment_content_request , times : 2 )
108111 end
109112
110113 test "Should only publish live edition when document is published with invalid draft" do
@@ -195,10 +198,14 @@ class PublishingApiDocumentRepublishingJobIntegrationTest < ActiveSupport::TestC
195198 publication_presenter = PublishingApiPresenters . presenter_for ( edition , update_type : "republish" )
196199 draft_publication_presenter = PublishingApiPresenters . presenter_for ( draft_edition , update_type : "republish" )
197200 html_attachment_presenter = PublishingApiPresenters . presenter_for ( edition . attachments . first , update_type : "republish" )
198- draft_html_attachment_presenter = PublishingApiPresenters . presenter_for ( draft_edition . attachments . first , update_type : "republish" )
199201
200202 WebMock . reset!
201203
204+ # The live edition and its new draft share the HTML attachment's content_id and,
205+ # now that neither carries an auth bypass token, present identical content, so the
206+ # attachment content is PUT once per edition version.
207+ html_attachment_content_request = stub_publishing_api_put_content ( html_attachment_presenter . content_id , html_attachment_presenter . content )
208+
202209 requests = [
203210 stub_publishing_api_put_content ( publication_presenter . content_id , publication_presenter . content ) ,
204211 stub_publishing_api_put_content ( publication_presenter . content_id , with_locale ( :es ) { publication_presenter . content } ) ,
@@ -212,7 +219,6 @@ class PublishingApiDocumentRepublishingJobIntegrationTest < ActiveSupport::TestC
212219 locale : "es" ,
213220 allow_draft : true ,
214221 } ) ,
215- stub_publishing_api_put_content ( html_attachment_presenter . content_id , html_attachment_presenter . content ) ,
216222 stub_publishing_api_patch_links ( html_attachment_presenter . content_id , links : html_attachment_presenter . links ) ,
217223 stub_publishing_api_unpublish ( html_attachment_presenter . content_id , body : {
218224 type : "redirect" ,
@@ -222,12 +228,12 @@ class PublishingApiDocumentRepublishingJobIntegrationTest < ActiveSupport::TestC
222228 } ) ,
223229 stub_publishing_api_put_content ( draft_publication_presenter . content_id , with_locale ( :en ) { draft_publication_presenter . content } ) ,
224230 stub_publishing_api_put_content ( draft_publication_presenter . content_id , with_locale ( :es ) { draft_publication_presenter . content } ) ,
225- stub_publishing_api_put_content ( draft_html_attachment_presenter . content_id , draft_html_attachment_presenter . content ) ,
226231 ]
227232
228233 PublishingApiDocumentRepublishingJob . new . perform ( edition . document . id , false )
229234
230235 assert_all_requested ( requests )
236+ assert_requested ( html_attachment_content_request , times : 2 )
231237 end
232238
233239 test "Should only unpublish live edition when document is unpublished with invalid draft" do
0 commit comments