X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e9e4b10473fa536cdb840303ee4afccf71c69329..507c395f51c20c3c0d5375313ea1ca0ed4156c75:/test/helpers/note_helper_test.rb diff --git a/test/helpers/note_helper_test.rb b/test/helpers/note_helper_test.rb index 75a0e521e..8b8173694 100644 --- a/test/helpers/note_helper_test.rb +++ b/test/helpers/note_helper_test.rb @@ -5,11 +5,28 @@ class NoteHelperTest < ActionView::TestCase include ApplicationHelper def test_note_event - date = Time.new(2014, 3, 5, 21, 37, 45, "+00:00") + date = Time.utc(2014, 3, 5, 21, 37, 45) user = create(:user) - assert_match %r{^Created by anonymous .* ago$}, note_event("opened", date, nil) - assert_match %r{^Resolved by #{user.display_name} .* ago$}, note_event("closed", date, user) + note_event_dom = Rails::Dom::Testing.html_document_fragment.parse "
#{note_event('opened', date, nil)}
" + assert_dom note_event_dom, ":root", :text => /^Created by anonymous .* ago$/ do + assert_dom "> a", :count => 0 + assert_dom "> time", :count => 1 do + assert_dom "> @title", "5 March 2014 at 21:37" + assert_dom "> @datetime", "2014-03-05T21:37:45Z" + end + end + + note_event_dom = Rails::Dom::Testing.html_document_fragment.parse "
#{note_event('closed', date, user)}
" + assert_dom note_event_dom, ":root", :text => /^Resolved by #{user.display_name} .* ago$/ do + assert_dom "> a", :count => 1, :text => user.display_name do + assert_dom "> @href", "/user/#{ERB::Util.u(user.display_name)}" + end + assert_dom "> time", :count => 1 do + assert_dom "> @title", "5 March 2014 at 21:37" + assert_dom "> @datetime", "2014-03-05T21:37:45Z" + end + end end def test_note_author @@ -17,17 +34,17 @@ class NoteHelperTest < ActionView::TestCase user = create(:user) assert_equal "", note_author(nil) + assert_equal "deleted", note_author(deleted_user) - assert_equal "#{user.display_name}", note_author(user) - assert_equal "#{user.display_name}", note_author(user, :only_path => false) - end - def test_disappear_in - note_closed_date = Time.new(2022, 1, 1, 12, 0, 0, "+00:00") - note = create(:note, :closed_at => note_closed_date) + note_author_dom = Rails::Dom::Testing.html_document_fragment.parse note_author(user) + assert_dom note_author_dom, "a:root", :text => user.display_name do + assert_dom "> @href", "/user/#{ERB::Util.u(user.display_name)}" + end - travel_to note_closed_date + 1.day do - assert_match %r{^6 days$}, disappear_in(note) + note_author_dom = Rails::Dom::Testing.html_document_fragment.parse note_author(user, :only_path => false) + assert_dom note_author_dom, "a:root", :text => user.display_name do + assert_dom "> @href", "http://test.host/user/#{ERB::Util.u(user.display_name)}" end end end