@@ -151,12 +151,16 class Changeset < ActiveRecord::Base | |||
|
151 | 151 | @long_comments || split_comments.last |
|
152 | 152 | end |
|
153 | 153 | |
|
154 | def text_tag | |
|
155 | if scmid? | |
|
154 | def text_tag(ref_project=nil) | |
|
155 | tag = if scmid? | |
|
156 | 156 | "commit:#{scmid}" |
|
157 | 157 | else |
|
158 | 158 | "r#{revision}" |
|
159 | 159 | end |
|
160 | if ref_project && project && ref_project != project | |
|
161 | tag = "#{project.identifier}:#{tag}" | |
|
162 | end | |
|
163 | tag | |
|
160 | 164 | end |
|
161 | 165 | |
|
162 | 166 | # Returns the previous changeset |
@@ -213,7 +217,7 class Changeset < ActiveRecord::Base | |||
|
213 | 217 | # don't change the status is the issue is closed |
|
214 | 218 | return if issue.status && issue.status.is_closed? |
|
215 | 219 | |
|
216 | journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag)) | |
|
220 | journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag(issue.project))) | |
|
217 | 221 | issue.status = status |
|
218 | 222 | unless Setting.commit_fix_done_ratio.blank? |
|
219 | 223 | issue.done_ratio = Setting.commit_fix_done_ratio.to_i |
@@ -232,7 +236,7 class Changeset < ActiveRecord::Base | |||
|
232 | 236 | :hours => hours, |
|
233 | 237 | :issue => issue, |
|
234 | 238 | :spent_on => commit_date, |
|
235 | :comments => l(:text_time_logged_by_changeset, :value => text_tag, | |
|
239 | :comments => l(:text_time_logged_by_changeset, :value => text_tag(issue.project), | |
|
236 | 240 | :locale => Setting.default_language) |
|
237 | 241 | ) |
|
238 | 242 | time_entry.activity = log_time_activity unless log_time_activity.nil? |
@@ -178,6 +178,24 class ChangesetTest < ActiveSupport::TestCase | |||
|
178 | 178 | assert c.issues.first.project != c.project |
|
179 | 179 | end |
|
180 | 180 | |
|
181 | def test_commit_closing_a_subproject_issue | |
|
182 | with_settings :commit_fix_status_id => 5, :commit_fix_keywords => 'closes' do | |
|
183 | issue = Issue.find(5) | |
|
184 | assert !issue.closed? | |
|
185 | assert_difference 'Journal.count' do | |
|
186 | c = Changeset.new(:repository => Project.find(1).repository, | |
|
187 | :committed_on => Time.now, | |
|
188 | :comments => 'closes #5, a subproject issue', | |
|
189 | :revision => '12345') | |
|
190 | assert c.save | |
|
191 | end | |
|
192 | assert issue.reload.closed? | |
|
193 | journal = Journal.first(:order => 'id DESC') | |
|
194 | assert_equal issue, journal.issue | |
|
195 | assert_include "Applied in changeset ecookbook:r12345.", journal.notes | |
|
196 | end | |
|
197 | end | |
|
198 | ||
|
181 | 199 | def test_commit_referencing_a_parent_project_issue |
|
182 | 200 | # repository of child project |
|
183 | 201 | r = Repository::Subversion.create!( |
@@ -197,6 +215,16 class ChangesetTest < ActiveSupport::TestCase | |||
|
197 | 215 | assert_equal 'r520', c.text_tag |
|
198 | 216 | end |
|
199 | 217 | |
|
218 | def test_text_tag_revision_with_same_project | |
|
219 | c = Changeset.new(:revision => '520', :repository => Project.find(1).repository) | |
|
220 | assert_equal 'r520', c.text_tag(Project.find(1)) | |
|
221 | end | |
|
222 | ||
|
223 | def test_text_tag_revision_with_different_project | |
|
224 | c = Changeset.new(:revision => '520', :repository => Project.find(1).repository) | |
|
225 | assert_equal 'ecookbook:r520', c.text_tag(Project.find(2)) | |
|
226 | end | |
|
227 | ||
|
200 | 228 | def test_text_tag_hash |
|
201 | 229 | c = Changeset.new( |
|
202 | 230 | :scmid => '7234cb2750b63f47bff735edc50a1c0a433c2518', |
@@ -204,6 +232,16 class ChangesetTest < ActiveSupport::TestCase | |||
|
204 | 232 | assert_equal 'commit:7234cb2750b63f47bff735edc50a1c0a433c2518', c.text_tag |
|
205 | 233 | end |
|
206 | 234 | |
|
235 | def test_text_tag_hash_with_same_project | |
|
236 | c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => Project.find(1).repository) | |
|
237 | assert_equal 'commit:7234cb27', c.text_tag(Project.find(1)) | |
|
238 | end | |
|
239 | ||
|
240 | def test_text_tag_hash_with_different_project | |
|
241 | c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => Project.find(1).repository) | |
|
242 | assert_equal 'ecookbook:commit:7234cb27', c.text_tag(Project.find(2)) | |
|
243 | end | |
|
244 | ||
|
207 | 245 | def test_text_tag_hash_all_number |
|
208 | 246 | c = Changeset.new(:scmid => '0123456789', :revision => '0123456789') |
|
209 | 247 | assert_equal 'commit:0123456789', c.text_tag |
General Comments 0
You need to be logged in to leave comments.
Login now