Skip to content

Commit

Permalink
Simplifying logic of asset checking
Browse files Browse the repository at this point in the history
Instead of relying on splitting, we could just use the filename that we actually pass through to asset manager to do the checks
  • Loading branch information
minhngocd committed Nov 22, 2024
1 parent f8f61b3 commit f4505f6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
4 changes: 1 addition & 3 deletions app/models/call_for_evidence_response_form_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def filename
end

def assets_match_updated_image_filename
return false unless carrierwave_file

assets.all? { |asset| asset.filename.include?(carrierwave_file.split("/").last) }
assets.all? { |asset| asset.filename.include?(filename) } if filename
end
end
4 changes: 1 addition & 3 deletions app/models/consultation_response_form_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def filename
end

def assets_match_updated_image_filename
return false unless carrierwave_file

assets.all? { |asset| asset.filename.include?(carrierwave_file.split("/").last) }
assets.all? { |asset| asset.filename.include?(filename) } if filename
end
end
4 changes: 1 addition & 3 deletions app/models/featured_image_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ def republish_on_assets_ready
private

def assets_match_updated_image_filename
return false unless carrierwave_image

assets.all? { |asset| asset.filename.include?(carrierwave_image.split("/").last) }
assets.all? { |asset| asset.filename.include?(filename) } if filename
end
end
4 changes: 1 addition & 3 deletions app/models/promotional_feature_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ def republish_organisation
end

def assets_match_updated_image_filename
return false unless self[:image]

assets.all? { |asset| asset.filename.include?(self[:image].split("/").last) }
assets.all? { |asset| asset.filename.include?(self[:image]) } if self[:image]
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class CallForEvidenceResponseFormDataTest < ActiveSupport::TestCase
call_for_evidence_response_form_data.update!(
call_for_evidence_response_form_data.attributes.merge(
file: upload_fixture("copy:#{call_for_evidence_response_form_data.filename}"),
),
)
),
)

assert_not call_for_evidence_response_form_data.all_asset_variants_uploaded?
end
Expand Down

0 comments on commit f4505f6

Please sign in to comment.