From 8a031d19c71dbce39aa92fe8933801c16478a7f0 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Mon, 14 Feb 2022 12:12:02 +0100
Subject: [PATCH] dehydrate

---
 test/fixtures/communication/website.yml |  3 +++
 test/fixtures/university.yml            |  2 ++
 test/models/summernote_test.rb          | 19 ++++++++++++++++++-
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 test/fixtures/communication/website.yml
 create mode 100644 test/fixtures/university.yml

diff --git a/test/fixtures/communication/website.yml b/test/fixtures/communication/website.yml
new file mode 100644
index 000000000..5e9fc0457
--- /dev/null
+++ b/test/fixtures/communication/website.yml
@@ -0,0 +1,3 @@
+test:
+  university: test
+  name: Site de test
diff --git a/test/fixtures/university.yml b/test/fixtures/university.yml
new file mode 100644
index 000000000..0ef3e762f
--- /dev/null
+++ b/test/fixtures/university.yml
@@ -0,0 +1,2 @@
+test:
+  name: Université de test
diff --git a/test/models/summernote_test.rb b/test/models/summernote_test.rb
index 348a45c6c..2079616b6 100644
--- a/test/models/summernote_test.rb
+++ b/test/models/summernote_test.rb
@@ -1,5 +1,22 @@
 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>"
+    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
+  end
 end
-- 
GitLab