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