Commit 0a60b19b2362a9c8d669efbb7212d2a45098f77e
1 parent
24ec186a
Exists in
master
and in
4 other branches
Remove the commit_msg_with_link_to_issues helper and specs
Showing
2 changed files
with
0 additions
and
85 deletions
Show diff stats
app/helpers/commits_helper.rb
| 1 | 1 | module CommitsHelper |
| 2 | - def commit_msg_with_link_to_issues(project, message) | |
| 3 | - return '' unless message | |
| 4 | - out = '' | |
| 5 | - message.split(/(#[0-9]+)/m).each do |m| | |
| 6 | - if m =~ /(#([0-9]+))/m | |
| 7 | - begin | |
| 8 | - issue = project.issues.find($2) | |
| 9 | - out += link_to($1, project_issue_path(project, $2)) | |
| 10 | - rescue | |
| 11 | - out += $1 | |
| 12 | - end | |
| 13 | - else | |
| 14 | - out += m | |
| 15 | - end | |
| 16 | - end | |
| 17 | - preserve out | |
| 18 | - end | |
| 19 | - | |
| 20 | 2 | def identification_type(line) |
| 21 | 3 | if line[0] == "+" |
| 22 | 4 | "new" | ... | ... |
spec/helpers/commit_helper_spec.rb
| ... | ... | @@ -1,67 +0,0 @@ |
| 1 | -require "spec_helper" | |
| 2 | -include Haml::Helpers | |
| 3 | - | |
| 4 | -describe CommitsHelper do | |
| 5 | - | |
| 6 | - before do | |
| 7 | - @project = Factory :project | |
| 8 | - @other_project = Factory :project, :path => "OtherPath", :code => "OtherCode" | |
| 9 | - @fake_user = Factory :user | |
| 10 | - @valid_issue = Factory :issue, :assignee => @fake_user, :author => @fake_user, :project => @project | |
| 11 | - @invalid_issue = Factory :issue, :assignee => @fake_user, :author => @fake_user, :project => @other_project | |
| 12 | - end | |
| 13 | - | |
| 14 | - it "should provides return message untouched if no issue number present" do | |
| 15 | - message = "Dummy message without issue number" | |
| 16 | - | |
| 17 | - commit_msg_with_link_to_issues(@project, message).should eql message | |
| 18 | - end | |
| 19 | - | |
| 20 | - it "should returns message handled by preserve" do | |
| 21 | - message = "My brand new | |
| 22 | - Commit on multiple | |
| 23 | - lines !" | |
| 24 | - | |
| 25 | - #\n are converted to 
 as specified in preserve_rspec | |
| 26 | - expected = "My brand new
 Commit on multiple
 lines !" | |
| 27 | - | |
| 28 | - commit_msg_with_link_to_issues(@project, message).should eql expected | |
| 29 | - end | |
| 30 | - | |
| 31 | - it "should returns empty string if message undefined" do | |
| 32 | - commit_msg_with_link_to_issues(@project, nil).should eql '' | |
| 33 | - end | |
| 34 | - | |
| 35 | - it "should returns link_to issue for one valid issue in message" do | |
| 36 | - issue_id = @valid_issue.id | |
| 37 | - message = "One commit message ##{issue_id}" | |
| 38 | - expected = "One commit message <a href=\"/#{@project.code}/issues/#{issue_id}\">##{issue_id}</a>" | |
| 39 | - | |
| 40 | - commit_msg_with_link_to_issues(@project, message).should eql expected | |
| 41 | - end | |
| 42 | - | |
| 43 | - it "should returns message untouched for one invalid issue in message" do | |
| 44 | - issue_id = @invalid_issue.id | |
| 45 | - message = "One commit message ##{issue_id}" | |
| 46 | - | |
| 47 | - commit_msg_with_link_to_issues(@project, message).should eql message | |
| 48 | - end | |
| 49 | - | |
| 50 | - it "should handle multiple issue references in commit message" do | |
| 51 | - issue_id = @valid_issue.id | |
| 52 | - invalid_issue_id = @invalid_issue.id | |
| 53 | - | |
| 54 | - message = "One big commit message with a valid issue ##{issue_id} and an invalid one ##{invalid_issue_id}. | |
| 55 | - We reference valid ##{issue_id} multiple times (##{issue_id}) as the invalid ##{invalid_issue_id} is also | |
| 56 | - referenced another time (##{invalid_issue_id})" | |
| 57 | - | |
| 58 | - expected = "One big commit message with a valid issue <a href=\"/#{@project.code}/issues/#{issue_id}\">##{issue_id}</a>"+ | |
| 59 | - " and an invalid one ##{invalid_issue_id}.
 "+ | |
| 60 | - "We reference valid <a href=\"/#{@project.code}/issues/#{issue_id}\">##{issue_id}</a> multiple times "+ | |
| 61 | - "(<a href=\"/#{@project.code}/issues/#{issue_id}\">##{issue_id}</a>) "+ | |
| 62 | - "as the invalid ##{invalid_issue_id} is also
 referenced another time (##{invalid_issue_id})" | |
| 63 | - | |
| 64 | - commit_msg_with_link_to_issues(@project, message).should eql expected | |
| 65 | - end | |
| 66 | - | |
| 67 | -end | |
| 68 | 0 | \ No newline at end of file |