Merge remote-tracking branch 'upstream/pull/4349'
This commit is contained in:
commit
2fcee9625d
17 changed files with 56 additions and 54 deletions
|
@ -57,19 +57,36 @@ class ApplicationHelperTest < ActionView::TestCase
|
|||
|
||||
def test_friendly_date
|
||||
date = friendly_date(Time.utc(2014, 3, 5, 18, 58, 23))
|
||||
assert_match %r{^<span title=" *5 March 2014 at 18:58">.*</span>$}, date
|
||||
assert_match %r{^<time title=" *5 March 2014 at 18:58" datetime="2014-03-05T18:58:23Z">.*</time>$}, date
|
||||
|
||||
date = friendly_date(Time.now.utc - 1.hour)
|
||||
assert_match %r{^<span title=".*">about 1 hour</span>$}, date
|
||||
assert_match %r{^<time title=".*">about 1 hour</time>$}, date
|
||||
|
||||
date = friendly_date(Time.now.utc - 2.days)
|
||||
assert_match %r{^<span title=".*">2 days</span>$}, date
|
||||
assert_match %r{^<time title=".*">2 days</time>$}, date
|
||||
|
||||
date = friendly_date(Time.now.utc - 3.weeks)
|
||||
assert_match %r{^<span title=".*">21 days</span>$}, date
|
||||
assert_match %r{^<time title=".*">21 days</time>$}, date
|
||||
|
||||
date = friendly_date(Time.now.utc - 4.months)
|
||||
assert_match %r{^<span title=".*">4 months</span>$}, date
|
||||
assert_match %r{^<time title=".*">4 months</time>$}, date
|
||||
end
|
||||
|
||||
def test_friendly_date_ago
|
||||
date = friendly_date_ago(Time.utc(2014, 3, 5, 18, 58, 23))
|
||||
assert_match %r{^<time title=" *5 March 2014 at 18:58" datetime="2014-03-05T18:58:23Z">.*</time>$}, date
|
||||
|
||||
date = friendly_date_ago(Time.now.utc - 1.hour)
|
||||
assert_match %r{^<time title=".*">about 1 hour ago</time>$}, date
|
||||
|
||||
date = friendly_date_ago(Time.now.utc - 2.days)
|
||||
assert_match %r{^<time title=".*">2 days ago</time>$}, date
|
||||
|
||||
date = friendly_date_ago(Time.now.utc - 3.weeks)
|
||||
assert_match %r{^<time title=".*">21 days ago</time>$}, date
|
||||
|
||||
date = friendly_date_ago(Time.now.utc - 4.months)
|
||||
assert_match %r{^<time title=".*">4 months ago</time>$}, date
|
||||
end
|
||||
|
||||
def test_body_class; end
|
||||
|
|
|
@ -17,11 +17,11 @@ class ChangesetsHelperTest < ActionView::TestCase
|
|||
# We need to explicitly reset the closed_at to some point in the future, and avoid the before_save callback
|
||||
changeset.update_column(:closed_at, Time.now.utc + 1.day) # rubocop:disable Rails/SkipsModelValidations
|
||||
|
||||
assert_match %r{^Created <abbr title="Mon, 01 Jan 2007 00:00:00 \+0000">.*</abbr> by anonymous$}, changeset_details(changeset)
|
||||
assert_match %r{^Created <time title="Mon, 01 Jan 2007 00:00:00 \+0000" datetime="2007-01-01T00:00:00Z">.*</time> by anonymous$}, changeset_details(changeset)
|
||||
|
||||
changeset = create(:changeset, :created_at => Time.utc(2007, 1, 1, 0, 0, 0), :closed_at => Time.utc(2007, 1, 2, 0, 0, 0))
|
||||
user_link = %(<a href="/user/#{ERB::Util.u(changeset.user.display_name)}">#{changeset.user.display_name}</a>)
|
||||
|
||||
assert_match %r{^Closed <abbr title="Created: Mon, 01 Jan 2007 00:00:00 \+0000 Closed: Tue, 02 Jan 2007 00:00:00 \+0000">.*</abbr> by #{user_link}$}, changeset_details(changeset)
|
||||
assert_match %r{^Closed <time title="Created: Mon, 01 Jan 2007 00:00:00 \+0000 Closed: Tue, 02 Jan 2007 00:00:00 \+0000" datetime="2007-01-02T00:00:00Z">.*</time> by #{user_link}$}, changeset_details(changeset)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,8 +8,8 @@ class NoteHelperTest < ActionView::TestCase
|
|||
date = Time.utc(2014, 3, 5, 21, 37, 45)
|
||||
user = create(:user)
|
||||
|
||||
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)
|
||||
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)
|
||||
assert_match %r{^Created by anonymous <time title=" 5 March 2014 at 21:37" datetime="2014-03-05T21:37:45Z">.* ago</time>$}, note_event("opened", date, nil)
|
||||
assert_match %r{^Resolved by <a href="/user/#{ERB::Util.u(user.display_name)}">#{user.display_name}</a> <time title=" 5 March 2014 at 21:37" datetime="2014-03-05T21:37:45Z">.* ago</time>$}, note_event("closed", date, user)
|
||||
end
|
||||
|
||||
def test_note_author
|
||||
|
@ -21,13 +21,4 @@ class NoteHelperTest < ActionView::TestCase
|
|||
assert_equal "<a href=\"/user/#{ERB::Util.u(user.display_name)}\">#{user.display_name}</a>", note_author(user)
|
||||
assert_equal "<a href=\"http://test.host/user/#{ERB::Util.u(user.display_name)}\">#{user.display_name}</a>", note_author(user, :only_path => false)
|
||||
end
|
||||
|
||||
def test_disappear_in
|
||||
note_closed_date = Time.utc(2022, 1, 1, 12, 0, 0)
|
||||
note = create(:note, :closed_at => note_closed_date)
|
||||
|
||||
travel_to note_closed_date + 1.day do
|
||||
assert_match %r{^<span title=" 8 January 2022 at 12:00">6 days</span>$}, disappear_in(note)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,10 +8,10 @@ class UserBlocksHelperTest < ActionView::TestCase
|
|||
assert_equal "Active until the user logs in.", block_status(block)
|
||||
|
||||
block = create(:user_block, :needs_view, :ends_at => Time.now.utc + 1.hour)
|
||||
assert_match %r{^Ends in <span title=".*">about 1 hour</span> and after the user has logged in\.$}, block_status(block)
|
||||
assert_match %r{^Ends in <time title=".*" datetime=".*">about 1 hour</time> and after the user has logged in\.$}, block_status(block)
|
||||
|
||||
block = create(:user_block, :ends_at => Time.now.utc + 1.hour)
|
||||
assert_match %r{^Ends in <span title=".*">about 1 hour</span>\.$}, block_status(block)
|
||||
assert_match %r{^Ends in <time title=".* datetime=".*">about 1 hour</time>\.$}, block_status(block)
|
||||
end
|
||||
|
||||
def test_block_duration_in_words
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue