3 class ApplicationHelperTest < ActionView::TestCase
4 attr_accessor :current_user
7 %w[http://example.com/test ftp://example.com/test https://example.com/test].each do |link|
8 text = "Test #{link} is <b>made</b> into a link"
11 assert_predicate html, :html_safe?
12 assert_dom_equal "Test <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> is <b>made</b> into a link", html
14 html = linkify(text.html_safe)
15 assert_predicate html, :html_safe?
16 assert_dom_equal "Test <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> is <b>made</b> into a link", html
19 %w[test@example.com mailto:test@example.com].each do |link|
20 text = "Test #{link} is not <b>made</b> into a link"
23 assert_predicate html, :html_safe?
24 assert_dom_equal "Test #{link} is not <b>made</b> into a link", html
26 html = linkify(text.html_safe)
27 assert_predicate html, :html_safe?
28 assert_dom_equal "Test #{link} is not <b>made</b> into a link", html
33 link = rss_link_to(:controller => :diary_entries, :action => :rss)
34 assert_dom_equal "<a class=\"rsssmall\" href=\"/diary/rss\"><img border=\"0\" height=\"16\" src=\"/images/RSS.png\" width=\"16\" /></a>", link
38 link = atom_link_to(:controller => :changesets, :action => :feed)
39 assert_dom_equal "<a class=\"rsssmall\" href=\"/history/feed\"><img border=\"0\" height=\"16\" src=\"/images/RSS.png\" width=\"16\" /></a>", link
43 assert_equal "ltr", dir
46 assert_equal "rtl", dir
49 I18n.with_locale "he" do
50 assert_equal "rtl", dir
53 assert_equal "ltr", dir
58 def test_friendly_date
59 date = friendly_date(Time.new(2014, 3, 5, 18, 58, 23).utc)
60 assert_match %r{^<span title=" *5 March 2014 at 18:58">.*</span>$}, date
62 date = friendly_date(Time.now.utc - 1.hour)
63 assert_match %r{^<span title=".*">about 1 hour</span>$}, date
65 date = friendly_date(Time.now.utc - 2.days)
66 assert_match %r{^<span title=".*">2 days</span>$}, date
68 date = friendly_date(Time.now.utc - 3.weeks)
69 assert_match %r{^<span title=".*">21 days</span>$}, date
71 date = friendly_date(Time.now.utc - 4.months)
72 assert_match %r{^<span title=".*">4 months</span>$}, date
75 def test_body_class; end
77 def test_current_page_class; end