# encoding: UTF-8
require_relative "../test_helper"
class TinyMceArticleTest < ActiveSupport::TestCase
def setup
super
@user = User.current = create_user('zezinho')
@profile = @user.person
end
attr_reader :profile
# this test can be removed when we get real tests for TinyMceArticle
should 'be an article' do
assert_kind_of TextArticle, TinyMceArticle.new
end
should 'define description' do
assert_kind_of String, TinyMceArticle.description
end
should 'define short description' do
assert_kind_of String, TinyMceArticle.short_description
end
should 'not sanitize target attribute' do
article = create(TinyMceArticle, :name => 'open link in new window', :body => "open link in new window", :profile => profile)
assert_tag_in_string article.body, :tag => 'a', :attributes => {:target => '_blank'}
end
should 'not translate & to amp; over times' do
article = create(TinyMceArticle, :name => 'link', :body => "link", :profile => profile)
assert article.save
assert_no_match(/&/, article.body)
assert_match(/&/, article.body)
end
should 'not escape comments from tiny mce article body' do
article = create(TinyMceArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "the article ...")
assert_equal "the article ...", article.body
end
should 'convert entities characters to UTF-8 instead of ISO-8859-1' do
article = create(TinyMceArticle, :profile => profile, :name => 'teste ' + Time.now.to_s, :body => 'link')
assert(article.body.is_utf8?, "%s expected to be valid UTF-8 content" % article.body.inspect)
end
should 'remove iframe if it is not from a trusted site' do
article = create(TinyMceArticle, :profile => profile, :name => 'article', :abstract => 'abstract', :body => "")
assert_equal "", article.body
end
should 'not mess with