# frozen_string_literal: true require 'test_helper' class EditorTest < ActionDispatch::IntegrationTest setup do @rol = create :rol @site = @rol.site @usuarie = @rol.usuarie @authorization = { Authorization: ActionController::HttpAuthentication::Basic .encode_credentials(@usuarie.email, @usuarie.password) } end teardown do @site.destroy end test 'al enviar html se guarda markdown' do content = <<~CONTENT
Qué onda?, estamos al aire
Una citaCONTENT md_content = <<~MARKDOWN # Hola Qué _onda?_, **estamos al aire** > Una cita ![Logo de Sutty](https://sutty.nl/logo.png) MARKDOWN post site_posts_url(@site), headers: @authorization, params: { post: { title: SecureRandom.hex, description: SecureRandom.hex, content: content } } @post = @site.posts.first assert_equal md_content.strip, @post.content.value end test 'convertir trix' do path = Rails.root.join('test', 'fixtures', 'files') trix_orig = File.read(File.join(path, 'trix.txt')) trix_md = File.read(File.join(path, 'trix.md')) post site_posts_url(@site), headers: @authorization, params: { post: { title: SecureRandom.hex, description: SecureRandom.hex, content: trix_orig } } @post = @site.posts.first assert_equal trix_md.strip, @post.content.value end end