Skip to content

Commit

Permalink
👽️ Envoi la zone de depot en base64
Browse files Browse the repository at this point in the history
  • Loading branch information
marouria committed Oct 4, 2024
1 parent 886e18a commit 2c6d058
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
5 changes: 5 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ def cdn_for(attachment)

ApplicationController.helpers.cdn_for(attachment)
end

def fichier_encode_base64(attachment)
file_content = attachment.download
ApplicationController.helpers.fichier_encode_en_base64(file_content)
end
end
5 changes: 0 additions & 5 deletions app/models/question_clic_dans_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,4 @@ def valide_zone_cliquable_avec_reponse
errors.add(:zone_cliquable, "doit contenir la classe 'bonne_reponse'")
throw(:abort)
end

def fichier_encode_base64(attachment)
file_content = attachment.download
ApplicationController.helpers.fichier_encode_en_base64(file_content)
end
end
2 changes: 1 addition & 1 deletion app/models/question_glisser_deposer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class QuestionGlisserDeposer < Question

def as_json(_options = nil)
json = base_json
json['zone_depot_url'] = cdn_for(zone_depot) if zone_depot.attached?
json['zone_depot_url'] = fichier_encode_base64(zone_depot) if zone_depot.attached?
json.merge!(json_audio_fields, reponses_fields)
end

Expand Down
4 changes: 1 addition & 3 deletions spec/models/question_glisser_deposer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
expect(json['illustration']).to eql(Rails.application.routes.url_helpers.url_for(
question.illustration
))
expect(json['zone_depot_url']).to eql(Rails.application.routes.url_helpers.url_for(
question.zone_depot
))
expect(json['zone_depot_url']).to start_with('data:image/svg+xml;base64,')
end

describe 'les reponsesNonClassees' do
Expand Down

0 comments on commit 2c6d058

Please sign in to comment.