]> git.openstreetmap.org Git - rails.git/blob - test/helpers/note_helper_test.rb
Merge remote-tracking branch 'upstream/pull/3975'
[rails.git] / test / helpers / note_helper_test.rb
1 require "test_helper"
2
3 class NoteHelperTest < ActionView::TestCase
4   include ERB::Util
5   include ApplicationHelper
6
7   def test_note_event
8     date = Time.utc(2014, 3, 5, 21, 37, 45)
9     user = create(:user)
10
11     assert_match %r{^Created by anonymous <abbr title="Wed, 05 Mar 2014 21:37:45 \+0000"><span title=" 5 March 2014 at 21:37">.* ago</span></abbr>$}, note_event("opened", date, nil)
12     assert_match %r{^Resolved by <a href="/user/#{ERB::Util.u(user.display_name)}">#{user.display_name}</a> <abbr title="Wed, 05 Mar 2014 21:37:45 \+0000"><span title=" 5 March 2014 at 21:37">.* ago</span></abbr>$}, note_event("closed", date, user)
13   end
14
15   def test_note_author
16     deleted_user = create(:user, :deleted)
17     user = create(:user)
18
19     assert_equal "", note_author(nil)
20     assert_equal "deleted", note_author(deleted_user)
21     assert_equal "<a href=\"/user/#{ERB::Util.u(user.display_name)}\">#{user.display_name}</a>", note_author(user)
22     assert_equal "<a href=\"http://test.host/user/#{ERB::Util.u(user.display_name)}\">#{user.display_name}</a>", note_author(user, :only_path => false)
23   end
24
25   def test_disappear_in
26     note_closed_date = Time.utc(2022, 1, 1, 12, 0, 0)
27     note = create(:note, :closed_at => note_closed_date)
28
29     travel_to note_closed_date + 1.day do
30       assert_match %r{^<span title=" 8 January 2022 at 12:00">6 days</span>$}, disappear_in(note)
31     end
32   end
33 end