aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/content_test.rb
blob: 59beb323cf5b688bb64a66648fff2204ccdcf213 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require_relative '../test_helper'

module ActionText
  class ContentTest < ActiveSupport::TestCase
    test "plain text conversion" do
      message = Message.new(subject: "Greetings", content: "<h1>Hello world</h1>")
      assert_equal "Hello world", message.content.body.to_plain_text
    end

    test "without content" do
      message = Message.create!(subject: "Greetings")
      assert message.content.body.nil?
    end

    test "embed extraction" do
      blob = create_file_blob(filename: "racecar.jpg", content_type: "image/jpg")
      message = Message.create!(subject: "Greetings", content: ActionText::Content.new("Hello world").append_attachables(blob))
      assert_equal "racecar.jpg", message.content.embeds.first.filename.to_s
    end
  end
end