Skip to content

Commit 29b7840

Browse files
unoduetrecatalinailie
authored andcommitted
Use asset_manager_id instead of attachment_data_id
When sending attachment information to publishing api, use asset_manager_id instead of attachment_data_id, as this is the id that the asset manager expects.
1 parent 9aa6f98 commit 29b7840

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

app/models/file_attachment.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def publishing_api_details_for_format
5555
filename:,
5656
number_of_pages:,
5757
preview_url:,
58-
attachment_data_id:,
58+
asset_manager_id:,
5959
}
6060
end
6161

@@ -67,10 +67,10 @@ def alternative_format_contact_email
6767
nil
6868
end
6969

70-
def attachment_data_id
70+
def asset_manager_id
7171
return unless csv? && attachable.is_a?(Edition) && attachment_data.all_asset_variants_uploaded?
7272

73-
attachment_data.id
73+
attachment_data.assets.first.asset_manager_id
7474
end
7575

7676
def preview_url

test/unit/app/models/file_attachment_test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ def assert_delegated(attachment, method)
6969
assert_equal Plek.asset_root + "/media/#{attachment.attachment_data.id}/sample.csv/preview", attachment.publishing_api_details_for_format[:preview_url]
7070
end
7171

72-
test "return media attachment_data_id if all_asset_variants_uploaded?" do
72+
test "#asset_manager_id returns asset manager id if all_asset_variants_uploaded?" do
7373
attachment = create(:csv_attachment, attachable: create(:edition))
74-
assert_equal attachment.attachment_data.id, attachment.publishing_api_details_for_format[:attachment_data_id]
74+
assert_not_nil attachment.attachment_data.assets.first.asset_manager_id
75+
assert_equal attachment.attachment_data.assets.first.asset_manager_id, attachment.publishing_api_details_for_format[:asset_manager_id]
7576
end
7677
end

0 commit comments

Comments
 (0)