@@ -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,24 +72,40 class ChangesetTest < ActiveSupport::TestCase | |||
|
72 | 72 | Setting.commit_ref_keywords = '*' |
|
73 | 73 | Setting.commit_logtime_enabled = '1' |
|
74 | 74 | |
|
75 | c = Changeset.new(:repository => Project.find(1).repository, | |
|
76 | :committed_on => 24.hours.ago, | |
|
77 | :comments => 'Worked on this issue #1 @2h', | |
|
78 | :revision => '520', | |
|
79 | :user => User.find(2)) | |
|
80 | assert_difference 'TimeEntry.count' do | |
|
81 | c.scan_comment_for_issue_ids | |
|
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| | |
|
90 | c = Changeset.new(:repository => Project.find(1).repository, | |
|
91 | :committed_on => 24.hours.ago, | |
|
92 | :comments => "Worked on this issue #1 @#{syntax}", | |
|
93 | :revision => '520', | |
|
94 | :user => User.find(2)) | |
|
95 | assert_difference 'TimeEntry.count' do | |
|
96 | c.scan_comment_for_issue_ids | |
|
97 | end | |
|
98 | assert_equal [1], c.issue_ids.sort | |
|
99 | ||
|
100 | time = TimeEntry.first(:order => 'id desc') | |
|
101 | assert_equal 1, time.issue_id | |
|
102 | assert_equal 1, time.project_id | |
|
103 | assert_equal 2, time.user_id | |
|
104 | assert_equal expected_hours, time.hours, "@#{syntax} should be logged as #{expected_hours} hours but was #{time.hours}" | |
|
105 | assert_equal Date.yesterday, time.spent_on | |
|
106 | assert time.activity.is_default? | |
|
107 | assert time.comments.include?('r520'), "r520 was expected in time_entry comments: #{time.comments}" | |
|
82 | 108 | end |
|
83 | assert_equal [1], c.issue_ids.sort | |
|
84 | ||
|
85 | time = TimeEntry.first(:order => 'id desc') | |
|
86 | assert_equal 1, time.issue_id | |
|
87 | assert_equal 1, time.project_id | |
|
88 | assert_equal 2, time.user_id | |
|
89 | assert_equal 2.0, time.hours | |
|
90 | assert_equal Date.yesterday, time.spent_on | |
|
91 | assert time.activity.is_default? | |
|
92 | assert time.comments.include?('r520'), "r520 was expected in time_entry comments: #{time.comments}" | |
|
93 | 109 | end |
|
94 | 110 | |
|
95 | 111 | def test_ref_keywords_closing_with_timelog |
@@ -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 @ |
|
|
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