require File.dirname(__FILE__) + '/../test_helper' class TinyMceArticleTest < Test::Unit::TestCase def setup Article.rebuild_index @profile = create_user('zezinho').person end attr_reader :profile # this test can be removed when we get real tests for TinyMceArticle should 'be an article' do assert_subclass TextArticle, TinyMceArticle 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 'be found when searching for articles by query' do tma = TinyMceArticle.create!(:name => 'test tinymce article', :body => '---', :profile => profile) assert_includes TinyMceArticle.find_by_contents('article'), tma assert_includes Article.find_by_contents('article'), tma end should 'not sanitize target attribute' do article = TinyMceArticle.create!(: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 = TinyMceArticle.create!(:name => 'link', :body => "link", :profile => profile) assert article.save assert_no_match(/&amp;/, article.body) assert_match(/&/, article.body) end should 'not escape comments from tiny mce article body' do article = TinyMceArticle.create!(: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 = TinyMceArticle.create!(: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 'fix tinymce mess with itheora comments for IE from tiny mce article body' do article = TinyMceArticle.create!(:profile => profile, :name => 'article', :abstract => 'abstract', :body => "the just for ie... ") assert_equal "the just for ie... ", article.body end should 'not mess with ") assert_equal "", article.body end should 'remove iframe if it is not from itheora' do article = TinyMceArticle.create!(:profile => profile, :name => 'article', :abstract => 'abstract', :body => "") assert_equal "", article.body end #TinymMCE convert config={"key":(.*)} in config={"key":(.*)} should 'not replace " with &quot; when adding an Archive.org video' do article = TinyMceArticle.create!(:profile => profile, :name => 'article', :abstract => 'abstract', :body => " ") assert_equal " ", article.body end end