From 03d7b091712f79efc69ebbd26a3ca08902e2ae60 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 14 Feb 2022 12:34:30 +0100 Subject: [PATCH] test dehydrate rehydrate --- test/fixtures/.keep | 0 test/fixtures/communication/website/post.yml | 7 +++++ test/models/summernote_test.rb | 28 +++++++++----------- 3 files changed, 19 insertions(+), 16 deletions(-) delete mode 100644 test/fixtures/.keep create mode 100644 test/fixtures/communication/website/post.yml diff --git a/test/fixtures/.keep b/test/fixtures/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/fixtures/communication/website/post.yml b/test/fixtures/communication/website/post.yml new file mode 100644 index 000000000..0c08b41e6 --- /dev/null +++ b/test/fixtures/communication/website/post.yml @@ -0,0 +1,7 @@ +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> diff --git a/test/models/summernote_test.rb b/test/models/summernote_test.rb index 2079616b6..e60cf8268 100644 --- a/test/models/summernote_test.rb +++ b/test/models/summernote_test.rb @@ -1,22 +1,18 @@ 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 -- GitLab