tiny_mce_article_test.rb
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 <a href='www.invalid.com' target='_blank'>link</a> 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 => "<a href='www.invalid.com?param1=value¶m2=value'>link</a>", :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 <!-- comment --> article ...")
assert_equal "the <!-- comment --> article ...", article.body
end
end