Skip to content
Snippets Groups Projects
Commit 03d7b091 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

test dehydrate rehydrate

parent 8a031d19
No related branches found
No related tags found
No related merge requests found
test:
university: test
website: test
title: Test
slug: test
text_new: >
<action-text-attachment sgid="sgid" content-type="image/jpeg" url="http://localhost:3000/dan-gold.jpeg" filename="test.jpg" filesize="352931" width="588" height="746" previewable="true" presentation="gallery"></action-text-attachment>
require "test_helper"
class SummernoteTest < ActiveSupport::TestCase
test "dehydrate" do
post = Communication::Website::Post.new university: university(:test),
website: communication_website(:test),
title: 'test',
slug: 'test'
post.text_new = "<action-text-attachment sgid=\"sgid\" content-type=\"image/jpeg\" url=\"http://localhost:3000/dan-gold.jpeg\" filename=\"test.jpg\" filesize=\"352931\" width=\"588\" height=\"746\" previewable=\"true\" presentation=\"gallery\">
<figure class=\"attachment attachment--preview attachment--jpg\">
<picture>
<source srcset=\"/rails/active_storage/representations/redirect/eyJfcmFpbHMiOns...watchingwindows_com_08.jpg 100w, /rails/active_storage/representations/redirect/eyJfcmFpbHMiOns...watchingwindows_com_08.jpg 200w\" type=\"image/webp\">
<source srcset=\"/rails/active_storage/representations/redirect/eyJfcmFpbHMiOns...watchingwindows_com_08.jpg 100w, /rails/active_storage/representations/redirect/eyJfcmFpbHMiOns...watchingwindows_com_08.jpg\" type=\"image/jpeg\">
<img src=\"/rails/active_storage/representations/redirect/eyJfcmFpbHMiOns...watchingwindows_com_08.jpg\" loading=\"lazy\" decoding=\"async\" width=\"800\">
</picture>
</figure>
</action-text-attachment>"
HTML_HYDRATED = "<action-text-attachment sgid=\"sgid\" content-type=\"image/jpeg\" url=\"http://localhost:3000/dan-gold.jpeg\" filename=\"test.jpg\" filesize=\"352931\" width=\"588\" height=\"746\" previewable=\"true\" presentation=\"gallery\"><figure class=\"attachment attachment--preview\">\n <img width=\"588\" height=\"746\" src=\"http://localhost:3000/dan-gold.jpeg\">\n</figure></action-text-attachment>\n"
HTML_DEHYDRATED = "<action-text-attachment sgid=\"sgid\" content-type=\"image/jpeg\" url=\"http://localhost:3000/dan-gold.jpeg\" filename=\"test.jpg\" filesize=\"352931\" width=\"588\" height=\"746\" previewable=\"true\" presentation=\"gallery\"></action-text-attachment>"
test "dehydrate actiontext" do
post = communication_website_post(:test)
post.text_new = HTML_HYDRATED
post.save
post.reload
assert_equal "<action-text-attachment sgid=\"sgid\" content-type=\"image/jpeg\" url=\"http://localhost:3000/dan-gold.jpeg\" filename=\"test.jpg\" filesize=\"352931\" width=\"588\" height=\"746\" previewable=\"true\" presentation=\"gallery\"></action-text-attachment>", post.text_new_before_type_cast
assert_equal HTML_DEHYDRATED, post.text_new_before_type_cast
end
test "rehydrate actiontext" do
assert_equal HTML_HYDRATED, communication_website_post(:test).text_new.to_s
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment