diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-06-13 14:38:10 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-06-13 18:10:28 +0200 |
commit | d69853585415c1fa89a9e39e4f2e0853412b047b (patch) | |
tree | 1bcbbcf1c67b9460c1d7a0bfcc2e9ad3472c255b | |
parent | 2af8ace1dc49e5ff59be01c2063139a3244b9cee (diff) | |
download | gitlab-ce-d69853585415c1fa89a9e39e4f2e0853412b047b.tar.gz |
Add a test for issue sentence generation
-rw-r--r-- | app/helpers/merge_requests_helper.rb | 4 | ||||
-rw-r--r-- | app/views/projects/merge_requests/show/_state_widget.html.haml | 2 | ||||
-rw-r--r-- | spec/helpers/merge_requests_helper.rb | 12 |
3 files changed, 17 insertions, 1 deletions
diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index f3c3d437710..cc63db2035e 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -42,4 +42,8 @@ module MergeRequestsHelper "Branches: #{@merge_request.source_branch} #{separator} #{@merge_request.target_branch}" end end + + def issues_sentence(issues) + issues.map { |i| "##{i.iid}" }.to_sentence + end end diff --git a/app/views/projects/merge_requests/show/_state_widget.html.haml b/app/views/projects/merge_requests/show/_state_widget.html.haml index bff5b36821d..c30310f1258 100644 --- a/app/views/projects/merge_requests/show/_state_widget.html.haml +++ b/app/views/projects/merge_requests/show/_state_widget.html.haml @@ -37,5 +37,5 @@ %i.icon-ok Accepting this merge request will close #{@closes_issues.size == 1 ? 'issue' : 'issues'} = succeed '.' do - != gfm(@closes_issues.map { |i| "##{i.iid}" }.to_sentence) + != gfm(issues_sentence(@closes_issues)) diff --git a/spec/helpers/merge_requests_helper.rb b/spec/helpers/merge_requests_helper.rb new file mode 100644 index 00000000000..5a317c4886b --- /dev/null +++ b/spec/helpers/merge_requests_helper.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe MergeRequestsHelper do + describe :issues_sentence do + subject { issues_sentence(issues) } + let(:issues) do + [build(:issue, iid: 1), build(:issue, iid: 2), build(:issue, iid: 3)] + end + + it { should eq('#1, #2, and #3') } + end +end |