@@ -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 |
@@ -215,7 +219,7 class Changeset < ActiveRecord::Base | |||
|
215 | 219 | # don't change the status is the issue is closed |
|
216 | 220 | return if issue.status && issue.status.is_closed? |
|
217 | 221 | |
|
218 | journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag)) | |
|
222 | journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag(issue.project))) | |
|
219 | 223 | issue.status = status |
|
220 | 224 | unless Setting.commit_fix_done_ratio.blank? |
|
221 | 225 | issue.done_ratio = Setting.commit_fix_done_ratio.to_i |
@@ -234,7 +238,7 class Changeset < ActiveRecord::Base | |||
|
234 | 238 | :hours => hours, |
|
235 | 239 | :issue => issue, |
|
236 | 240 | :spent_on => commit_date, |
|
237 | :comments => l(:text_time_logged_by_changeset, :value => text_tag, | |
|
241 | :comments => l(:text_time_logged_by_changeset, :value => text_tag(issue.project), | |
|
238 | 242 | :locale => Setting.default_language) |
|
239 | 243 | ) |
|
240 | 244 | 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!( |
@@ -227,6 +245,16 class ChangesetTest < ActiveSupport::TestCase | |||
|
227 | 245 | assert_equal 'r520', c.text_tag |
|
228 | 246 | end |
|
229 | 247 | |
|
248 | def test_text_tag_revision_with_same_project | |
|
249 | c = Changeset.new(:revision => '520', :repository => Project.find(1).repository) | |
|
250 | assert_equal 'r520', c.text_tag(Project.find(1)) | |
|
251 | end | |
|
252 | ||
|
253 | def test_text_tag_revision_with_different_project | |
|
254 | c = Changeset.new(:revision => '520', :repository => Project.find(1).repository) | |
|
255 | assert_equal 'ecookbook:r520', c.text_tag(Project.find(2)) | |
|
256 | end | |
|
257 | ||
|
230 | 258 | def test_text_tag_hash |
|
231 | 259 | c = Changeset.new( |
|
232 | 260 | :scmid => '7234cb2750b63f47bff735edc50a1c0a433c2518', |
@@ -234,6 +262,16 class ChangesetTest < ActiveSupport::TestCase | |||
|
234 | 262 | assert_equal 'commit:7234cb2750b63f47bff735edc50a1c0a433c2518', c.text_tag |
|
235 | 263 | end |
|
236 | 264 | |
|
265 | def test_text_tag_hash_with_same_project | |
|
266 | c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => Project.find(1).repository) | |
|
267 | assert_equal 'commit:7234cb27', c.text_tag(Project.find(1)) | |
|
268 | end | |
|
269 | ||
|
270 | def test_text_tag_hash_with_different_project | |
|
271 | c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => Project.find(1).repository) | |
|
272 | assert_equal 'ecookbook:commit:7234cb27', c.text_tag(Project.find(2)) | |
|
273 | end | |
|
274 | ||
|
237 | 275 | def test_text_tag_hash_all_number |
|
238 | 276 | c = Changeset.new(:scmid => '0123456789', :revision => '0123456789') |
|
239 | 277 | assert_equal 'commit:0123456789', c.text_tag |
General Comments 0
You need to be logged in to leave comments.
Login now