3 class NoteHelperTest < ActionView::TestCase
 
   5   include ApplicationHelper
 
   8     date = Time.utc(2014, 3, 5, 21, 37, 45)
 
  11     note_event_dom = Rails::Dom::Testing.html_document_fragment.parse "<div>#{note_event('opened', date, nil)}</div>"
 
  12     assert_dom note_event_dom, ":root", :text => /^Created by anonymous .* ago$/ do
 
  13       assert_dom "> a", :count => 0
 
  14       assert_dom "> time", :count => 1 do
 
  15         assert_dom "> @title", "5 March 2014 at 21:37"
 
  16         assert_dom "> @datetime", "2014-03-05T21:37:45Z"
 
  20     note_event_dom = Rails::Dom::Testing.html_document_fragment.parse "<div>#{note_event('closed', date, user)}</div>"
 
  21     assert_dom note_event_dom, ":root", :text => /^Resolved by #{user.display_name} .* ago$/ do
 
  22       assert_dom "> a", :count => 1, :text => user.display_name do
 
  23         assert_dom "> @href", "/user/#{ERB::Util.u(user.display_name)}"
 
  25       assert_dom "> time", :count => 1 do
 
  26         assert_dom "> @title", "5 March 2014 at 21:37"
 
  27         assert_dom "> @datetime", "2014-03-05T21:37:45Z"
 
  33     deleted_user = create(:user, :deleted)
 
  36     assert_equal "", note_author(nil)
 
  38     assert_equal "deleted", note_author(deleted_user)
 
  40     note_author_dom = Rails::Dom::Testing.html_document_fragment.parse note_author(user)
 
  41     assert_dom note_author_dom, "a:root", :text => user.display_name do
 
  42       assert_dom "> @href", "/user/#{ERB::Util.u(user.display_name)}"
 
  45     note_author_dom = Rails::Dom::Testing.html_document_fragment.parse note_author(user, :only_path => false)
 
  46     assert_dom note_author_dom, "a:root", :text => user.display_name do
 
  47       assert_dom "> @href", "http://test.host/user/#{ERB::Util.u(user.display_name)}"