5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 15:36:22 +00:00
panel/test/integration/editor_test.rb

77 lines
2 KiB
Ruby
Raw Permalink Normal View History

2019-09-02 16:46:30 +00:00
# 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
skip
2019-09-02 16:46:30 +00:00
content = <<~CONTENT
<h1>Hola</h1>
<p>Qué <em>onda?</em>, <strong>estamos al aire</strong></p>
<blockquote>Una cita</blockquote>
<img src="https://sutty.nl/logo.png" alt="Logo de Sutty"/>
CONTENT
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,
2019-09-02 16:46:30 +00:00
content: content
}
}
2019-10-17 19:18:38 +00:00
@post = @site.posts.first
2019-09-02 16:46:30 +00:00
assert_equal md_content.strip, @post.content.value
end
test 'convertir trix' do
skip
2019-09-02 16:46:30 +00:00
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,
2019-09-02 16:46:30 +00:00
content: trix_orig
}
}
2019-10-17 19:18:38 +00:00
@post = @site.posts.first
2019-09-02 16:46:30 +00:00
assert_equal trix_md.strip, @post.content.value
end
end