3 class ApplicationHelperTest < ActionView::TestCase
 
   4   attr_accessor :current_user
 
  15     %w[http://example.com/test ftp://example.com/test https://example.com/test].each do |link|
 
  16       text = "Test #{link} is <b>made</b> into a link"
 
  19       assert html.html_safe?
 
  20       assert_dom_equal "Test <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> is <b>made</b> into a link", html
 
  22       html = linkify(text.html_safe)
 
  23       assert html.html_safe?
 
  24       assert_dom_equal "Test <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> is <b>made</b> into a link", html
 
  27     %w[test@example.com mailto:test@example.com].each do |link|
 
  28       text = "Test #{link} is not <b>made</b> into a link"
 
  31       assert html.html_safe?
 
  32       assert_dom_equal "Test #{link} is not <b>made</b> into a link", html
 
  34       html = linkify(text.html_safe)
 
  35       assert html.html_safe?
 
  36       assert_dom_equal "Test #{link} is not <b>made</b> into a link", html
 
  41     link = rss_link_to(:controller => :diary_entries, :action => :rss)
 
  42     assert_dom_equal "<a class=\"rsssmall\" href=\"/diary/rss\"><img border=\"0\" height=\"16\" src=\"/images/RSS.png\" width=\"16\" /></a>", link
 
  46     link = atom_link_to(:controller => :changesets, :action => :feed)
 
  47     assert_dom_equal "<a class=\"rsssmall\" href=\"/history/feed\"><img border=\"0\" height=\"16\" src=\"/images/RSS.png\" width=\"16\" /></a>", link
 
  50   def test_richtext_area
 
  51     html = richtext_area(:message, :body, :cols => 40, :rows => 20)
 
  56     assert_equal "ltr", dir
 
  59     assert_equal "rtl", dir
 
  64     assert_equal "rtl", dir
 
  67     assert_equal "ltr", dir
 
  71   def test_friendly_date
 
  72     date = friendly_date(Time.new(2014, 3, 5, 18, 58, 23))
 
  73     assert_match %r{^<span title=" *5 March 2014 at 18:58">.*</span>$}, date
 
  75     date = friendly_date(Time.now - 1.hour)
 
  76     assert_match %r{^<span title=".*">about 1 hour</span>$}, date
 
  78     date = friendly_date(Time.now - 2.days)
 
  79     assert_match %r{^<span title=".*">2 days</span>$}, date
 
  81     date = friendly_date(Time.now - 3.weeks)
 
  82     assert_match %r{^<span title=".*">21 days</span>$}, date
 
  84     date = friendly_date(Time.now - 4.months)
 
  85     assert_match %r{^<span title=".*">4 months</span>$}, date
 
  88   def test_body_class; end
 
  90   def test_current_page_class; end