Skip to content
Snippets Groups Projects
summernote_test.rb 1.19 KiB
Newer Older
Arnaud Levy's avatar
Arnaud Levy committed
require "test_helper"

class SummernoteTest < ActiveSupport::TestCase
Arnaud Levy's avatar
Arnaud Levy committed
  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
Sébastien Gaya's avatar
Sébastien Gaya committed
    post = communication_website_posts(:test_post)
Arnaud Levy's avatar
Arnaud Levy committed
    post.text = HTML_HYDRATED
Arnaud Levy's avatar
Arnaud Levy committed
    post.save
    post.reload
Arnaud Levy's avatar
Arnaud Levy committed
    assert_equal HTML_DEHYDRATED, post.text_before_type_cast
Arnaud Levy's avatar
Arnaud Levy committed
  end

  test "rehydrate actiontext" do
Sébastien Gaya's avatar
Sébastien Gaya committed
    post = communication_website_posts(:test_post)
Arnaud Levy's avatar
Arnaud Levy committed
    post.text = HTML_DEHYDRATED
Arnaud Levy's avatar
Arnaud Levy committed
    post.save
    post.reload
Sébastien Gaya's avatar
Sébastien Gaya committed
    assert_equal HTML_HYDRATED, communication_website_posts(:test_post).text.to_s
Arnaud Levy's avatar
Arnaud Levy committed
  end
Arnaud Levy's avatar
Arnaud Levy committed
 end