##// END OF EJS Templates
Fixes syntax for time logging in commit messages (#7630, #7718)....
Jean-Philippe Lang -
r4831:2d115bbe7071
parent child
Show More
@@ -97,11 +97,13 class Changeset < ActiveRecord::Base
97 97
98 98 TIMELOG_RE = /
99 99 (
100 (\d+([.,]\d+)?)h?
100 ((\d+)(h|hours?))((\d+)(m|min)?)?
101 |
102 ((\d+)(h|hours?|m|min))
101 103 |
102 104 (\d+):(\d+)
103 105 |
104 ((\d+)(h|hours?))?((\d+)(m|min)?)?
106 (\d+([\.,]\d+)?)h?
105 107 )
106 108 /x
107 109
@@ -72,9 +72,24 class ChangesetTest < ActiveSupport::TestCase
72 72 Setting.commit_ref_keywords = '*'
73 73 Setting.commit_logtime_enabled = '1'
74 74
75 {
76 '2' => 2.0,
77 '2h' => 2.0,
78 '2hours' => 2.0,
79 '15m' => 0.25,
80 '15min' => 0.25,
81 '3h15' => 3.25,
82 '3h15m' => 3.25,
83 '3h15min' => 3.25,
84 '3:15' => 3.25,
85 '3.25' => 3.25,
86 '3.25h' => 3.25,
87 '3,25' => 3.25,
88 '3,25h' => 3.25,
89 }.each do |syntax, expected_hours|
75 90 c = Changeset.new(:repository => Project.find(1).repository,
76 91 :committed_on => 24.hours.ago,
77 :comments => 'Worked on this issue #1 @2h',
92 :comments => "Worked on this issue #1 @#{syntax}",
78 93 :revision => '520',
79 94 :user => User.find(2))
80 95 assert_difference 'TimeEntry.count' do
@@ -86,11 +101,12 class ChangesetTest < ActiveSupport::TestCase
86 101 assert_equal 1, time.issue_id
87 102 assert_equal 1, time.project_id
88 103 assert_equal 2, time.user_id
89 assert_equal 2.0, time.hours
104 assert_equal expected_hours, time.hours, "@#{syntax} should be logged as #{expected_hours} hours but was #{time.hours}"
90 105 assert_equal Date.yesterday, time.spent_on
91 106 assert time.activity.is_default?
92 107 assert time.comments.include?('r520'), "r520 was expected in time_entry comments: #{time.comments}"
93 108 end
109 end
94 110
95 111 def test_ref_keywords_closing_with_timelog
96 112 Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id
@@ -100,7 +116,7 class ChangesetTest < ActiveSupport::TestCase
100 116
101 117 c = Changeset.new(:repository => Project.find(1).repository,
102 118 :committed_on => Time.now,
103 :comments => 'This is a comment. Fixes #1 @2.5, #2 @1',
119 :comments => 'This is a comment. Fixes #1 @4.5, #2 @1',
104 120 :user => User.find(2))
105 121 assert_difference 'TimeEntry.count', 2 do
106 122 c.scan_comment_for_issue_ids
General Comments 0
You need to be logged in to leave comments. Login now