@@ -97,11 +97,13 class Changeset < ActiveRecord::Base | |||||
97 |
|
97 | |||
98 | TIMELOG_RE = / |
|
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 | (\d+):(\d+) |
|
104 | (\d+):(\d+) | |
103 | | |
|
105 | | | |
104 | ((\d+)(h|hours?))?((\d+)(m|min)?)? |
|
106 | (\d+([\.,]\d+)?)h? | |
105 | ) |
|
107 | ) | |
106 | /x |
|
108 | /x | |
107 |
|
109 |
@@ -72,9 +72,24 class ChangesetTest < ActiveSupport::TestCase | |||||
72 | Setting.commit_ref_keywords = '*' |
|
72 | Setting.commit_ref_keywords = '*' | |
73 | Setting.commit_logtime_enabled = '1' |
|
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 | c = Changeset.new(:repository => Project.find(1).repository, |
|
90 | c = Changeset.new(:repository => Project.find(1).repository, | |
76 | :committed_on => 24.hours.ago, |
|
91 | :committed_on => 24.hours.ago, | |
77 |
:comments => |
|
92 | :comments => "Worked on this issue #1 @#{syntax}", | |
78 | :revision => '520', |
|
93 | :revision => '520', | |
79 | :user => User.find(2)) |
|
94 | :user => User.find(2)) | |
80 | assert_difference 'TimeEntry.count' do |
|
95 | assert_difference 'TimeEntry.count' do | |
@@ -86,11 +101,12 class ChangesetTest < ActiveSupport::TestCase | |||||
86 | assert_equal 1, time.issue_id |
|
101 | assert_equal 1, time.issue_id | |
87 | assert_equal 1, time.project_id |
|
102 | assert_equal 1, time.project_id | |
88 | assert_equal 2, time.user_id |
|
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 | assert_equal Date.yesterday, time.spent_on |
|
105 | assert_equal Date.yesterday, time.spent_on | |
91 | assert time.activity.is_default? |
|
106 | assert time.activity.is_default? | |
92 | assert time.comments.include?('r520'), "r520 was expected in time_entry comments: #{time.comments}" |
|
107 | assert time.comments.include?('r520'), "r520 was expected in time_entry comments: #{time.comments}" | |
93 | end |
|
108 | end | |
|
109 | end | |||
94 |
|
110 | |||
95 | def test_ref_keywords_closing_with_timelog |
|
111 | def test_ref_keywords_closing_with_timelog | |
96 | Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id |
|
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 | c = Changeset.new(:repository => Project.find(1).repository, |
|
117 | c = Changeset.new(:repository => Project.find(1).repository, | |
102 | :committed_on => Time.now, |
|
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 | :user => User.find(2)) |
|
120 | :user => User.find(2)) | |
105 | assert_difference 'TimeEntry.count', 2 do |
|
121 | assert_difference 'TimeEntry.count', 2 do | |
106 | c.scan_comment_for_issue_ids |
|
122 | c.scan_comment_for_issue_ids |
General Comments 0
You need to be logged in to leave comments.
Login now